From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: James Bottomley <James.Bottomley@suse.de>,
linux-scsi <linux-scsi@vger.kernel.org>,
Fubo Chen <fubo.chen@gmail.com>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 3/3] target: Minor sparse warning fixes and annotations
Date: Mon, 24 Jan 2011 16:37:17 -0800 [thread overview]
Message-ID: <1295915837.24778.123.camel@haakon2.linux-iscsi.org> (raw)
In-Reply-To: <20110125005610.11d5d143@stein>
On Tue, 2011-01-25 at 00:56 +0100, Stefan Richter wrote:
> On Jan 24 Nicholas A. Bellinger wrote:
> > On Mon, 2011-01-24 at 15:51 -0600, James Bottomley wrote:
> > > On Mon, 2011-01-24 at 13:33 -0800, Nicholas A. Bellinger wrote:
> > > > On Mon, 2011-01-24 at 14:56 -0600, James Bottomley wrote:
> > > > > On Mon, 2011-01-24 at 12:37 -0800, Nicholas A. Bellinger wrote:
> > > > > > -#define TASK_CMD(task) ((struct se_cmd *)task->task_se_cmd)
> > > > > > -#define TASK_DEV(task) ((struct se_device *)task->se_dev)
> > > > > > +#define TASK_CMD(task) ((task)->task_se_cmd)
> > > > > > +#define TASK_DEV(task) ((task)->se_dev)
> > > > >
> > > > > If sparse is objecting to things like this then sparse needs fixing:
> > > > > It's decreasing typesafety. the things being cast are void * ... they'd
> > > > > be depositable into any pointer whatsoever without the cast. With the
> > > > > cast in the #define, we pick up pointer mismatches (as we should).
> > > > > Without it, we don't. As long as the define is always a specific type,
> > > > > it *should* cast to it.
> > > > >
> > > >
> > > > Hmmm, good point.. In that case I will go ahead and drop this part of
> > > > the patch.
> > >
> > > Actually, I misspoke on this. They're not void *; they're defined as
> > > struct pointers ... so the cast is actually a spurious double cast. As
> > > long as the rest are, I'm fine with this.
> > >
> >
> > Committed as seperate commit b58b76c -> lio-core-2.6.git/linus-38-rc2,
> > and picked into the mainline queue @ scsi-post-merge-2.6.git/for-jejb.
>
> Why do you provide macros for a simple structure member dereference?
>
> And if you *really* need these helpers, why not
>
> static inline struct se_cmd *cmd_of(struct se_task *task)
> {
> return task->task_se_cmd;
> }
>
> (But then, I see no reason at all not to write it as task->task_se_cmd at
> the user sites.)
Most of these accessor macros originally came from the usage of more
than a single pointer deference. These days only DEV_ATTRIB and
DEV_T10_WWN still deference multiple pointers, so it's really just a
matter of style in modern v4.0 code.
So my perference would be against using inlined cmd_of() callers, and
just access things directly. Btw at this point this type of cleanup
would be considered for-39 material.
--nab
next prev parent reply other threads:[~2011-01-25 0:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-24 20:37 [PATCH 0/3] target: Sparse bugfixes and warnings/annotations Nicholas A. Bellinger
2011-01-24 20:37 ` [PATCH 1/3] target: Drop nacl->device_list_lock on core_update_device_list_for_node failure Nicholas A. Bellinger
2011-01-24 20:37 ` [PATCH 2/3] target: Reaquire hba_lock + se_port_lock during se_clear_dev_ports continue Nicholas A. Bellinger
2011-01-25 0:08 ` Stefan Richter
2011-01-25 1:20 ` Nicholas A. Bellinger
2011-01-25 2:03 ` Nicholas A. Bellinger
2011-01-25 14:39 ` Stefan Richter
2011-01-24 20:37 ` [PATCH 3/3] target: Minor sparse warning fixes and annotations Nicholas A. Bellinger
2011-01-24 20:56 ` James Bottomley
2011-01-24 21:33 ` Nicholas A. Bellinger
2011-01-24 21:51 ` James Bottomley
2011-01-24 22:12 ` Nicholas A. Bellinger
2011-01-24 23:56 ` Stefan Richter
2011-01-25 0:37 ` Nicholas A. Bellinger [this message]
2011-01-24 23:18 ` Joe Eykholt
2011-01-24 23:25 ` Nicholas A. Bellinger
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=1295915837.24778.123.camel@haakon2.linux-iscsi.org \
--to=nab@linux-iscsi.org \
--cc=James.Bottomley@suse.de \
--cc=fubo.chen@gmail.com \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=stefanr@s5r6.in-berlin.de \
/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