From: Joe Perches <joe@perches.com>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: David Laight <David.Laight@ACULAB.COM>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Chaoming Li <chaoming_li@realsil.com.cn>,
"David S. Miller" <davem@davemloft.net>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] rtlwifi: use %*ph[C] to dump small buffers
Date: Fri, 28 Sep 2012 10:24:21 -0700 [thread overview]
Message-ID: <1348853061.14262.44.camel@joe-AO722> (raw)
In-Reply-To: <5065D32F.9090107@lwfinger.net>
On Fri, 2012-09-28 at 11:41 -0500, Larry Finger wrote:
> On 09/28/2012 04:04 AM, David Laight wrote:
> >>> Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
[]
> >>> - *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) |
> >>> - (ratr_index << 28);
> >>> + for (i = 0; i < 3; i++)
> >>> + rate_mask[i] = ratr_bitmap & (0xff << (i * 4));
[]
> > So this either fixes, or adds, an endianness bug.
>
> Yes, the rate_mask array is little endian after this fragment is run, but the
> only use of the byte array is to write it to the device, and LE is what it needs
> no matter the platform. This change fixes an endianness bug.
>
> As I tend to get confused when doing these things, I wrote a small test program
> and ran it on x86_64 and PPC-32 to confirm the result.
>
> Thanks for teaching me about a = b >>= 8. I was not aware that C could do that.
The other thing that could be done is to use cpu_to_le32()
but David's method I think is superior for this use as there's
no absolute guarantee that rate_mask is aligned on a u32.
I'd add parens to make the precedence explicit.
rate_mask[0] = ratr_bitmap;
rate_mask[1] = (ratr_bitmap >>= 8);
rate_mask[2] = (ratr_bitmap >>= 8);
rate_mask[3] = ((ratr_bitmap >> 8) & 0xf) | (ratr_index << 4);
next prev parent reply other threads:[~2012-09-28 17:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-26 13:57 [PATCH] rtlwifi: use %*ph[C] to dump small buffers Andy Shevchenko
[not found] ` <1348667852-5957-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2012-09-26 16:45 ` Joe Perches
2012-09-27 15:16 ` Larry Finger
2012-09-27 22:28 ` Larry Finger
[not found] ` <5064D318.6090705-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
2012-09-28 3:13 ` Joe Perches
2012-09-28 9:04 ` David Laight
[not found] ` <AE90C24D6B3A694183C094C60CF0A2F6026B700D-CgBM+Bx2aUAnGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2012-09-28 16:41 ` Larry Finger
2012-09-28 17:24 ` Joe Perches [this message]
2012-09-27 15:10 ` Larry Finger
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=1348853061.14262.44.camel@joe-AO722 \
--to=joe@perches.com \
--cc=David.Laight@ACULAB.COM \
--cc=Larry.Finger@lwfinger.net \
--cc=andriy.shevchenko@linux.intel.com \
--cc=chaoming_li@realsil.com.cn \
--cc=davem@davemloft.net \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).