According to "The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition":
"The value of errno should only be examined when it is indicated to be valid by a function's return value."
So using errno in the above code is wrong.
According to "The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition":
"The value of errno should only be examined when it is indicated to be valid by a function's return value."
So using errno in the above code is wrong.