On Tue, 3 Dec 2019 at 01:54, Rosen Penev <ros...@gmail.com> wrote: > > A const char * variable is being passed as a format string. Unfortunately, > this is not correct. > > A constant expression needs to be passed so that GCC can determine the > types of the format properly. > > Also fixed a different warning that needs a printf attribute. > > Fixes: > > error: format not a string literal, argument types not checked > [-Werror=format-nonliteral] > 176 | error_info); > | ^~~~~~~~~~ > error: format not a string literal, argument types not checked > [-Werror=format-nonliteral] > 185 | error_info); > > cli.c:196:19: error: format string is not a string literal > [-Werror=format-nonliteral] > vfprintf(stderr, fmt, ap); > > Signed-off-by: Rosen Penev <ros...@gmail.com> > --- > v3: Moved define to top of file. > v2: Fixed extra warning from clang 10. > cli.c | 1 + > libuci.c | 15 ++++++++------- > 2 files changed, 9 insertions(+), 7 deletions(-) > > diff --git a/cli.c b/cli.c > index 8970f4f..6ba97ea 100644 > --- a/cli.c > +++ b/cli.c > @@ -185,6 +185,7 @@ static void cli_perror(void) > uci_perror(ctx, appname); > } > > +__attribute__((format(printf, 1, 2))) > static void cli_error(const char *fmt, ...) > { > va_list ap; > diff --git a/libuci.c b/libuci.c > index a9e70e8..0f0211a 100644 > --- a/libuci.c > +++ b/libuci.c > @@ -40,6 +40,12 @@ static const char *uci_errstr[] = { > #include "uci_internal.h" > #include "list.c" > > +#define errstr \
As mentioned in my previous email, please use all caps for #defines. And maybe give it a more descriptive less generic name. E.g. UCI_ERR_FORMAT, as it is a format string, and should be uci "namespaced" (as much as you can namespace stuff in C). Regards Jonas _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel