This allows gcc to check format string vs. passed arguments.
Fix the fallout from this as well, typical warning produced is:
libebt_mark_m.c:112:28: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
xt_xlate_add(xl, "and 0x%x %s0 ", info->mask, ...
~^ ~~~~~~~~~~
so add the required casts or fixup format strings as needed.
libxt_conntrack also passed an unneeded argument (port), so remove that.
Signed-off-by: Florian Westphal <fw@strlen.de>
xt_xlate_add(xl, "meta mark ");
if (info->bitmask == EBT_MARK_OR) {
- xt_xlate_add(xl, "and 0x%x %s0 ", info->mask,
+ xt_xlate_add(xl, "and 0x%x %s0 ", (uint32_t)info->mask,
info->invert ? "" : "!= ");
} else if (info->mask != 0xffffffffU) {
- xt_xlate_add(xl, "and 0x%x %s0x%x ", info->mask,
- op == XT_OP_EQ ? "" : "!= ", info->mark);
+ xt_xlate_add(xl, "and 0x%x %s0x%x ", (uint32_t)info->mask,
+ op == XT_OP_EQ ? "" : "!= ", (uint32_t)info->mark);
} else {
xt_xlate_add(xl, "%s0x%x ",
- op == XT_OP_EQ ? "" : "!= ", info->mark);
+ op == XT_OP_EQ ? "" : "!= ", (uint32_t)info->mark);
}
return 1;
switch(markinfo->mode) {
case XT_MARK_SET:
- xt_xlate_add(xl, "0x%x ", markinfo->mark);
+ xt_xlate_add(xl, "0x%x ", (uint32_t)markinfo->mark);
break;
case XT_MARK_AND:
- xt_xlate_add(xl, "mark and 0x%x ", markinfo->mark);
+ xt_xlate_add(xl, "mark and 0x%x ", (uint32_t)markinfo->mark);
break;
case XT_MARK_OR:
- xt_xlate_add(xl, "mark or 0x%x ", markinfo->mark);
+ xt_xlate_add(xl, "mark or 0x%x ", (uint32_t)markinfo->mark);
break;
}
sinfo->invert_flags & XT_CONNTRACK_EXPIRES ?
"!= " : "");
if (sinfo->expires_max == sinfo->expires_min)
- xt_xlate_add(xl, "%lu", sinfo->expires_min);
+ xt_xlate_add(xl, "%u", sinfo->expires_min);
else
- xt_xlate_add(xl, "%lu-%lu", sinfo->expires_min,
+ xt_xlate_add(xl, "%u-%u", sinfo->expires_min,
sinfo->expires_max);
space = " ";
}
if (sinfo->match_flags & XT_CONNTRACK_REPLDST_PORT) {
xt_xlate_add(xl, "%sct reply proto-dst %s", space,
sinfo->invert_flags & XT_CONNTRACK_REPLDST_PORT ?
- "!= " : "", sinfo->repldst_port);
+ "!= " : "");
if (sinfo->repldst_port == sinfo->repldst_port_high)
xt_xlate_add(xl, "%u", sinfo->repldst_port);
else
_rates[i].mult / avg < _rates[i].mult % avg)
break;
- xt_xlate_add(xl, " %llu/%s ",
+ xt_xlate_add(xl, " %" PRIu64 "/%s ",
_rates[i-1].mult / avg, _rates[i-1].name);
}
else {
print_packets_rate_xlate(xl, cfg->avg, revision);
if (cfg->burst != XT_HASHLIMIT_BURST)
- xt_xlate_add(xl, "burst %lu packets", cfg->burst);
+ xt_xlate_add(xl, "burst %" PRIu64 " packets", (uint64_t)cfg->burst);
}
xt_xlate_add(xl, "}");
ret = hashlimit_mode_xlate(xl, info->cfg.mode, NFPROTO_IPV4, 32, 32);
xt_xlate_add(xl, " timeout %us limit rate", info->cfg.expire / 1000);
print_packets_rate_xlate(xl, info->cfg.avg, 1);
- xt_xlate_add(xl, " burst %lu packets", info->cfg.burst);
+ xt_xlate_add(xl, " burst %u packets", info->cfg.burst);
xt_xlate_add(xl, "}");
return ret;
/* xlate infrastructure */
struct xt_xlate *xt_xlate_alloc(int size);
void xt_xlate_free(struct xt_xlate *xl);
-void xt_xlate_add(struct xt_xlate *xl, const char *fmt, ...);
+void xt_xlate_add(struct xt_xlate *xl, const char *fmt, ...) __attribute__((format(printf,2,3)));
void xt_xlate_add_comment(struct xt_xlate *xl, const char *comment);
const char *xt_xlate_get_comment(struct xt_xlate *xl);
const char *xt_xlate_get(struct xt_xlate *xl);