is errno supposed to be positive or negative?

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Wed Jun 27 05:35:51 EDT 2012


Hello,

Well, ok, errno is supposed to be zero, but in the rare cases where it's
not, what is intended?

Assuming ESOMETHING is always positive, in userspace errno is
positive, e.g. you test for errno == EBADF.

In barebox however most assignments use

	errno = -ESOMETHING

but there are also some tests and assignments without minus. barebox'
perror expects a negative errno which is also different from POSIX'
perror. strerror uses positive semantics in both barebox and POSIX.

I'd vote to fix barebox to use the same semantic for errno (and perror)
as POSIX.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the barebox mailing list