Return-path: Received: from c60.cesmail.net ([216.154.195.49]:34923 "EHLO c60.cesmail.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752714AbYILRMQ (ORCPT ); Fri, 12 Sep 2008 13:12:16 -0400 Subject: Re: I need help with a sparse warning From: Pavel Roskin To: Larry Finger Cc: Roland Dreier , LKML , wireless In-Reply-To: <48C9DC5C.3040109@lwfinger.net> References: <48C9D040.8010107@lwfinger.net> <48C9DC5C.3040109@lwfinger.net> Content-Type: text/plain Date: Fri, 12 Sep 2008 13:12:12 -0400 Message-Id: <1221239532.13346.5.camel@dv> (sfid-20080912_191223_029556_1271E895) Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org List-ID: On Thu, 2008-09-11 at 22:05 -0500, Larry Finger wrote: > > I would guess you want something like: > > > > priv->rx_mtu = le16_to_cpu(((__force __le16 *) bootrec->data)[20]); > > > > (__force is what shuts up sparse, and as far as I can see, the size_t > > cast is useless, since the result will be promoted anyway) > > Yes, that one works. As you suspected, this section is parsing data > from the firmware. I believe __force should be the last resort. If you want to read a 16-bit little endian value at the given offset, I suggest that you use le16_to_cpup(), which operates on pointers and does the cast for you. A better but more elaborate solution would be to define a structure that would have __le16 rx_mtu at the offset 40. Then you can cast bootrec to that structure and apply le16_to_cpu() to that field. -- Regards, Pavel Roskin