All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Richard Yang <weiyang@linux.vnet.ibm.com>
Cc: Stefani Seibold <stefani@seibold.net>,
	Yuanhan Liu <yliu.null@gmail.com>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Fengguang Wu <fengguang.wu@intel.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCH] kfifo: remove unnecessary type check
Date: Fri, 26 Oct 2012 20:31:38 +0800	[thread overview]
Message-ID: <20121026123138.GF2778@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <20121026095244.GA815@richard.(null)>

On Fri, Oct 26, 2012 at 05:52:44PM +0800, Richard Yang wrote:
> On Fri, Oct 26, 2012 at 02:11:45PM +0800, Yuanhan Liu wrote:
> >On Fri, Oct 26, 2012 at 07:38:31AM +0200, Stefani Seibold wrote:
> >> Am Freitag, den 26.10.2012, 09:46 +0800 schrieb Yuanhan Liu:
> >> > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> >> > 
> >> > Firstly, this kind of type check doesn't work. It does something similay
> >> > like following:
> >> > 	void * __dummy = NULL;
> >> > 	__buf = __dummy;
> >> > 
> >> > __dummy is defined as void *. Thus it will not trigger warnings as
> >> > expected.
> >> > 
> >> > Second, we don't need that kind of check. Since the prototype
> >> > of __kfifo_out is:
> >> > 	unsigned int __kfifo_out(struct __kfifo *fifo,  void *buf, unsigned int len)
> >> > 
> >> > buf is defined as void *, so we don't need do the type check. Remove it.
> >> > 
> >> > LINK: https://lkml.org/lkml/2012/10/25/386
> >> > LINK: https://lkml.org/lkml/2012/10/25/584
> >> > 
> >> > Cc: Andrew Morton <akpm@linux-foundation.org>
> >> > Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
> >> > Cc: Stefani Seibold <stefani@seibold.net>
> >> > Cc: Fengguang Wu <fengguang.wu@intel.com>
> >> > Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> >> > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> >> > ---
> >> >  include/linux/kfifo.h | 20 --------------------
> >> >  1 file changed, 20 deletions(-)
> >> > 
> >> > diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
> >> > index 10308c6..b8c1d03 100644
> >> > --- a/include/linux/kfifo.h
> >> > +++ b/include/linux/kfifo.h
> >> > @@ -390,10 +390,6 @@ __kfifo_int_must_check_helper( \
> >> >  	unsigned int __ret; \
> >> >  	const size_t __recsize = sizeof(*__tmp->rectype); \
> >> >  	struct __kfifo *__kfifo = &__tmp->kfifo; \
> >> > -	if (0) { \
> >> > -		typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
> >> > -		__dummy = (typeof(__val))NULL; \
> >> > -	} \
> >> >  	if (__recsize) \
> >> >  		__ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \
> >> >  			__recsize); \
> >> > @@ -432,8 +428,6 @@ __kfifo_uint_must_check_helper( \
> >> >  	unsigned int __ret; \
> >> >  	const size_t __recsize = sizeof(*__tmp->rectype); \
> >> >  	struct __kfifo *__kfifo = &__tmp->kfifo; \
> >> > -	if (0) \
> >> > -		__val = (typeof(__tmp->ptr))0; \
> >> >  	if (__recsize) \
> >> >  		__ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \
> >> >  			__recsize); \
> >> > @@ -473,8 +467,6 @@ __kfifo_uint_must_check_helper( \
> >> >  	unsigned int __ret; \
> >> >  	const size_t __recsize = sizeof(*__tmp->rectype); \
> >> >  	struct __kfifo *__kfifo = &__tmp->kfifo; \
> >> > -	if (0) \
> >> > -		__val = (typeof(__tmp->ptr))NULL; \
> >> >  	if (__recsize) \
> >> >  		__ret = __kfifo_out_peek_r(__kfifo, __val, sizeof(*__val), \
> >> >  			__recsize); \
> >> > @@ -512,10 +504,6 @@ __kfifo_uint_must_check_helper( \
> >> >  	unsigned long __n = (n); \
> >> >  	const size_t __recsize = sizeof(*__tmp->rectype); \
> >> >  	struct __kfifo *__kfifo = &__tmp->kfifo; \
> >> > -	if (0) { \
> >> > -		typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
> >> > -		__dummy = (typeof(__buf))NULL; \
> >> > -	} \
> >> >  	(__recsize) ?\
> >> >  	__kfifo_in_r(__kfifo, __buf, __n, __recsize) : \
> >> >  	__kfifo_in(__kfifo, __buf, __n); \
> >> > @@ -565,10 +553,6 @@ __kfifo_uint_must_check_helper( \
> >> >  	unsigned long __n = (n); \
> >> >  	const size_t __recsize = sizeof(*__tmp->rectype); \
> >> >  	struct __kfifo *__kfifo = &__tmp->kfifo; \
> >> > -	if (0) { \
> >> > -		typeof(__tmp->ptr) __dummy = NULL; \
> >> > -		__buf = __dummy; \
> >> > -	} \
> >> >  	(__recsize) ?\
> >> >  	__kfifo_out_r(__kfifo, __buf, __n, __recsize) : \
> >> >  	__kfifo_out(__kfifo, __buf, __n); \
> >> > @@ -777,10 +761,6 @@ __kfifo_uint_must_check_helper( \
> >> >  	unsigned long __n = (n); \
> >> >  	const size_t __recsize = sizeof(*__tmp->rectype); \
> >> >  	struct __kfifo *__kfifo = &__tmp->kfifo; \
> >> > -	if (0) { \
> >> > -		typeof(__tmp->ptr) __dummy __attribute__ ((unused)) = NULL; \
> >> > -		__buf = __dummy; \
> >> > -	} \
> >> >  	(__recsize) ? \
> >> >  	__kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \
> >> >  	__kfifo_out_peek(__kfifo, __buf, __n); \
> >> 
> >> Did you tried to compile the whole kernel including all the drivers with
> >> your patch?
> >
> >Hi Stefani,
> >
> >I did a build test, it did't introduce any new compile errors and
> >warnings. While, I haven't tried make allmodconfig then. Does this patch
> >seems wrong to you?
> 
> Hmm, in my mind, those warnings are produced by the code you removed.
> So it is reasonable that you see no new warnings.

Hi Yang,

Nope. It's not hard to tell they are old warnings. And as you can see from
the email I posted, I did a build compile with and without applying this
patch, and does make C=2 2>/tmp/out.{before,after}. I then compared the
two file, they are exactly same. So, no new warnings introduced.

Thanks,
Yuanhan Liu

  parent reply	other threads:[~2012-10-26 12:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26  1:46 [PATCH] kfifo: remove unnecessary type check Yuanhan Liu
2012-10-26  5:38 ` Stefani Seibold
2012-10-26  6:11   ` Yuanhan Liu
2012-10-26  6:51     ` Stefani Seibold
2012-10-26  7:17       ` Yuanhan Liu
2012-10-26  7:33         ` Yuanhan Liu
2012-10-26  9:26         ` Stefani Seibold
2012-10-26 13:04           ` Yuanhan Liu
2012-10-26 13:42             ` Stefani Seibold
2012-10-27  8:43               ` Yuanhan Liu
     [not found]     ` <20121026095244.GA815@richard.(null)>
2012-10-26 12:31       ` Yuanhan Liu [this message]
     [not found]         ` <20121027015558.GA3983@richard.(null)>
2012-10-27  8:48           ` Yuanhan Liu

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=20121026123138.GF2778@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=stefani@seibold.net \
    --cc=weiyang@linux.vnet.ibm.com \
    --cc=yliu.null@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 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.