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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/24/11 1:33 PM, 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)
Part of the problem with the old code is that task was not parenthesized,
so if TASK_CMD() were used with an expression, you might not get what
you want.  If you did TASK_CMD(p + 5), for example, you would get

    ((struct se_cmd *)p + 5->task_se_cmd)

Which wouldn't compile, but maybe other examples would compile and
would cause strange problems.   So, it's a bad macro as it is.
Just my 2 cents.

     Cheers,
     Joe

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.

Thanks!

--nab


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux