Oh god, the discussion about fix is the most C thing ever, it makes the recent musl issue much more understandable:
- Let's return -1 for error
- People might not expect new -1 value, let's return 0
- How are clients supposed to differ between old 0 and new 0
It's not even C, most of the Windows API solves this problem by operating on handles error codes are clear and error checking becomes easier (though it still goes wrong). Good old winerror even has bit patterns to see what sort of error you're dealing with.
The Unix flavour of C, which relies on passing magical numbers, is making C's lack of proper error handling patterns a lot worse.