GNOME Bugzilla – Bug 702516
gfileutils: Make -Werror=format-nonliteral happy
Last modified: 2013-09-29 18:37:14 UTC
I tried to please it by using G_GNUC_FORMAT, but that didn't work, so let's just fall back to pushing an ignore.
Created attachment 247075 [details] [review] gfileutils: Make -Werror=format-nonliteral happy I tried to please it by using G_GNUC_FORMAT, but that didn't work, so let's just fall back to pushing an ignore.
See also https://bugzilla.gnome.org/show_bug.cgi?id=692130 which is related I think in that if we actually got -Werror=format-security it'd trigger this.
Review of attachment 247075 [details] [review]: I assume it is safe to use _Pragma directly like that, other compilers are supposed to ignore it. But _Pragma is C99 - does it work with all the compilers we care about ?
no. but we can just use #pragma here since it's not in a macro
Created attachment 252071 [details] [review] now with a more #pragma-tic soution
Created attachment 255994 [details] [review] Covers the other 5 files with these errors I've patched the other 5 files. Apple has released Xcode 5 without llvm-gcc4.2, so there's only Clang, so it's a bit more urgent that we commit these patches.
Review of attachment 255994 [details] [review]: Hi John, This looks fine, thanks a lot for writing the patch! It's unfortunate that CLang applies -Wformat-nonliteral differently from GCC, but I'm glad it at least respects the same diagnostics. Let's go with this for now, but I suspect this will be a continuing issue because a lot of us GCC-using developers will keep adding patches that may trigger the behavior.
(Can you or someone else review my patch?)
Review of attachment 252071 [details] [review]: seems all right to me.
Heh. With gcc-4.2, it bombs with /Users/john/Development/gtk-sources/glib-2.38.0/glib/gfileutils.c: In function 'format_error_message': /Users/john/Development/gtk-sources/glib-2.38.0/glib/gfileutils.c:1019: error: #pragma GCC diagnostic not allowed inside functions /Users/john/Development/gtk-sources/glib-2.38.0/glib/gfileutils.c:1020: error: #pragma GCC diagnostic not allowed inside functions /Users/john/Development/gtk-sources/glib-2.38.0/glib/gfileutils.c:1026: error: #pragma GCC diagnostic not allowed inside functions I fixed that with ab5aa2a and backported everything to glib-2-38.