Most of the standard C system calls I use return 0 on success, -1 on failure and sometimes an arbitrary positive int as information to the caller.
This means comparing to -1 to check on success, eg:-
I personally find returning a 1 (true) on success and 0 (false) on failure makes for easier to read code:-Code:if (thatWorked != -1) printf("Hooray!");
.... but I'm trying to adhere to common standards as much as possible, and having some functions return 1 on success and some return 0 on success makes for even worse code reading.Code:if (thatWorked) printf("Hooray!");
Any thoughts? What style do you use?