Say what you will about the half dozen mutually incomprehensible error code standards in Win32, at least 0 indicates success in all of them. Well, except for BOOLEAN.
I really don't understand why anyone would return an int and have 0 indicate failure. OpenSSL does this too, and it makes no sense to me. I don't know how far this goes back, but clearly we have a long tradition of programs returning 0 to the OS to indicate no error.
Using zero for errors means you can express error checking directly with C expressions that appear boolean. It's not as safe or rigorous, but is more readable.
Yes, you can, but that doesn't read very well to my eyes, given most function names. if(open()), if(read()), if (CreateWindowExW()), all suggest success to me.
if (!open(...)) goto fail;
if (!read(...)) goto fail;
if (!close(...)) goto fail;
reads a lot nicer to me. Although, the reality is that you need to assign to an error variable, which makes it not as nice and clean.
I really don't understand why anyone would return an int and have 0 indicate failure. OpenSSL does this too, and it makes no sense to me. I don't know how far this goes back, but clearly we have a long tradition of programs returning 0 to the OS to indicate no error.