From: Al Viro <viro@ZenIV.linux.org.uk>
To: Jacob Kiefer <jtk54@cornell.edu>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
Jes Sorensen <Jes.Sorensen@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com>,
Roberta Dobrescu <roberta.dobrescu@gmail.com>,
"open list:STAGING - REALTEK RTL8723U WIRELESS DRIVER"
<linux-wireless@vger.kernel.org>,
"open list:STAGING SUBSYSTEM" <devel@driverdev.osuosl.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c
Date: Wed, 7 Oct 2015 00:11:34 +0100 [thread overview]
Message-ID: <20151006231134.GV22011@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1444105958-32087-1-git-send-email-jtk54@cornell.edu>
On Tue, Oct 06, 2015 at 12:32:28AM -0400, Jacob Kiefer wrote:
> int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param)
> {
> - *((u32 *)param) = cpu_to_le32(*((u32 *)param));
> + __le32 leparam;
>
> - FillH2CCmd(padapter, RSSI_SETTING_EID, 3, param);
> + leparam = cpu_to_le32(*((u32 *)param));
> +
> + FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)&leparam);
Why not fill the thing we are passing already with little-endian? There's
only one caller, after all...
> int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
> {
> u8 buf[5];
> + __le32 lemask;
>
> memset(buf, 0, 5);
> - mask = cpu_to_le32(mask);
> - memcpy(buf, &mask, 4);
> + lemask = cpu_to_le32(mask);
> + memcpy(buf, &lemask, 4);
> buf[4] = arg;
>
> FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
Ugh...
struct macid_config_eid {__le32 mask; u8 arg;} buf = {
.mask = cpu_to_le32(mask), .arg = arg
};
FillH2CCmd(padapter, MACID_CONFIG_EID, 5, &buf);
Why bother with memcpy/memset/whatnot when all you are trying to do is to
initialize a temporary structure? And no, it's not going to have any gaps...
next prev parent reply other threads:[~2015-10-06 23:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-06 4:32 [PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c Jacob Kiefer
2015-10-06 23:11 ` Al Viro [this message]
2015-10-07 2:40 ` Jacob Kiefer
2015-10-10 18:50 ` Jacob Kiefer
2015-10-10 19:12 ` Greg Kroah-Hartman
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=20151006231134.GV22011@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=Jes.Sorensen@redhat.com \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hgujulan@visteon.com \
--cc=jtk54@cornell.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=roberta.dobrescu@gmail.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.