Staging: Cleanup redundant tests on unsigned
PATCH 1/1 Staging: Cleanup redundant tests on unsigned
The variables are unsigned so the test >= 0' is always true, the < 0' test always fails. In these cases the other part of the test catches wrapped values.
Signed-off-by Roel Kluin <[email protected]>
--- drivers/staging/comedi/comedi_fops.c | 4 +- drivers/staging/go7007/go7007-v4l2.c | 2 +- drivers/staging/rt2860/common/cmm_info.c | 37 ++++++++++------------------- drivers/staging/rt3090/common/cmm_info.c | 8 +++--- drivers/staging/usbip/vhci_sysfs.c | 2 +- 5 files changed, 21 insertions(+), 32 deletions(-)
drivers/staging/comedi/comedi_fops.c +2 -2
@@ -300,7 +300,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg)if (copy_from_user (&bc, arg,sizeof (struct comedi_bufconfig )))return -EFAULT ; -if (bc.subdevice >= dev->n_subdevices || bc.subdevice <0 ) +if (bc.subdevice >= dev->n_subdevices)return -EINVAL ; s = dev->subdevices + bc.subdevice;
@@ -556,7 +556,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, void *arg)if (copy_from_user (&bi, arg,sizeof (struct comedi_bufinfo )))return -EFAULT ; -if (bi.subdevice >= dev->n_subdevices || bi.subdevice <0 ) +if (bi.subdevice >= dev->n_subdevices)return -EINVAL ; s = dev->subdevices + bi.subdevice;
drivers/staging/go7007/go7007-v4l2.c +1 -1
@@ -809,7 +809,7 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)return retval;mutex_lock (&gofh->lock); -if (buf->index <0 || buf->index >= gofh->buf_count) +if (buf->index >= gofh->buf_count) goto unlock_and_return; gobuf = &gofh->bufs[buf->index];
drivers/staging/rt2860/common/cmm_info.c +13 -24
@@ -249,22 +249,16 @@ INT Set_CountryRegion_Proc( region =simple_strtol (arg,0 ,10 );// Country can be set only when EEPROM not programmed -if (pAd->CommonCfg.CountryRegion &0x80 ) - { +if (pAd->CommonCfg.CountryRegion &0x80 ) {DBGPRINT (RT_DEBUG_ERROR , ("Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n" ));return FALSE; } -if ((region >=0 ) && (region <=REGION_MAXIMUM_BG_BAND )) - { +if (region <=REGION_MAXIMUM_BG_BAND ) { pAd->CommonCfg.CountryRegion = (UCHAR ) region; - } -else if (region ==REGION_31_BG_BAND ) - { + }else if (region ==REGION_31_BG_BAND ) { pAd->CommonCfg.CountryRegion = (UCHAR ) region; - } -else - { + }else {DBGPRINT (RT_DEBUG_ERROR , ("Set_CountryRegion_Proc::parameters out of range\n" ));return FALSE; }
@@ -295,18 +289,14 @@ INT Set_CountryRegionABand_Proc( region =simple_strtol (arg,0 ,10 );// Country can be set only when EEPROM not programmed -if (pAd->CommonCfg.CountryRegionForABand &0x80 ) - { +if (pAd->CommonCfg.CountryRegionForABand &0x80 ) {DBGPRINT (RT_DEBUG_ERROR , ("Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n" ));return FALSE; } -if ((region >=0 ) && (region <=REGION_MAXIMUM_A_BAND )) - { +if (region <=REGION_MAXIMUM_A_BAND ) { pAd->CommonCfg.CountryRegionForABand = (UCHAR ) region; - } -else - { + }else {DBGPRINT (RT_DEBUG_ERROR , ("Set_CountryRegionABand_Proc::parameters out of range\n" ));return FALSE; }
@@ -2194,13 +2184,13 @@ INT Set_HtMcs_Proc( (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX)) {if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS !=MCS_AUTO ) && - (HtMcs >=0 && HtMcs <=3 ) && + (HtMcs <=3 ) && (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode ==FIXED_TXMODE_CCK )) {RTMPSetDesiredRates (pAd, (LONG ) (RateIdToMbps[HtMcs] *1000000 )); }else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS !=MCS_AUTO ) && - (HtMcs >=0 && HtMcs <=7 ) && + (HtMcs <=7 ) && (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode ==FIXED_TXMODE_OFDM )) {RTMPSetDesiredRates (pAd, (LONG ) (RateIdToMbps[HtMcs+4 ] *1000000 ));
@@ -2255,10 +2245,9 @@ INT Set_HtTxBASize_Proc( Size =simple_strtol (arg,0 ,10 ); -if (Size <=0 || Size >=64 ) - { +if (Size ==0 || Size >=64 ) Size =8 ; - } + pAd->CommonCfg.TxBASize = Size-1 ;DBGPRINT (RT_DEBUG_ERROR , ("Set_HtTxBASize ::(TxBASize= %d)\n" , Size));
@@ -2364,7 +2353,7 @@ INT Set_HtMpduDensity_Proc( Value =simple_strtol (arg,0 ,10 ); -if (Value <=7 && Value >=0 ) +if (Value <=7 ) pAd->CommonCfg.BACapability.field.MpduDensity = Value;else pAd->CommonCfg.BACapability.field.MpduDensity =4 ;
@@ -2582,7 +2571,7 @@ INT Set_HtMIMOPSmode_Proc( Value =simple_strtol (arg,0 ,10 ); -if (Value <=3 && Value >=0 ) +if (Value <=3 ) pAd->CommonCfg.BACapability.field.MMPSmode = Value;else pAd->CommonCfg.BACapability.field.MMPSmode =3 ;
drivers/staging/rt3090/common/cmm_info.c +4 -4
@@ -2548,13 +2548,13 @@ INT Set_HtMcs_Proc( (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE < MODE_HTMIX)) {if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS !=MCS_AUTO ) && - (HtMcs >=0 && HtMcs <=3 ) && + (HtMcs <=3 ) && (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode ==FIXED_TXMODE_CCK )) {RTMPSetDesiredRates (pAd, (LONG ) (RateIdToMbps[HtMcs] *1000000 )); }else if ((pAd->StaCfg.DesiredTransmitSetting.field.MCS !=MCS_AUTO ) && - (HtMcs >=0 && HtMcs <=7 ) && + (HtMcs <=7 ) && (pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode ==FIXED_TXMODE_OFDM )) {RTMPSetDesiredRates (pAd, (LONG ) (RateIdToMbps[HtMcs+4 ] *1000000 ));
@@ -2741,7 +2741,7 @@ INT Set_HtMpduDensity_Proc( Value =simple_strtol (arg,0 ,10 ); -if (Value <=7 && Value >=0 ) +if (Value <=7 ) pAd->CommonCfg.BACapability.field.MpduDensity = Value;else pAd->CommonCfg.BACapability.field.MpduDensity =4 ;
@@ -2959,7 +2959,7 @@ INT Set_HtMIMOPSmode_Proc( Value =simple_strtol (arg,0 ,10 ); -if (Value <=3 && Value >=0 ) +if (Value <=3 ) pAd->CommonCfg.BACapability.field.MMPSmode = Value;else pAd->CommonCfg.BACapability.field.MMPSmode =3 ;
drivers/staging/usbip/vhci_sysfs.c +1 -1
@@ -134,7 +134,7 @@ static DEVICE_ATTR(detach, S_IWUSR, NULL, store_detach);static int valid_args (__u32 rhport,enum usb_device_speed speed) {/* check rhport */ -if ((rhport <0 ) || (rhport >=VHCI_NPORTS )) { +if (rhport >=VHCI_NPORTS ) {usbip_uerr ("port %u\n" , rhport);return -EINVAL ; }