[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1221239532.13346.5.camel@dv>
Date: Fri, 12 Sep 2008 13:12:12 -0400
From: Pavel Roskin <proski@....org>
To: Larry Finger <Larry.Finger@...inger.net>
Cc: Roland Dreier <rdreier@...co.com>,
LKML <linux-kernel@...r.kernel.org>,
wireless <linux-wireless@...r.kernel.org>
Subject: Re: I need help with a sparse warning
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists