GNOME Bugzilla – Bug 725994
cheese uses -Werror=nonliteral-format and non-literal format strings
Last modified: 2014-03-17 21:41:38 UTC
Cheese (due to its use of Vala) makes use of non-literal format strings.
One such example:
_tmp13_ = stdout;
_tmp14_ = _ ("Run '%s --help' to see a full list of available command line options.");
_tmp15_ = arguments;
_tmp15__length1 = arguments_length1;
_tmp16_ = _tmp15_;
fprintf (_tmp13_, _tmp14_, _tmp16_);
it should probably stop using -Werror=non-literal format (and maybe a lot of other warnings CFLAGS) if it's using Vala...
gcc makes an exception to the non-literal format string rule in cases of functions that take va_list instead of '...', but clang makes no such exception -- instead, it forces the format-string annotation to be applied at the next level up, so cheese currently won't build with clang and default CFLAGS.
as an aside: for this particular case, maybe it makes sense to look at the new GApplication commandline argument handling API, which would eliminate the need to throw this message yourself...
(vala bug 725995)
Created attachment 271489 [details] [review]
The attached patch works for me, and I guess avoids the string format warning as a side effect. I am not a Vala expert, so I still need to fix the TODO if I can (but will look at it again tomorrow). Please let me know if it works with clang.
I should have mentioned that bug 726057 needs fixing for ApplicationCommandLine.get_options_dict() to appear in the VAPI.
Review of attachment 271489 [details] [review]:
@@ +157,3 @@
+ var opts = cl.get_options_dict ();
+ if (opts.contains ("device"))
You want type string "^ay" to read into a char*.
But in general, you should not be using command_line in this way... that comes down to the Vala bindings being updated, as you properly point out.
Fixed in master with commit 9697f05e2c0ce03b96791ec2fa9b993c4c505164. Thanks for the hint about the "^ay".