[PATCH] utils: Remove always true checks

Maks Mishin maks.mishinfz at gmail.com
Fri Aug 23 12:59:17 UTC 2024


All tests from the repository pass after applying this patch, new tests do
not break.

пт, 23 авг. 2024 г. в 11:17, David Laight <David.Laight at aculab.com>:

> On 64bit long is 64bits - so the test is valid.
>
> > -----Original Message-----
> > From: busybox <busybox-bounces at busybox.net> On Behalf Of Maks Mishin
> > Sent: 22 August 2024 18:04
> > To: busybox at busybox.net
> > Subject: [PATCH] utils: Remove always true checks
> >
> > 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 <maks.mishinFZ at gmail.com>
> > ---
> >  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;
> >               }
> >       }
> > --
> > 2.30.2
> >
> > _______________________________________________
> > busybox mailing list
> > busybox at busybox.net
> > http://lists.busybox.net/mailman/listinfo/busybox
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1
> 1PT, UK
> Registration No: 1397386 (Wales)
>
>

-- 
С уважением,
Мишин Максим Александрович
+7 (915) 958-41-07
maks.mishinFZ at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20240823/117f6289/attachment-0001.html>


More information about the busybox mailing list