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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 15 Jan 2008 08:17:04 +0800
From:	"Dave Young" <hidave.darkstar@...il.com>
To:	"Cornelia Huck" <cornelia.huck@...ibm.com>
Cc:	"Greg KH" <gregkh@...e.de>, stefanr@...6.in-berlin.de,
	James.Bottomley@...senpartnership.com, a.zummo@...ertech.it,
	peterz@...radead.org, cbou@...l.ru, linux-kernel@...r.kernel.org,
	"David Brownell" <david-b@...bell.net>, krh@...hat.com,
	stern@...land.harvard.edu, dwmw2@...radead.org,
	davem@...emloft.net, jarkao2@...il.com
Subject: Re: [PATCH 1/7] driver-core : add class iteration api

On Jan 14, 2008 8:13 PM, Cornelia Huck <cornelia.huck@...ibm.com> wrote:
> On Sat, 12 Jan 2008 17:47:54 +0800,
> Dave Young <hidave.darkstar@...il.com> wrote:
>
> Minor style suggestion (same for class_find_child):
>
> > +struct device *class_find_device(struct class *class, void *data,
> > +                                int (*match)(struct device *, void *))
> > +{
> > +     struct device *dev;
> > +     int error = 1;
>
> How about using inverse logic here (e.g., start with int found = 0)...

Sounds good, will do. Thanks.

>
> > +
> > +     if (!class)
> > +             return NULL;
> > +
> > +     down(&class->sem);
> > +     list_for_each_entry(dev, &class->devices, node) {
> > +             dev = get_device(dev);
> > +             if (dev) {
> > +                     if (match(dev, data)) {
> > +                             error = 0;
>
> ...and set found = 1 here...
>
> > +                             break;
> > +                     } else
> > +                             put_device(dev);
> > +             } else
> > +                     break;
> > +     }
> > +     up(&class->sem);
> > +
> > +     if (error)
> > +             return NULL;
> > +     return dev;
>
> ...and do
>         return found ? dev : NULL;
> in the end?
>
> Especially since not finding the device is not really an error.
>
> > +}
>
> Otherwise this looks fine to me.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ