From e3cde0613bfdd59d525770bc0e15c54e58b08412 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 27 Feb 2023 19:13:13 +1100 Subject: Add -Wsuggest-attribute=format warning, correct warnings thus generated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add this new warning to the default build flags. It suggests adding a ((format)) attribute to xavsprintf_append(), so do that. Suggested-by: Marc-André Lureau Signed-off-by: David Gibson --- Makefile | 3 ++- meson.build | 3 ++- util.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 93938e9..23b4a3c 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ ASSUME_MASK ?= 0 CPPFLAGS = -I libfdt -I . -DFDT_ASSUME_MASK=$(ASSUME_MASK) WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs -Wsign-compare \ - -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow + -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow \ + -Wsuggest-attribute=format CFLAGS = -g -Os $(SHAREDLIB_CFLAGS) -Werror $(WARNINGS) $(EXTRA_CFLAGS) BISON = bison diff --git a/meson.build b/meson.build index 78251eb..f50cf1e 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,8 @@ add_project_arguments( '-Wstrict-prototypes', '-Wmissing-prototypes', '-Wredundant-decls', - '-Wshadow' + '-Wshadow', + '-Wsuggest-attribute=format', ]), language: 'c' ) diff --git a/util.h b/util.h index 9d38ede..1547707 100644 --- a/util.h +++ b/util.h @@ -65,7 +65,7 @@ extern char *xstrndup(const char *s, size_t len); extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...); extern int PRINTF(2, 3) xasprintf_append(char **strp, const char *fmt, ...); -extern int xavsprintf_append(char **strp, const char *fmt, va_list ap); +extern int PRINTF(2, 0) xavsprintf_append(char **strp, const char *fmt, va_list ap); extern char *join_path(const char *path, const char *name); /** -- cgit v1.2.1