Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

errno or -errno or -1 or...WTF?!

Name: Anonymous 2015-01-12 0:41

http://man7.org/linux/man-pages/man2/syscalls.2.html

Note: system calls indicate a failure by returning a negative error number to the caller; when this happens, the wrapper function negates the returned error number (to make it positive), copies it to errno, and returns -1 to the caller of the wrapper.

So the system calls quite sensibly return a negative number to indicate an error, but then someone added code to be executed every single time a syscall is made just to check its return value and store that in a separate variable, turning all errors into -1? Now every time you use a syscall you have to check for errors and then pull the correct error number back out of errno instead of straightforwardly passing the error value through as the return value? Which brain-damaged idiot thought this was a good idea!?

Name: Anonymous 2016-08-08 13:09

>>13
Yes, everyone knows that ERRNO is part of POSIX, but is this silly wrapper and negation nonsense part of POSIX as well?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List