On 08.10.21 09:51, Michael Adler wrote:
> The previous comparison with LONG_{MIN,MAX} was (almost) always false
> because the variable for the comparison had already been casted from
> long to int.
> 
> Signed-off-by: Michael Adler <[email protected]>
> ---
>  tools/bg_setenv.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/bg_setenv.c b/tools/bg_setenv.c
> index d26eeed..043c0aa 100644
> --- a/tools/bg_setenv.c
> +++ b/tools/bg_setenv.c
> @@ -221,16 +221,17 @@ static error_t set_uservars(char *arg)
>  static int parse_int(char *arg)
>  {
>       char *tmp;
> -     int i;
> +     long i;
>  
>       errno = 0;
>       i = strtol(arg, &tmp, 10);
>       if ((errno == ERANGE && (i == LONG_MAX || i == LONG_MIN)) ||
> +             (i > INT_MAX || i < INT_MIN) ||

Can't we drop the LONG_* tests then?

Jan

>           (errno != 0 && i == 0) || (tmp == arg)) {
>               errno = EINVAL;
>               return -1;
>       }
> -     return i;
> +     return (int) i;
>  }
>  
>  static error_t parse_opt(int key, char *arg, struct argp_state *state)
> 

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/0007564a-ddf1-085b-cf0a-ea0dfaf4732c%40siemens.com.

Reply via email to