* [PATCH net-next] ipvs: fix type warning in do_div() on 32 bit
@ 2022-12-13 3:20 Jakub Kicinski
2022-12-13 11:09 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2022-12-13 3:20 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, Jakub Kicinski, horms, ja, pablo,
kadlec, fw, jwiesner, lvs-devel, netfilter-devel, coreteam
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.
Fixes: 705dd3444081 ("ipvs: use kthreads for stats estimation")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: horms@verge.net.au
CC: ja@ssi.bg
CC: pablo@netfilter.org
CC: kadlec@netfilter.org
CC: fw@strlen.de
CC: jwiesner@suse.de
CC: lvs-devel@vger.kernel.org
CC: netfilter-devel@vger.kernel.org
CC: coreteam@netfilter.org
---
net/netfilter/ipvs/ip_vs_est.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipvs/ip_vs_est.c b/net/netfilter/ipvs/ip_vs_est.c
index df56073bb282..ce2a1549b304 100644
--- a/net/netfilter/ipvs/ip_vs_est.c
+++ b/net/netfilter/ipvs/ip_vs_est.c
@@ -640,9 +640,10 @@ static int ip_vs_est_calc_limits(struct netns_ipvs *ipvs, int *chain_max)
int i, loops, ntest;
s32 min_est = 0;
ktime_t t1, t2;
- s64 diff, val;
int max = 8;
int ret = 1;
+ s64 diff;
+ u64 val;
INIT_HLIST_HEAD(&chain);
mutex_lock(&__ip_vs_mutex);
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ipvs: fix type warning in do_div() on 32 bit
2022-12-13 3:20 [PATCH net-next] ipvs: fix type warning in do_div() on 32 bit Jakub Kicinski
@ 2022-12-13 11:09 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2022-12-13 11:09 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, horms, ja, kadlec, fw, jwiesner,
lvs-devel, netfilter-devel, coreteam
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@ssi.bg/
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-13 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13 3:20 [PATCH net-next] ipvs: fix type warning in do_div() on 32 bit Jakub Kicinski
2022-12-13 11:09 ` Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.