lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.02.1306130955380.2260@hadrien>
Date:	Thu, 13 Jun 2013 09:56:11 +0200 (CEST)
From:	Julia Lawall <julia.lawall@...6.fr>
To:	"Michael S. Tsirkin" <mst@...hat.com>
cc:	Rusty Russell <rusty@...tcorp.com.au>,
	Julia Lawall <julia.lawall@...6.fr>,
	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>, Thomas Meyer <thomas@...3r.de>,
	grant.likely@...aro.org, rob.herring@...xeda.com,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [RFC] PTR_ERR: return 0 if ptr isn't an error value.

On Thu, 13 Jun 2013, Michael S. Tsirkin wrote:

> On Thu, Jun 13, 2013 at 02:07:40PM +0930, Rusty Russell wrote:
> > Julia Lawall <julia.lawall@...6.fr> writes:
> > > On Mon, 3 Jun 2013, Uwe Kleine-König wrote:
> > > For a random example, here is a function that currently uses PTR_RET:
> >
> > Heheh, nice choice: I think I wrote that code originally :)
> >
> > > static int __net_init iptable_raw_net_init(struct net *net)
> > > {
> > >         struct ipt_replace *repl;
> > >
> > >         repl = ipt_alloc_initial_table(&packet_raw);
> > > 	if (repl == NULL)
> > >                 return -ENOMEM;
> > >         net->ipv4.iptable_raw =
> > >                 ipt_register_table(net, &packet_raw, repl);
> > > 	kfree(repl);
> > >         return PTR_RET(net->ipv4.iptable_raw);
> > > }
> > >
> > > If it becomes return PTR_ERR(...); at the end, won't it look like the
> > > function always fails?
> >
> > That is a valid point, though in this case the reader will know that
> > can't be the case.
> >
> > On the other hand, there's an incremental learning curve cost to every
> > convenience function we add.  There are only 50 places where we use
> > PTR_RET(), so it's not saving us very much typing over the clearest
> > solution: open-coding the test.
> >
> > I think using PTR_ERR() is a less bad solution than promoting PTR_RET,
> > which has a non-obvious name.
> >
> > Cheers,
> > Rusty.
>
> Will a longer name make the function more obvious?
> 	PTR_ERR_OR_ZERO() ?
> 	PTR_ERR0() ?
> PTR_ERR() can then stay simple for cases where we know we
> are on the error path.

I was thinking of something along those lines.  And in that case, PTR_ERR
could stay without the additional test.

julia

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ