[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b94959fddb0a4077b9e562704e6344e3@AcuMS.aculab.com>
Date: Mon, 10 Aug 2020 14:24:20 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Andrew Lunn' <andrew@...n.ch>, Michal Kubecek <mkubecek@...e.cz>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH ethtool 3/7] ioctl: get rid of signed/unsigned comparison
warnings
From: Andrew Lunn
> > - while (arg_num < ctx->argc) {
> > + while (arg_num < (unsigned int)ctx->argc) {
>
> Did you try changing ctx->argc to an unsigned int? I guess there would
> be less casts that way, and it is a more logical type for this.
My favourite solution is to use '+ 0u' to force the signed
integer to unsigned.
Less likely to hide another bug than the cast.
But changing the type is better.
I just wish they'd fix gcc so that it didn't complain
if you'd just done a test that excluded negative values.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists