Q: The strerror() function doesn't seem to work quite right, sometimes. It sometimes returns an incorrect result, sometimes works.
A: strerror() happens to ignore its argument, contrary to the documentation and common sense. It works directly with errno, rather than its argument. The workaround: instead of saving errno, save strerror()'s result.