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]
Date:   Mon, 22 May 2017 09:21:33 +0800
From:   Chunfeng Yun <chunfeng.yun@...iatek.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC:     Masahiro Yamada <yamada.masahiro@...ionext.com>,
        <linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] usb: mtu3: cleanup with list_first_entry_or_null()

Hi,
On Sat, 2017-05-20 at 21:19 +0200, Greg Kroah-Hartman wrote:
> On Sun, May 21, 2017 at 02:05:31AM +0900, Masahiro Yamada wrote:
> > The combo of list_empty() and list_first_entry() can be replaced with
> > list_first_entry_or_null().
> > 
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
> > ---
> > 
> >  drivers/usb/mtu3/mtu3.h | 8 ++------
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
> > index aa6fd6a..7b6dc23 100644
> > --- a/drivers/usb/mtu3/mtu3.h
> > +++ b/drivers/usb/mtu3/mtu3.h
> > @@ -356,12 +356,8 @@ static inline struct mtu3_ep *to_mtu3_ep(struct usb_ep *ep)
> >  
> >  static inline struct mtu3_request *next_request(struct mtu3_ep *mep)
> >  {
> > -	struct list_head *queue = &mep->req_list;
> > -
> > -	if (list_empty(queue))
> > -		return NULL;
> > -
> > -	return list_first_entry(queue, struct mtu3_request, list);
> > +	return list_first_entry_or_null(&mep->req_list, struct mtu3_request,
> > +					list);
> 
> Even better, why is this an inlined function at all?  Why not just have
> it "open coded" everywhere it is used?
> 
This can avoid repeated function definition, currently it is used in
three files.

> thanks,
> 
> greg k-h


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ