Maks Mishin <[email protected]> 於 2024年8月23日 星期五寫道:
> Expression 'res <= 4294967295UL' is always true , which may be caused
> by a logical error: 'res' has a type 'unsigned long' with minimum value
'0'
> and a maximum value '4294967295'
>
> Found by the static analyzer Svace.
>
> Signed-off-by: Maks Mishin <[email protected]>
> ---
>  networking/libiproute/utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
> index 3cce4a06e..9e8600f34 100644
> --- a/networking/libiproute/utils.c
> +++ b/networking/libiproute/utils.c
> @@ -42,7 +42,7 @@ unsigned FAST_FUNC get_unsigned(char *arg, const char
*errmsg)
>         if (*arg) {
>                 res = strtoul(arg, &ptr, 0);
>  //FIXME: "" will be accepted too, is it correct?!
> -               if (!*ptr && res <= UINT_MAX) {
> +               if (!*ptr) {
>                         return res;
>                 }
>         }
> @@ -57,7 +57,7 @@ uint32_t FAST_FUNC get_u32(char *arg, const char
*errmsg)
>         if (*arg) {
>                 res = strtoul(arg, &ptr, 0);
>  //FIXME: "" will be accepted too, is it correct?!
> -               if (!*ptr && res <= 0xFFFFFFFFUL) {
> +               if (!*ptr) {
>                         return res;
>                 }
>         }
> --

No, I don't think removal is the right way. `long` is 64-bit in 64-bit OS
(the "LP64" data model). You get the always true condition only on 32-bit
systems, or on Windows, which uses LLP64.
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to