[PATCH nft v2 8/8] include: drop "format" attribute from nft_gmp_print()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



nft_gmp_print() passes the format string and arguments to
gmp_vfprintf(). Note that the format string is then interpreted
by gmp, which also understand special specifiers like "%Zx".

Note that with clang we get various compiler warnings:

  datatype.c:299:26: error: invalid conversion specifier 'Z' [-Werror,-Wformat-invalid-specifier]
          nft_gmp_print(octx, "0x%Zx [invalid type]", expr->value);
                                 ~^

gcc doesn't warn, because to gcc 'Z' is a deprecated alias for 'z' and
because the 3rd argument of the attribute((format())) is zero (so gcc
doesn't validate the arguments). But Z specifier in gmp expects a
"mpz_t" value and not a size_t. It's really not the same thing.

The correct solution is not to mark the function to accept a printf format
string.

Fixes: 2535ba7006f2 ('src: get rid of printf')

Signed-off-by: Thomas Haller <thaller@xxxxxxxxxx>
---
 include/nftables.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/nftables.h b/include/nftables.h
index 219a10100206..b9b2b01c2689 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -236,8 +236,7 @@ void realm_table_rt_exit(struct nft_ctx *ctx);
 
 int nft_print(struct output_ctx *octx, const char *fmt, ...)
 	__attribute__((format(printf, 2, 3)));
-int nft_gmp_print(struct output_ctx *octx, const char *fmt, ...)
-	__attribute__((format(printf, 2, 0)));
+int nft_gmp_print(struct output_ctx *octx, const char *fmt, ...);
 
 int nft_optimize(struct nft_ctx *nft, struct list_head *cmds);
 
-- 
2.41.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux