[rtems commit] satcan.c: Fix Unsigned compared against 0 (CID #1399768)

Joel Sherrill joel at rtems.org
Fri Mar 5 20:19:38 UTC 2021


Module:    rtems
Branch:    master
Commit:    1f29ee4528290cd516be551c0ff7e945d6567390
Changeset: http://git.rtems.org/rtems/commit/?id=1f29ee4528290cd516be551c0ff7e945d6567390

Author:    Ryan Long <ryan.long at oarcorp.com>
Date:      Wed Mar  3 15:52:30 2021 -0500

satcan.c: Fix Unsigned compared against 0 (CID #1399768)

CID 1399768: Unsigned compared against 0 in satcan_ioctl().

Closes #4294

---

 bsps/shared/grlib/can/satcan.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/bsps/shared/grlib/can/satcan.c b/bsps/shared/grlib/can/satcan.c
index c3fdc15..52e674c 100644
--- a/bsps/shared/grlib/can/satcan.c
+++ b/bsps/shared/grlib/can/satcan.c
@@ -239,9 +239,7 @@ static rtems_device_driver satcan_ioctl(rtems_device_major_number major, rtems_d
 		/* Get regmod structure from argument */
 		regmod = (satcan_regmod*)ioarg->buffer;
 		DBG("SatCAN: ioctl: getting register %d\n\r", regmod->reg);
-		if (regmod->reg < 0)
-			return RTEMS_INVALID_NAME;
-		else if (regmod->reg <= SATCAN_FILTER_STOP)
+		if (regmod->reg <= SATCAN_FILTER_STOP)
 			regmod->val = regs->satcan[regmod->reg];
 		else if (regmod->reg == SATCAN_WCTRL)
 			regmod->val = regs->ctrl;
@@ -260,9 +258,7 @@ static rtems_device_driver satcan_ioctl(rtems_device_major_number major, rtems_d
 		regmod = (satcan_regmod*)ioarg->buffer;
 		DBG("SatCAN: ioctl: setting register %d, value %x\n\r", 
 		    regmod->reg, regmod->val);
-		if (regmod->reg < 0)
-			return RTEMS_INVALID_NAME;
-		else if (regmod->reg <= SATCAN_FILTER_STOP)
+		if (regmod->reg <= SATCAN_FILTER_STOP)
 			regs->satcan[regmod->reg] = regmod->val;
 		else if (regmod->reg == SATCAN_WCTRL)
 			regs->ctrl = regmod->val;
@@ -281,9 +277,7 @@ static rtems_device_driver satcan_ioctl(rtems_device_major_number major, rtems_d
 		regmod = (satcan_regmod*)ioarg->buffer;
 		DBG("SatCAN: ioctl: or:ing register %d, with value %x\n\r",
 		    regmod->reg, regmod->val);
-		if (regmod->reg < 0)
-			return RTEMS_INVALID_NAME;
-		else if (regmod->reg <= SATCAN_FILTER_STOP)
+		if (regmod->reg <= SATCAN_FILTER_STOP)
 			regs->satcan[regmod->reg] |= regmod->val;
 		else if (regmod->reg == SATCAN_WCTRL)
 			regs->ctrl |= regmod->val;
@@ -302,9 +296,7 @@ static rtems_device_driver satcan_ioctl(rtems_device_major_number major, rtems_d
 		regmod = (satcan_regmod*)ioarg->buffer;
 		DBG("SatCAN: ioctl: masking register %d, with value %x\n\r",
 		    regmod->reg, regmod->val);
-		if (regmod->reg < 0)
-			return RTEMS_INVALID_NAME;
-		else if (regmod->reg <= SATCAN_FILTER_STOP)
+		if (regmod->reg <= SATCAN_FILTER_STOP)
 			regs->satcan[regmod->reg] &= regmod->val;
 		else if (regmod->reg == SATCAN_WCTRL)
 			regs->ctrl &= regmod->val;



More information about the vc mailing list