Skip to content

Commit b99bddc

Browse files
ppisarcire831
authored andcommitted
Fix building with -Werror=format-security (#40)
When buildling with -Wall -Werror=format-security, fatal warnings arise like this: gcc -I. -I. -I./../include -I./include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D _FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord -gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -pedantic -Wno-long-long -I. -I. -I./../include -I./include -c -o macro.o -MT macro.o -MMD -MP -MF .deps/macro.Po macro.c [...] macro.c: In function ‘create_iso_definition’: macro.c:1576:8: error: format not a string literal and no format arguments [-Werror=format-security] cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); ^~~~~~~~~ macro.c:1589:8: error: format not a string literal and no format arguments [-Werror=format-security] cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); ^~~~~~~~~ This patch fixes them.
1 parent 3edac3c commit b99bddc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

libcpp/macro.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
15731573
function-like macros, but not at the end. */
15741574
if (following_paste_op)
15751575
{
1576-
cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
1576+
cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg);
15771577
return false;
15781578
}
15791579
break;
@@ -1586,7 +1586,7 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
15861586
function-like macros, but not at the beginning. */
15871587
if (macro->count == 1)
15881588
{
1589-
cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg);
1589+
cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg);
15901590
return false;
15911591
}
15921592

src/nesc-generate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static bool prt_arguments(declaration parms, bool first, bool rename)
190190
if (rename || !vd->ddecl->name)
191191
output("arg_%p", vd->ddecl);
192192
else
193-
output((char *)vd->ddecl->name);
193+
output("%s", (char *)vd->ddecl->name);
194194
}
195195
return first;
196196
}

0 commit comments

Comments
 (0)