All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: Dan Carpenter <error27@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Andi Kleen <ak@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Mauro Carvalho Chehab <mchehab@redhat.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] kfifo: __must_check helper casts everything to unsigned
Date: Fri, 13 Aug 2010 21:35:52 +0000	[thread overview]
Message-ID: <1281735352.19775.1.camel@wall-e.seibold.net> (raw)
In-Reply-To: <20100813205936.GS645@bicker>

There is a new wrapper to add a __must_check to kfifo macros.  The
problem is that it casts everything to unsigned.  That breaks for places
that check stuff like:

	if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0)

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Stefani Seibold <stefani@seibold.net>

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 311f875..437cc0d 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -177,6 +177,12 @@ __kfifo_must_check_helper(unsigned int val)
 	return val;
 }
 
+static inline int __must_check
+__kfifo_must_check_helper_signed(int val)
+{
+	return val;
+}
+
 /**
  * kfifo_initialized - Check if the fifo is initialized
  * @fifo: address of the fifo to check
@@ -323,7 +329,7 @@ __kfifo_must_check_helper( \
  * Return 0 if no error, otherwise an error code.
  */
 #define kfifo_alloc(fifo, size, gfp_mask) \
-__kfifo_must_check_helper( \
+__kfifo_must_check_helper_signed( \
 ({ \
 	typeof(fifo + 1) __tmp = (fifo); \
 	struct __kfifo *__kfifo = &__tmp->kfifo; \
@@ -609,7 +615,7 @@ __kfifo_must_check_helper( \
  * writer, you don't need extra locking to use these macro.
  */
 #define	kfifo_from_user(fifo, from, len, copied) \
-__kfifo_must_check_helper( \
+__kfifo_must_check_helper_signed( \
 ({ \
 	typeof(fifo + 1) __tmp = (fifo); \
 	const void __user *__from = (from); \
@@ -637,7 +643,7 @@ __kfifo_must_check_helper( \
  * writer, you don't need extra locking to use these macro.
  */
 #define	kfifo_to_user(fifo, to, len, copied) \
-__kfifo_must_check_helper( \
+__kfifo_must_check_helper_signed( \
 ({ \
 	typeof(fifo + 1) __tmp = (fifo); \
 	void __user *__to = (to); \



WARNING: multiple messages have this Message-ID (diff)
From: Stefani Seibold <stefani@seibold.net>
To: Dan Carpenter <error27@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Andi Kleen <ak@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Mauro Carvalho Chehab <mchehab@redhat.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] kfifo: __must_check helper casts everything to unsigned
Date: Fri, 13 Aug 2010 23:35:52 +0200	[thread overview]
Message-ID: <1281735352.19775.1.camel@wall-e.seibold.net> (raw)
In-Reply-To: <20100813205936.GS645@bicker>

There is a new wrapper to add a __must_check to kfifo macros.  The
problem is that it casts everything to unsigned.  That breaks for places
that check stuff like:

	if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0)

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Stefani Seibold <stefani@seibold.net>

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 311f875..437cc0d 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -177,6 +177,12 @@ __kfifo_must_check_helper(unsigned int val)
 	return val;
 }
 
+static inline int __must_check
+__kfifo_must_check_helper_signed(int val)
+{
+	return val;
+}
+
 /**
  * kfifo_initialized - Check if the fifo is initialized
  * @fifo: address of the fifo to check
@@ -323,7 +329,7 @@ __kfifo_must_check_helper( \
  * Return 0 if no error, otherwise an error code.
  */
 #define kfifo_alloc(fifo, size, gfp_mask) \
-__kfifo_must_check_helper( \
+__kfifo_must_check_helper_signed( \
 ({ \
 	typeof(fifo + 1) __tmp = (fifo); \
 	struct __kfifo *__kfifo = &__tmp->kfifo; \
@@ -609,7 +615,7 @@ __kfifo_must_check_helper( \
  * writer, you don't need extra locking to use these macro.
  */
 #define	kfifo_from_user(fifo, from, len, copied) \
-__kfifo_must_check_helper( \
+__kfifo_must_check_helper_signed( \
 ({ \
 	typeof(fifo + 1) __tmp = (fifo); \
 	const void __user *__from = (from); \
@@ -637,7 +643,7 @@ __kfifo_must_check_helper( \
  * writer, you don't need extra locking to use these macro.
  */
 #define	kfifo_to_user(fifo, to, len, copied) \
-__kfifo_must_check_helper( \
+__kfifo_must_check_helper_signed( \
 ({ \
 	typeof(fifo + 1) __tmp = (fifo); \
 	void __user *__to = (to); \



  reply	other threads:[~2010-08-13 21:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-13 20:59 [patch] kfifo: __must_check helper casts everything to unsigned Dan Carpenter
2010-08-13 20:59 ` Dan Carpenter
2010-08-13 21:35 ` Stefani Seibold [this message]
2010-08-13 21:35   ` 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=1281735352.19775.1.camel@wall-e.seibold.net \
    --to=stefani@seibold.net \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=error27@gmail.com \
    --cc=gregkh@suse.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@redhat.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 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.