summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2025-10-17 10:38:25 +0200
committerFlorian Westphal <fw@strlen.de>2025-10-23 14:53:50 +0200
commitbc330914780345616edde25329e3c866ec279b42 (patch)
tree52a73d4f3d886f13c86fff60e14516ca2c2b97be /src
parent95482c8c809922aa870099e81c65568330b35b42 (diff)
src: fix fmt string warnings
for some reason several functions had a __gmp_fmtstring annotation, but that was an empty macro. After fixing it up, we get several new warnings: In file included from src/datatype.c:28: src/datatype.c:174:24: note: in expansion of macro 'error' 174 | return error(&sym->location, | ^~~~~ src/datatype.c:405:24: note: in expansion of macro 'error' 405 | return error(&sym->location, "Could not parse %s; did you mean `%s'?", | ^~~~~ Fmt string says '%s', but unqailified void *, add 'const char *' cast, it is safe in both cases. In file included from src/evaluate.c:29: src/evaluate.c: In function 'byteorder_conversion': src/evaluate.c:232:35: warning: format '%s' expects a matching 'char *' argument [-Wformat=] 232 | "Byteorder mismatch: %s expected %s, %s got %s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Actual bug, fmt string has one '%s' too many, remove it. All other warnings were due to '%u' instead of '%lu' / '%zu'. Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src')
-rw-r--r--src/datatype.c4
-rw-r--r--src/evaluate.c8
-rw-r--r--src/parser_bison.y2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/datatype.c b/src/datatype.c
index f347010f..956ce2ac 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -173,7 +173,7 @@ static struct error_record *__symbol_parse_fuzzy(const struct expr *sym,
if (st.obj) {
return error(&sym->location,
"Could not parse %s expression; did you you mean `%s`?",
- sym->dtype->desc, st.obj);
+ sym->dtype->desc, (const char *)st.obj);
}
return NULL;
@@ -403,7 +403,7 @@ static struct error_record *verdict_type_error(const struct expr *sym)
if (st.obj) {
return error(&sym->location, "Could not parse %s; did you mean `%s'?",
- sym->dtype->desc, st.obj);
+ sym->dtype->desc, (const char *)st.obj);
}
/* assume user would like to jump to chain as a hint. */
diff --git a/src/evaluate.c b/src/evaluate.c
index a5cc4181..ffd3ce62 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -229,7 +229,7 @@ static int byteorder_conversion(struct eval_ctx *ctx, struct expr **expr,
return 0;
default:
return expr_error(ctx->msgs, *expr,
- "Byteorder mismatch: %s expected %s, %s got %s",
+ "Byteorder mismatch: expected %s, %s got %s",
byteorder_names[byteorder],
expr_name(*expr),
byteorder_names[(*expr)->byteorder]);
@@ -1811,7 +1811,7 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
ctx->inner_desc = NULL;
if (size > NFT_MAX_EXPR_LEN_BITS)
- return expr_error(ctx->msgs, i, "Concatenation of size %u exceeds maximum size of %u",
+ return expr_error(ctx->msgs, i, "Concatenation of size %u exceeds maximum size of %lu",
size, NFT_MAX_EXPR_LEN_BITS);
}
@@ -3507,7 +3507,7 @@ static int stmt_evaluate_payload(struct eval_ctx *ctx, struct stmt *stmt)
if (payload_byte_size > sizeof(data))
return expr_error(ctx->msgs, stmt->payload.expr,
- "uneven load cannot span more than %u bytes, got %u",
+ "uneven load cannot span more than %zu bytes, got %u",
sizeof(data), payload_byte_size);
if (aligned_fetch && payload_byte_size & 1) {
@@ -5187,7 +5187,7 @@ static int set_expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
size += netlink_padded_len(i->len);
if (size > NFT_MAX_EXPR_LEN_BITS)
- return expr_error(ctx->msgs, i, "Concatenation of size %u exceeds maximum size of %u",
+ return expr_error(ctx->msgs, i, "Concatenation of size %u exceeds maximum size of %lu",
size, NFT_MAX_EXPR_LEN_BITS);
}
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 3c21c758..52730f71 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -5863,7 +5863,7 @@ payload_expr : payload_raw_expr
payload_raw_len : NUM
{
if ($1 > NFT_MAX_EXPR_LEN_BITS) {
- erec_queue(error(&@1, "raw payload length %u exceeds upper limit of %u",
+ erec_queue(error(&@1, "raw payload length %lu exceeds upper limit of %lu",
$1, NFT_MAX_EXPR_LEN_BITS),
state->msgs);
YYERROR;