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.
>
>
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
> - 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
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