public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>, Andi Kleen <andi@firstfloor.org>,
	Amerigo Wang <xiyou.wangcong@gmail.com>,
	Joe Perches <joe@perches.com>,
	Roger Quadros <quadros.roger@gmail.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Mauro Carvalho Chehab <mchehab@redhat.com>
Subject: Re: [PATCH] kfifo: fix warn_unused_result
Date: Mon, 14 Dec 2009 05:36:39 +0100	[thread overview]
Message-ID: <1260765399.6620.51.camel@wall-e> (raw)
In-Reply-To: <20091213142907.d0ac63da.akpm@linux-foundation.org>

Am Sonntag, den 13.12.2009, 14:29 -0800 schrieb Andrew Morton:
> On Fri, 11 Dec 2009 10:18:28 +0100 Stefani Seibold <stefani@seibold.net> wrote:
> 
> > As requested by Andrew Morton:
> > 
> > This patch fix the "ignoring return value of '...', declared with
> > attribute warn_unused_result" compiler warning in several users of the
> > new kfifo API.
> > 
> > The patch-set is against current mm tree from 11-Dec-2009
> > 
> > ...
> >
> > --- mmotm/drivers/char/nozomi.c	2009-12-11 08:31:46.670736197 +0100
> > +++ linux-2.6.32/drivers/char/nozomi.c	2009-12-11 09:25:46.941436203 +0100
> > @@ -685,8 +685,9 @@ static int nozomi_read_config_table(stru
> >  		dump_table(dc);
> >  
> >  		for (i = PORT_MDM; i < MAX_PORT; i++) {
> > -			kfifo_alloc(&dc->port[i].fifo_ul,
> > -				FIFO_BUFFER_SIZE_UL, GFP_ATOMIC);
> > +			if (kfifo_alloc(&dc->port[i].fifo_ul,
> > +				FIFO_BUFFER_SIZE_UL, GFP_ATOMIC))
> > +					BUG();
> 
> No, we can't do this.  GFP_ATOMIC allocations are unreliable and can
> fail.  The calling code *has* to detect the failure and then take some
> recovery action.
> 
> It would be better to leave the warning in place, rather than to add
> this runtime landmine.
> 

The problem is that the old code did not provide an error check. So i
don't think it is a land mine, because this drivers tries to allocate a
some kfifo inside an interrupt. But i think i am able to understand the
code and fix it.

> >  		input_sync(kp.dev);
> > -		kfifo_in_locked(&sonypi_device.input_fifo,
> > +		if (kfifo_in_locked(&sonypi_device.input_fifo,
> >  			(unsigned char *)&kp, sizeof(kp),
> > -			&sonypi_device.input_fifo_lock);
> > +			&sonypi_device.input_fifo_lock) != sizeof(kp))
> > +				BUG();
> 
> The rest of the patch seems to be adding BUG()s if kfifo_in() fails. 
> All over the place.
> 
> If that's the appropriate way to handle failure for these callsites
> then it would be neater to do this in the callee.  ie, add a new
> 
> unsigned int kfifo_in_nonpartial(struct kfifo *fifo,
>                         const unsigned char *from, unsigned int len)
> {
> 	unsigned int ret = kfifo_in(fifo, from, len);
> 
> 	BUG_ON(ret != len);
> 	return ret;
> }
> 

No, i don't like to idea to introduce a new API call, because i must
also introduce a 

kfifo_out_nonpartial()
kfifo_in_nonpartial_locked()
and
kfifo_out_nonpartial_locked()

I don't like this _locked functions, it is a design break and only
introduced for compatibility reasons.

This will also go way if i get the okay for the new kqueue API.

If it is okay, i will remove the __must_check from kfifo_in and
kfifo_in_locked. But the kfifo_out and kfifo_out_locked check must be
performed and if it fails, it is a real BUG.



  parent reply	other threads:[~2009-12-14  4:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-11  9:18 [PATCH] kfifo: fix warn_unused_result Stefani Seibold
2009-12-13 22:29 ` Andrew Morton
2009-12-14  0:50   ` Alan Cox
2009-12-14  4:36   ` Stefani Seibold [this message]
2009-12-14  5:58     ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2009-12-14  5:25 Stefani Seibold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1260765399.6620.51.camel@wall-e \
    --to=stefani@seibold.net \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@suse.de \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --cc=quadros.roger@gmail.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox