Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1241074
| From | Al Viro <viro@ZenIV.linux.org.uk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c |
| Date | 2015-10-07 01:20 +0200 |
| Message-ID | <qgJGx-3T4-3@gated-at.bofh.it> (permalink) |
| References | <qgscG-3Qi-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c Jacob Kiefer <jtk54@cornell.edu> - 2015-10-06 06:40 +0200
Re: [PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c Al Viro <viro@ZenIV.linux.org.uk> - 2015-10-07 01:20 +0200
Re: [PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c Jacob Kiefer <jtk54@cornell.edu> - 2015-10-07 04:50 +0200
Re: [PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c Jacob Kiefer <jtk54@cornell.edu> - 2015-10-10 21:00 +0200
Re: [PATCH v2] staging: rtl8723au: Fix sparse errors in rtl8723a_cmd.c Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-10-10 21:20 +0200
csiph-web