All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Roland Dreier <rdreier@cisco.com>,
	LKML <linux-kernel@vger.kernel.org>,
	wireless <linux-wireless@vger.kernel.org>
Subject: Re: I need help with a sparse warning
Date: Fri, 12 Sep 2008 13:12:12 -0400	[thread overview]
Message-ID: <1221239532.13346.5.camel@dv> (raw)
In-Reply-To: <48C9DC5C.3040109@lwfinger.net>

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

  reply	other threads:[~2008-09-12 17:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12  2:13 I need help with a sparse warning Larry Finger
2008-09-12  2:32 ` Steven Noonan
2008-09-12  2:58   ` Larry Finger
2008-09-12  3:04     ` Roland Dreier
2008-09-12  3:07       ` Larry Finger
2008-09-12 15:25     ` Michael Buesch
2008-09-12  2:39 ` Roland Dreier
2008-09-12  3:05   ` Larry Finger
2008-09-12 17:12     ` Pavel Roskin [this message]
2008-09-12  2:44 ` Alexey Dobriyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1221239532.13346.5.camel@dv \
    --to=proski@gnu.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rdreier@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.