* [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats
@ 2017-05-24 7:13 Alin Nastac
2017-05-29 12:02 ` Pablo Neira Ayuso
0 siblings, 1 reply; 6+ messages in thread
From: Alin Nastac @ 2017-05-24 7:13 UTC (permalink / raw)
To: netfilter-devel
From: Alin Nastac <alin.nastac@gmail.com>
The remaining %llu formats are used for unsigned long long values.
Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
---
extensions/libxt_hashlimit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/extensions/libxt_hashlimit.c b/extensions/libxt_hashlimit.c
index 9e63e1e..d7de540 100644
--- a/extensions/libxt_hashlimit.c
+++ b/extensions/libxt_hashlimit.c
@@ -736,7 +736,7 @@ hashlimit_mt_print(const struct hashlimit_cfg2 *cfg, unsigned int dmask, int rev
quantum = print_bytes(cfg->avg, cfg->burst, "");
} else {
quantum = print_rate(cfg->avg, revision);
- printf(" burst %llu", cfg->burst);
+ printf(" burst %"PRIu64, cfg->burst);
}
if (cfg->mode & (XT_HASHLIMIT_HASH_SIP | XT_HASHLIMIT_HASH_SPT |
XT_HASHLIMIT_HASH_DIP | XT_HASHLIMIT_HASH_DPT)) {
@@ -846,7 +846,7 @@ hashlimit_mt_save(const struct hashlimit_cfg2 *cfg, const char* name, unsigned i
quantum = print_bytes(cfg->avg, cfg->burst, "--hashlimit-");
} else {
quantum = print_rate(cfg->avg, revision);
- printf(" --hashlimit-burst %llu", cfg->burst);
+ printf(" --hashlimit-burst %"PRIu64, cfg->burst);
}
if (cfg->mode & (XT_HASHLIMIT_HASH_SIP | XT_HASHLIMIT_HASH_SPT |
@@ -942,7 +942,7 @@ static void print_packets_rate_xlate(struct xt_xlate *xl, uint64_t avg,
_rates[i].mult / avg < _rates[i].mult % avg)
break;
- xt_xlate_add(xl, " %llu/%s burst %lu packets",
+ xt_xlate_add(xl, " %"PRIu64"/%s burst %"PRIu64" packets",
_rates[i-1].mult / avg, _rates[i-1].name, burst);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats
2017-05-24 7:13 [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats Alin Nastac
@ 2017-05-29 12:02 ` Pablo Neira Ayuso
2017-05-29 12:11 ` Alin Năstac
2017-05-29 12:18 ` Alin Năstac
0 siblings, 2 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2017-05-29 12:02 UTC (permalink / raw)
To: Alin Nastac; +Cc: netfilter-devel
On Wed, May 24, 2017 at 09:13:58AM +0200, Alin Nastac wrote:
> From: Alin Nastac <alin.nastac@gmail.com>
>
> The remaining %llu formats are used for unsigned long long values.
Hm, still problems here:
libxt_hashlimit.c: In function ‘hashlimit_mt_print’:
libxt_hashlimit.c:739:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=] printf(" burst %"PRIu64, cfg->burst);
printf(" burst %"PRIu64, cfg->burst);
^
libxt_hashlimit.c: In function ‘hashlimit_mt_save’:
libxt_hashlimit.c:849:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=]
printf(" --hashlimit-burst %"PRIu64, cfg->burst);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats
2017-05-29 12:02 ` Pablo Neira Ayuso
@ 2017-05-29 12:11 ` Alin Năstac
2017-05-29 12:17 ` Pablo Neira Ayuso
2017-05-29 12:18 ` Alin Năstac
1 sibling, 1 reply; 6+ messages in thread
From: Alin Năstac @ 2017-05-29 12:11 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On Mon, May 29, 2017 at 2:02 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Wed, May 24, 2017 at 09:13:58AM +0200, Alin Nastac wrote:
>> From: Alin Nastac <alin.nastac@gmail.com>
>>
>> The remaining %llu formats are used for unsigned long long values.
>
> Hm, still problems here:
>
> libxt_hashlimit.c: In function ‘hashlimit_mt_print’:
> libxt_hashlimit.c:739:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=] printf(" burst %"PRIu64, cfg->burst);
> printf(" burst %"PRIu64, cfg->burst);
> ^
> libxt_hashlimit.c: In function ‘hashlimit_mt_save’:
> libxt_hashlimit.c:849:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=]
> printf(" --hashlimit-burst %"PRIu64, cfg->burst);
That's odd, burst field of hashlimit_cfg2 struct is supposed to be an
__u64 integer (see include/linux/netfilter/xt_hashlimit.h line 68).
Probably you include the wrong header file.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats
2017-05-29 12:11 ` Alin Năstac
@ 2017-05-29 12:17 ` Pablo Neira Ayuso
0 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2017-05-29 12:17 UTC (permalink / raw)
To: Alin Năstac; +Cc: netfilter-devel
On Mon, May 29, 2017 at 02:11:39PM +0200, Alin Năstac wrote:
> On Mon, May 29, 2017 at 2:02 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Wed, May 24, 2017 at 09:13:58AM +0200, Alin Nastac wrote:
> >> From: Alin Nastac <alin.nastac@gmail.com>
> >>
> >> The remaining %llu formats are used for unsigned long long values.
> >
> > Hm, still problems here:
> >
> > libxt_hashlimit.c: In function ‘hashlimit_mt_print’:
> > libxt_hashlimit.c:739:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=] printf(" burst %"PRIu64, cfg->burst);
> > printf(" burst %"PRIu64, cfg->burst);
> > ^
> > libxt_hashlimit.c: In function ‘hashlimit_mt_save’:
> > libxt_hashlimit.c:849:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=]
> > printf(" --hashlimit-burst %"PRIu64, cfg->burst);
>
> That's odd, burst field of hashlimit_cfg2 struct is supposed to be an
> __u64 integer (see include/linux/netfilter/xt_hashlimit.h line 68).
> Probably you include the wrong header file.
Yes, this is strange. I'm just giving a quick compilation test on my
laptop using the git tree and I hit this. Hm.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats
2017-05-29 12:02 ` Pablo Neira Ayuso
2017-05-29 12:11 ` Alin Năstac
@ 2017-05-29 12:18 ` Alin Năstac
2017-06-19 17:26 ` Pablo Neira Ayuso
1 sibling, 1 reply; 6+ messages in thread
From: Alin Năstac @ 2017-05-29 12:18 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On Mon, May 29, 2017 at 2:02 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Wed, May 24, 2017 at 09:13:58AM +0200, Alin Nastac wrote:
>> From: Alin Nastac <alin.nastac@gmail.com>
>>
>> The remaining %llu formats are used for unsigned long long values.
>
> Hm, still problems here:
>
> libxt_hashlimit.c: In function ‘hashlimit_mt_print’:
> libxt_hashlimit.c:739:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=] printf(" burst %"PRIu64, cfg->burst);
> printf(" burst %"PRIu64, cfg->burst);
> ^
> libxt_hashlimit.c: In function ‘hashlimit_mt_save’:
> libxt_hashlimit.c:849:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=]
> printf(" --hashlimit-burst %"PRIu64, cfg->burst);
On second thought, seems that "%"PRIu64 is equivalent in your case
with "%lu". Maybe it is better to replace all %"PRIu64" with %llu.
After all, uint64_t is supposed to be unsigned long long on all
architectures, isn't it so?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats
2017-05-29 12:18 ` Alin Năstac
@ 2017-06-19 17:26 ` Pablo Neira Ayuso
0 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2017-06-19 17:26 UTC (permalink / raw)
To: Alin Năstac; +Cc: netfilter-devel
On Mon, May 29, 2017 at 02:18:51PM +0200, Alin Năstac wrote:
> On Mon, May 29, 2017 at 2:02 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Wed, May 24, 2017 at 09:13:58AM +0200, Alin Nastac wrote:
> >> From: Alin Nastac <alin.nastac@gmail.com>
> >>
> >> The remaining %llu formats are used for unsigned long long values.
> >
> > Hm, still problems here:
> >
> > libxt_hashlimit.c: In function ‘hashlimit_mt_print’:
> > libxt_hashlimit.c:739:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=] printf(" burst %"PRIu64, cfg->burst);
> > printf(" burst %"PRIu64, cfg->burst);
> > ^
> > libxt_hashlimit.c: In function ‘hashlimit_mt_save’:
> > libxt_hashlimit.c:849:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat=]
> > printf(" --hashlimit-burst %"PRIu64, cfg->burst);
>
> On second thought, seems that "%"PRIu64 is equivalent in your case
> with "%lu". Maybe it is better to replace all %"PRIu64" with %llu.
> After all, uint64_t is supposed to be unsigned long long on all
> architectures, isn't it so?
long unsigned int here is 64-bits. But it takes processor word size.
I'm inclined to think we should just cast the __u64 to uint64_t to
sort out this, and use PRIu64.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-06-19 17:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24 7:13 [PATCH v3] extensions: libxt_hashlimit: fix uint64_t printf formats Alin Nastac
2017-05-29 12:02 ` Pablo Neira Ayuso
2017-05-29 12:11 ` Alin Năstac
2017-05-29 12:17 ` Pablo Neira Ayuso
2017-05-29 12:18 ` Alin Năstac
2017-06-19 17:26 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).