[PATCH 10/12] satcan.c: Fix Unsigned compared against 0 (CID #1399768)

Gedare Bloom gedare at rtems.org
Fri Mar 5 15:08:11 UTC 2021


On Thu, Mar 4, 2021 at 12:50 PM Ryan Long <thisisryanlong at gmail.com> wrote:
>
> 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);
should these DBG prints also be changed to %u?

> -               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;
> --
> 1.8.3.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list