Re: [PATCH ethtool 3/7] ioctl: get rid of signed/unsigned comparison warnings

2020-08-11 Thread Michal Kubecek
On Mon, Aug 10, 2020 at 04:19:24PM +0200, Andrew Lunn wrote: > > - 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. > >

RE: [PATCH ethtool 3/7] ioctl: get rid of signed/unsigned comparison warnings

2020-08-10 Thread David Laight
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

Re: [PATCH ethtool 3/7] ioctl: get rid of signed/unsigned comparison warnings

2020-08-10 Thread 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. Andrew

[PATCH ethtool 3/7] ioctl: get rid of signed/unsigned comparison warnings

2020-08-09 Thread Michal Kubecek
Comparison between signed and unsigned values is fragile and causes compiler warnings with recent compilers and stricter CFLAGS. Prevent such comparisons either by properly declaring variables (mostly loop iterators) as unsigned or by explicitly casting one side of the comparison. Signed-off-by: M