Good day,
I'm reading through some old code I've been asked to maintain, and I see a number of functions that are like so:
uint32_t myFunc(int* pI);
In the case of error conditions within the body of the function, the function exits early by returning a negative errno
value, ie: return (-EINVAL);
Is this value standard (ie: C99, ANSI), C? I've read in the comments that apparently doing this sets the errno
to EINVAL
, but I can't find any documentation to support this. Wouldn't it be better to just declare the function as a signed int (ie: int32_t myFunc(int* pI)
) and treat negative values as error codes, rather than attempt to set errno
in this manner?