-Wformat-security warnings generated in gcc build

Prathamesh Kulkarni bilbotheelffriend@gmail.com
Tue Jan 21 16:03:00 GMT 2014


There are about 35 warnings of type "format not a string literal and
no formal arguments [-Wformat-security]" generated during gcc-4.9.0
build (revision 206867)
I have attached them in orig-warnings.txt.

Souce of these warnings are typically calls to error() and friends.
In  C and C++ front ends there are many calls of error (errmsg).
errmsg is in many cases, assigned the return value of targetm hooks
(tagetm.invalid_return_type(), etc.)  Is it correct to replace error
(errmsg) by
error ("%s", errmsg) in these cases ?

I have attached a patch that removes 25 of these warnings
(attached in removed-warnings.txt).
I didn't replace the calls to error() and friends where gmsgid was passed.
(eg: c-typeck.c: error (gmsgid) called by error_init() function at line 6390)

Thanks and Regards,
Prathamesh
-------------- next part --------------
../../src/libcpp/expr.c:672:18: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/libcpp/expr.c:675:39: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/libcpp/macro.c:2972:58: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/libcpp/macro.c:2985:58: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-decl.c:5701:16: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-decl.c:6482:21: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:3303:28: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:3798:42: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:10066:42: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-convert.c:82:31: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/tree-sra.c:3864:26: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/tree-ssa-uninit.c:767:26: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/opts.c:1042:33: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/opts.c:1042:33: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/decl.c:9553:16: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/decl.c:11122:17: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/pt.c:13968:20: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/typeck.c:3986:24: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/typeck.c:5562:24: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/cvt.c:672:26: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/collect2.c:1985:21: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/collect2.c:2536:21: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/lto-wrapper.c:195:24: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/lto-wrapper.c:198:15: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/gcc.c:2785:25: warning: format not a string literal and no format arguments [-Wformat-security]
-------------- next part --------------
../../src/libcpp/expr.c:672:18: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/libcpp/expr.c:675:39: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/libcpp/macro.c:2972:58: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/libcpp/macro.c:2985:58: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-decl.c:5701:16: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-decl.c:6482:21: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:3303:28: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:3798:42: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:6390:16: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:6407:33: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:6425:23: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-typeck.c:10066:42: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c/c-convert.c:82:31: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c-family/c-common.c:9524:18: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/c-family/c-common.c:9528:21: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/dwarf2asm.c:167:50: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/fold-const.c:315:42: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/tree-sra.c:3864:26: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/tree-ssa-uninit.c:767:26: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/opts.c:1042:33: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/opts.c:1042:33: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/opts.c:1056:8: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/opts.c:1056:8: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/decl.c:9553:16: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/decl.c:11122:17: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/pt.c:13968:20: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/parser.c:2658:55: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/typeck.c:3986:24: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/typeck.c:5562:24: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/cp/cvt.c:672:26: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/collect2.c:1985:21: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/collect2.c:2536:21: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/lto-wrapper.c:195:24: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/lto-wrapper.c:198:15: warning: format not a string literal and no format arguments [-Wformat-security]
../../src/gcc/gcc.c:2785:25: warning: format not a string literal and no format arguments [-Wformat-security]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: format-warnings.patch
Type: text/x-patch
Size: 8446 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20140121/f5076e67/attachment.bin>


More information about the Gcc mailing list