lkml.org 
[lkml]   [2005]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 3/27] Add MAD helper functions
Date
On Wednesday 13 July 2005 02:17, Michael S. Tsirkin wrote:
> Quoting r. Tom Duffy <tduffy@sun.com>:
> > These seem to be mostly coming from cpu_to_be*() and be*_to_cpu(). Is
> > there a good rule of thumb for fixing these warnings?
>
> Yes.
> Use attributes like __be32 and friends appropriately.

ITYM types. ;-)

Tom, see, for example, drivers/infiniband/core/sysfs.c:
----------------------------------------------------------------------------
313 in_mad->mad_hdr.attr_id = cpu_to_be16(0x12); /* PortCounters */
----------------------------------------------------------------------------
drivers/infiniband/core/sysfs.c:313:32: warning: incorrect type in assignment (different base types)
drivers/infiniband/core/sysfs.c:313:32: expected unsigned short [unsigned] [usertype] attr_id
drivers/infiniband/core/sysfs.c:313:32: got restricted unsigned short [usertype] [force] <noident>
----------------------------------------------------------------------------
Grepping for attr_id in drivers/infiniband/ shows that:
1) in_mad->attr_id is set to IB_SMP_ATTR_NODE_INFO (network order)
2) mad->mad_hdr.attr_id is compared with IB_SMP_ATTR_PORT_INFO (network order)
3) *->mad_hdr.attr_id is set to big-endian value

All this suggests that struct ib_mad_hdr::attr_id should be __be16 instead of
u16. So, if attr_id is really something big-endian (infiniband people should
know), convert it. If not (unlikely) all those cpu_to_be16() and htons() are
bogus.

HO-WE-VER, be careful and don't blindly shut up sparse. Its warnings exist to
uncover real bugs.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-07-13 00:50    [W:0.063 / U:0.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site