RE: [PATCH v4 16/18] staging: r8188eu: hal: Clean up rtw_read*() and rtw_write*()

From: David Laight
Date: Tue Sep 14 2021 - 10:33:31 EST


From: Fabio M. De Francesco
> Sent: 13 September 2021 19:10
...
> + u16 address = (u16)(addr & 0xffff);
>
> - usbctrl_vendorreq(pintfhdl, wvalue, &data, 1, REALTEK_USB_VENQT_READ);
> + usbctrl_vendorreq(intfhdl, address, &data, 1, REALTEK_USB_VENQT_READ);

You really don't need the (u16) cast or the '& 0xffff'.
The assignment will just truncate.

But do you even need to truncate the value at all?
It rather depends on what happens inside usbctrl_vendorreq()
and whether the parameter to this code is already constrained.

I think modern gcc are better, but I have seen code where
the '& 0xffff' masked the value, then the (u16) masked the
value and finally the low 16 bits were written into a structure.

(Oh the other patches are now readable - a lot of junk down the pan.)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)