All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Randy Dunlap <randy.dunlap@oracle.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Stefani Seibold <stefani@seibold.net>
Subject: Re: kfifo must_check warning
Date: Tue, 19 Oct 2010 22:12:42 -0700	[thread overview]
Message-ID: <20101019221242.c732e1fa.akpm@linux-foundation.org> (raw)
In-Reply-To: <20101019151048.ae79bb25.randy.dunlap@oracle.com>

On Tue, 19 Oct 2010 15:10:48 -0700 Randy Dunlap <randy.dunlap@oracle.com> wrote:

> In 2.6.36-rc8, I see this build warning:
> 
> drivers/char/n_gsm.c: In function 'gsm_dlci_alloc':
> drivers/char/n_gsm.c:1580: warning: ignoring return value of '__kfifo_must_check_helper', declared with attribute warn_unused_result
> 
> The helper seems to be getting in the way (?).  The driver code does this:
> 
> 	if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
> 		kfree(dlci);
> 		return NULL;
> 	}
> 
> Should the driver code be doing something else?
> or should the kfifo_alloc() macro be checking the result of the helper?
> 

A gcc bug, I'd say.  The code looks OK and my gcc doesn't warn.

Perhaps see if you can find some code transformation in n_gsm.c which
makes it go away?  Add a new local variable or something.


I did see a probably unrelated bug in there though. 
__kfifo_must_check_helper() coerces its arg into an `unsigned int' and
returns an unsigned int.  Consequently if kfifo_alloc() tries to return
-EINVAL, the above-quoted code won't detect the error: it will see
-EINVAL as a large, positive unsigned value.

I don't see a simple fix for that apart from creating several flavours
of __kfifo_must_check_helper() and carefully going through each
instance and using the one which takes (and returns) the correct type.

A suitable temporary 2.6.37 patch would bee to just disable
__kfifo_must_check_helper():

--- a/include/linux/kfifo.h~a
+++ a/include/linux/kfifo.h
@@ -171,11 +171,7 @@ struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PT
 	}
 
 
-static inline unsigned int __must_check
-__kfifo_must_check_helper(unsigned int val)
-{
-	return val;
-}
+#define __kfifo_must_check_helper(x) (x)
 
 /**
  * kfifo_initialized - Check if the fifo is initialized
_


  reply	other threads:[~2010-10-20  5:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-19 22:10 kfifo must_check warning Randy Dunlap
2010-10-20  5:12 ` Andrew Morton [this message]
2010-10-20 16:46   ` kfifo must_check warning (+ patch) Randy Dunlap
2010-10-20 17:51     ` miltonm
2010-10-20 18:37     ` Alan Cox
2010-10-20 18:56       ` Andrew Morton
2010-10-20 20:09         ` 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=20101019221242.c732e1fa.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=randy.dunlap@oracle.com \
    --cc=stefani@seibold.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.