staging: rtl8188eu: use prefix decrement operator on trycnt variable
authorPhillip Potter <phil@philpotter.co.uk>
Tue, 15 Jun 2021 22:36:02 +0000 (23:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jun 2021 07:25:29 +0000 (09:25 +0200)
Modify trycnt condition in the do/while loop of rtw_hal_set_hwreg to use
a prefix decrement operator instead of postfix. As an unsigned 8-bit
integer, this value would actually be 255 after the end of the do/while
loop, which is almost certainly not what was intended. It is more
reasonable to assume a loop counter should be zero at the end of all
loop iterations. Indeed, the line following the loop previously contained
an if statement which assumed trycnt was 0, and therefore was never
triggered.

Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
Link: https://lore.kernel.org/r/20210615223607.13863-3-phil@philpotter.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/hal/usb_halinit.c

index 0c3f114..dcdf868 100644 (file)
@@ -1657,7 +1657,7 @@ void rtw_hal_set_hwreg(struct adapter *Adapter, u8 variable, u8 *val)
                                do {
                                        if (!(usb_read32(Adapter, REG_RXPKT_NUM) & RXDMA_IDLE))
                                                break;
-                               } while (trycnt--);
+                               } while (--trycnt);
 
                                /* RQPN Load 0 */
                                usb_write16(Adapter, REG_RQPN_NPQ, 0x0);