mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* is errno supposed to be positive or negative?
@ 2012-06-27  9:35 Uwe Kleine-König
  2012-06-27  9:51 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2012-06-27  9:35 UTC (permalink / raw)
  To: barebox

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/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: is errno supposed to be positive or negative?
  2012-06-27  9:35 is errno supposed to be positive or negative? Uwe Kleine-König
@ 2012-06-27  9:51 ` Sascha Hauer
  2012-06-27 10:59   ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2012-06-27  9:51 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox

On Wed, Jun 27, 2012 at 11:35:51AM +0200, Uwe Kleine-König wrote:
> 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.

Your tree is not up to date.

see:

commit 6188685091c58c9772b990cf0ca6ac522f97a9d0
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Sun May 13 12:43:58 2012 +0200

    Make errno a positive value
    
    Normally errno contains a positive error value. A certain unnamed developer
    mixed this up while implementing U-Boot-v2. Also, normally errno is never
    set to zero by any library function. This patch fixes this.
    
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: is errno supposed to be positive or negative?
  2012-06-27  9:51 ` Sascha Hauer
@ 2012-06-27 10:59   ` Uwe Kleine-König
  2012-06-27 13:53     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2012-06-27 10:59 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Wed, Jun 27, 2012 at 11:51:28AM +0200, Sascha Hauer wrote:
> On Wed, Jun 27, 2012 at 11:35:51AM +0200, Uwe Kleine-König wrote:
> > 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.
> 
> Your tree is not up to date.
> 
> see:
> 
> commit 6188685091c58c9772b990cf0ca6ac522f97a9d0
> Author: Sascha Hauer <s.hauer@pengutronix.de>
> Date:   Sun May 13 12:43:58 2012 +0200
> 
>     Make errno a positive value
>     
>     Normally errno contains a positive error value. A certain unnamed developer
>     mixed this up while implementing U-Boot-v2. Also, normally errno is never
>     set to zero by any library function. This patch fixes this.
>     
>     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
OK, you're right.

There is just:

	$ git grep errno\ =\ -E origin/master
	origin/master:fs/ramfs.c:                       errno = -ENOENT;

Best regards
Uwe

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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: is errno supposed to be positive or negative?
  2012-06-27 10:59   ` Uwe Kleine-König
@ 2012-06-27 13:53     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-06-27 13:53 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox

On Wed, Jun 27, 2012 at 12:59:15PM +0200, Uwe Kleine-König wrote:
> On Wed, Jun 27, 2012 at 11:51:28AM +0200, Sascha Hauer wrote:
> > On Wed, Jun 27, 2012 at 11:35:51AM +0200, Uwe Kleine-König wrote:
> > > 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.
> > 
> > Your tree is not up to date.
> > 
> > see:
> > 
> > commit 6188685091c58c9772b990cf0ca6ac522f97a9d0
> > Author: Sascha Hauer <s.hauer@pengutronix.de>
> > Date:   Sun May 13 12:43:58 2012 +0200
> > 
> >     Make errno a positive value
> >     
> >     Normally errno contains a positive error value. A certain unnamed developer
> >     mixed this up while implementing U-Boot-v2. Also, normally errno is never
> >     set to zero by any library function. This patch fixes this.
> >     
> >     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> OK, you're right.
> 
> There is just:
> 
> 	$ git grep errno\ =\ -E origin/master
> 	origin/master:fs/ramfs.c:                       errno = -ENOENT;

Oops, this shouldn't be there at all. errno should be set in the
filesystem layer, not in the fs drivers.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-27 13:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27  9:35 is errno supposed to be positive or negative? Uwe Kleine-König
2012-06-27  9:51 ` Sascha Hauer
2012-06-27 10:59   ` Uwe Kleine-König
2012-06-27 13:53     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox