xt_pknock: fix do_div() signness mismatch
PATCH 1/1 xt_pknock: fix do_div() signness mismatch
do_div() expects an unsigned 64-bit dividend, but time64_t is signed. On 32-bit arch, this triggers a warnning:
In file included from ./arch/arm/include/asm/div64.h:107,
from ./include/linux/math.h:6,
from ./include/linux/math64.h:6,
from ./include/linux/time.h:6,
from ./include/linux/stat.h:19,
from ./include/linux/module.h:13,
from ./xtables-addons-3.30/extensions/pknock/xt_pknock.c:10:./xtables-addons-3.30/extensions/pknock/xt_pknock.c: In function 'has_secret':./include/asm-generic/div64.h:222:35: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types]
222 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
| ^~./xtables-addons-3.30/extensions/pknock/xt_pknock.c:747:17: note: in expansion of macro 'do_div'
747 | do_div(t, 60);
|Change the type of variable t to uint64_t to fix this.
--- extensions/pknock/xt_pknock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
extensions/pknock/xt_pknock.c +1 -1
@@ -743,7 +743,7 @@ has_secret(const unsigned char *secret, unsigned int secret_len, uint32_t ipsrc,/* Time needs to be in minutes relative to epoch. */ { -time64_t t =ktime_get_real_seconds (); +uint64_t t =ktime_get_real_seconds ();do_div (t,60 ); epoch_min = t; }
Signature · 1 line
2.43.0
Jan Engelhardt
AppliedQuoted 5 lines · Qingfang Deng
do_div()expects an unsigned 64-bit dividend, buttime64_tis signed. On 32-bit arch, this triggers a warnning:extensions/pknock/xt_pknock.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)[...]
Applied to the git repository.