linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Stefani Seibold <stefani@seibold.net>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/5] kfifo: remove unnecessary type check
Date: Thu, 10 Jan 2013 15:12:23 +0800	[thread overview]
Message-ID: <20130110071223.GE304@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1357745379.11538.4.camel@wall-e>

On Wed, Jan 09, 2013 at 04:29:39PM +0100, Stefani Seibold wrote:
> Am Mittwoch, den 09.01.2013, 10:35 +0800 schrieb Yuanhan Liu:
> > On Tue, Jan 08, 2013 at 10:51:04PM +0100, Stefani Seibold wrote:
> > > Am Dienstag, den 08.01.2013, 22:57 +0800 schrieb Yuanhan Liu:
> > > > Firstly, this kind of type check doesn't work. It does something similar
> > > > as 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.
> > > > 
> > > 
> > > Thats wrong.
> > > 
> > > First the type checking will be used in kfifo_put() and kfifo_in() for
> > > const types to check if the passed type of the data can converted to the
> > > fifo element type. 
> > 
> > Hi Stefani,
> > 
> > Yes, I see now. After rechecking the code, I found that this kind of
> > type checking only works for those static defined kifo by
> > DECLARE/DEFINE_KFIFO. As the ptrtype is the same as the data type:
> > 
> >     /* the 4th argument "type" is "ptrtype" */
> >     #define STRUCT_KFIFO(type, size) struct __STRUCT_KFIFO(type, size, 0, type)
> > 
> >     #define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo
> > 
> > While, for those kfifo dynamically allocated, the type checking will not
> > work as expected then as ptrtype is always "void":
> > 
> >     struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void);
> > 
> 
> You should avoid using struct kfifo, as you can read in kfifo.h this is
> only for compatibility reason.

Well, the fact is struct kfifo is used far more widely than
DECLARE/DEFINE_KFIFO; say above 50 vs less than 10.

Thanks.

	--yliu
> 
> If you use the macro DECLARE_KFIFO_PTR(), DECLARE_KFIFO() or
> DEFINE_KFIFO() instead.
> 
> Have a look at the examples files in the samples/kfifo directory.
> 
> - Stefani
> 

  reply	other threads:[~2013-01-10  7:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 14:57 [PATCH 0/5] kfifo cleanup and log based kfifo API Yuanhan Liu
2013-01-08 14:57 ` [PATCH 1/5] kfifo: remove unnecessary type check Yuanhan Liu
2013-01-08 21:51   ` Stefani Seibold
2013-01-09  2:35     ` Yuanhan Liu
2013-01-09 15:29       ` Stefani Seibold
2013-01-10  7:12         ` Yuanhan Liu [this message]
2013-01-08 14:57 ` [PATCH 2/5] libsrp: replace kfifo_init with kfifo_alloc Yuanhan Liu
2013-01-08 14:57 ` [PATCH 3/5] libiscsi: " Yuanhan Liu
2013-01-08 14:57 ` [PATCH 4/5] kfifo: remove kfifo_init Yuanhan Liu
2013-01-08 14:57 ` [PATCH 5/5] kfifo: log based kfifo API Yuanhan Liu
2013-01-08 18:16   ` Dmitry Torokhov
2013-01-08 21:10     ` Andy Walls
2013-01-09  2:42     ` Yuanhan Liu
2013-01-08 15:03 ` Antw: [PATCH 0/5] kfifo cleanup and " Ulrich Windl
2013-01-08 15:29   ` 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=20130110071223.GE304@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).