Hi all,
I'm just curious to understand why some system calls, let's say mkdir(2), return 0 on success and a different value on error (while setting errno at the same time). In this way the coding pattern seems to be:
while if the mkdir (and other calls) returns a non-zero value on success it could be rewritten as
that seems to me more C-like. Can anybody explain me the rationale behind the above code pattern?
Thanks
I'm just curious to understand why some system calls, let's say mkdir(2), return 0 on success and a different value on error (while setting errno at the same time). In this way the coding pattern seems to be:
Code:
error = mkdir(...);
if( error ) return error;
while if the mkdir (and other calls) returns a non-zero value on success it could be rewritten as
Code:
if( ! mkdir(.. ) ) //error
that seems to me more C-like. Can anybody explain me the rationale behind the above code pattern?
Thanks