News for hackers. Stuff that matters.
Re: Critical crypto bug leaves Linux, hundreds of apps open ... by cjensen on Tuesday March 04, 2014 @03:25PM (#7342859)
No. CreateFile returns INVALID_HANDLE_VALUE which is -1. Compare this to CreateSemaphore which also returns a HANDLE, but returns NULL[1] on failure.

Returning int(0) as a failure is often done in C if the return value is a boolean since C lacks a true boolean type.

[1] NULL should never be used in actual code because it is ambiguous.

Re: Critical crypto bug leaves Linux, hundreds of apps open ... by userbinator on Tuesday March 04, 2014 @07:18PM (#7344285)
Those are functions that return more possible success values than failure values. The three common conventions seem to be:

Nonzero: error code, zero: success

Nonzero: one of many possible success values, zero: error (e.g. malloc())

Negative: error code, positive: one of many possible success values

And each has its tradeoffs.