[PATCH 2/2] gpio/gpio-support: Fix build warnings.

Joel Sherrill joel at rtems.org
Sat Mar 28 16:08:19 UTC 2020


We don't think you should assert or generate a fatal error after
initialization. This could cause an unknown, but safety critical,
application to fail.

This same logic should be converted to a run-time error.

This is probably guidance that is or should be in the coding style in the
software engineering guide. If it isn't, please let us know. It needs a
small tasks ticket.

--joel


On Sat, Mar 28, 2020, 5:50 AM G S Niteesh Babu <niteesh.gs at gmail.com> wrote:

> Fixes "array subscript is outside array bounds" in gpio-support.c
> ---
>  bsps/shared/dev/gpio/gpio-support.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/bsps/shared/dev/gpio/gpio-support.c
> b/bsps/shared/dev/gpio/gpio-support.c
> index 9c053dc151..04f1c8ca90 100644
> --- a/bsps/shared/dev/gpio/gpio-support.c
> +++ b/bsps/shared/dev/gpio/gpio-support.c
> @@ -325,6 +325,7 @@ static rtems_status_code get_pin_bitmask(
>        ACQUIRE_LOCK(gpio_bank_state[bank].lock);
>      }
>      else if ( bank != *bank_number ) {
> +      assert ( *bank_number >= 0 && *bank_number < GPIO_BANK_COUNT );
>        RELEASE_LOCK(gpio_bank_state[*bank_number].lock);
>
>        return RTEMS_UNSATISFIED;
> --
> 2.17.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200328/52b65094/attachment-0001.html>


More information about the devel mailing list