LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [PATCH net-next] ipvs: fix type warning in do_div() on 32 bit

To: Jakub Kicinski <kuba@xxxxxxxxxx>
Subject: Re: [PATCH net-next] ipvs: fix type warning in do_div() on 32 bit
Cc: davem@xxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, edumazet@xxxxxxxxxx, pabeni@xxxxxxxxxx, horms@xxxxxxxxxxxx, ja@xxxxxx, kadlec@xxxxxxxxxxxxx, fw@xxxxxxxxx, jwiesner@xxxxxxx, lvs-devel@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx, coreteam@xxxxxxxxxxxxx
From: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
Date: Tue, 13 Dec 2022 12:09:28 +0100
Hi Jakub,

On Mon, Dec 12, 2022 at 07:20:37PM -0800, Jakub Kicinski wrote:
> 32 bit platforms without 64bit div generate the following warning:
> 
> net/netfilter/ipvs/ip_vs_est.c: In function 'ip_vs_est_calc_limits':
> include/asm-generic/div64.h:222:35: warning: comparison of distinct pointer 
> types lacks a cast
>   222 |         (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
>       |                                   ^~
> net/netfilter/ipvs/ip_vs_est.c:694:17: note: in expansion of macro 'do_div'
>   694 |                 do_div(val, loops);
>       |                 ^~~~~~
> include/asm-generic/div64.h:222:35: warning: comparison of distinct pointer 
> types lacks a cast
>   222 |         (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
>       |                                   ^~
> net/netfilter/ipvs/ip_vs_est.c:700:33: note: in expansion of macro 'do_div'
>   700 |                                 do_div(val, min_est);
>       |                                 ^~~~~~
> 
> first argument of do_div() should be unsigned. We can't just cast
> as do_div() updates it as well, so we need an lval.
> Make val unsigned in the first place, all paths check that the value
> they assign to this variables are non-negative already.

Your patch is very similar to what Julian posted:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/20221212195845.101844-1-ja@xxxxxx/

Thanks.

<Prev in Thread] Current Thread [Next in Thread>