format and vecformat must be declared as "char * const" to be really treated as constant when building with -Werror=format-nonliteral, otherwise compiler will consider them subject to change throughout the function. Signed-off-by: Giulio Benetti <giulio.benetti@xxxxxxxxxxxxxxxxxxxxxx> --- tools/rpcgen/rpc_cout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/rpcgen/rpc_cout.c b/tools/rpcgen/rpc_cout.c index f806a86a..df2609c4 100644 --- a/tools/rpcgen/rpc_cout.c +++ b/tools/rpcgen/rpc_cout.c @@ -319,8 +319,8 @@ emit_union(definition *def) case_list *cl; declaration *cs; char *object; - char *vecformat = "objp->%s_u.%s"; - char *format = "&objp->%s_u.%s"; + char * const vecformat = "objp->%s_u.%s"; + char * const format = "&objp->%s_u.%s"; print_stat(1,&def->def.un.enum_decl); f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name); -- 2.20.1