Re: [PATCH] staging: rtl8192u: fix incorrect assignments

From: Jakub Jedelsky
Date: Tue Apr 18 2017 - 16:12:28 EST


On Tue, Apr 18, 2017 at 01:52:01PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Apr 11, 2017 at 10:19:08AM +0200, Jakub Jedelsky wrote:
> > Fixing warnings found by sparse on rtl8192u/ieee80211.
> >
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1318:45: warning: incorrect type in assignment (different base types)
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1318:45: expected unsigned short [unsigned] [usertype] len
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1318:45: got restricted __be16 [usertype] <noident>
> >
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1481:40: warning: incorrect type in assignment (different base types)
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1481:40: expected restricted __le16 <noident>
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1481:40: got int
> >
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1483:40: warning: incorrect type in assignment (different base types)
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1483:40: expected restricted __le16 <noident>
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1483:40: got int
> >
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1487:45: warning: incorrect type in assignment (different base types)
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1487:45: expected restricted __le16 <noident>
> > drivers/staging/rtl8192u/ieee80211//ieee80211_rx.c:1487:45: gotunsigned short [unsigned] [usertype] <noident>
> >
> > Signed-off-by: Jakub Jedelsky <jakub.jedelsky@xxxxxxxxx>
> > ---
> > drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
> > index 2310ec7..7a31510 100644
> > --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
> > +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
> > @@ -1315,7 +1315,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
> > } else {
> > u16 len;
> > /* Leave Ethernet header part of hdr and full payload */
> > - len = htons(sub_skb->len);
> > + len = be16_to_cpu(htons(sub_skb->len));
> > memcpy(skb_push(sub_skb, 2), &len, 2);
> > memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
> > memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
> > @@ -1478,13 +1478,15 @@ static int ieee80211_qos_convert_ac_to_parameters(struct
> > /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
> > qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci];
> >
> > - qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F;
> > + qos_param->cw_min[aci] =
> > + cpu_to_le16(ac_params->ecw_min_max & 0x0F);
> >
> > - qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4;
> > + qos_param->cw_max[aci] =
> > + cpu_to_le16((ac_params->ecw_min_max & 0xF0) >> 4);
> >
> > qos_param->flag[aci] =
> > (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
> > - qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit);
> > + qos_param->tx_op_limit[aci] = ac_params->tx_op_limit;
>
> Are you sure about these changes? How did you test them?
>
> thanks,
>
> greg k-h

well, I didn't test it on a HW because I haven't that chip, but it's
possible to compile it without errors. I just wanted to repair a
sparse warning (to better understand the kernel devel), so I did
(and without introducing a new one).

The first change (be16_to_cpu) is reaction to commit 1c19f3794d8e
(linux-next). The rest is based on struct defines for
ieee80211_qos_parameters and ieee80211_qos_ac_parameter.

Hope it's ok.

thanks,

- jj