Re: [PATCH 3/3] target: Minor sparse warning fixes and annotations

James Bottomley
2011-01-24T21:51:41Z

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.

James