[GRASS-dev] compilation of grass on AIX 7.1

Hamish hamish_b at yahoo.com
Mon Jul 29 01:55:29 PDT 2013


Vaclav wrote:
>> GCC warns me also about "format not a string literal and no format
>> arguments". I remember this was once discussed on the ML but I'm not
>> sure what the result was: the call is correct but the G_warning
>> function needs some GCC attributes to specify what it is?
Glynn:
> G_warning() already has a "format" attribute, which is why gcc
> complains about the format string not being a string literal.
>
> However, G_gettext() needs a "format_arg" attribute to to tell gcc
> that one of arguments may be a format string, so that it stillcan
> perform argument checking (and not generate "not a string literal"
> warnings) when a format string is passed through that function (the
> _(...) macro expands to a G_gettext() call when --with-nls is used).
>
> Done in r57238.
>
> With that change there are still 208 such warnings, but most of them
> appear to indicate genuine bugs, i.e. passing arbitrary strings as
> format strings, which will fail (e.g. crash) if the string contains
> any % characters.

Hi,

is it appropriate to backport r57238 to 6.x?

glocale.h:
-extern char *G_gettext(const char *, const char *);
+extern char *G_gettext(const char *, const char *) __attribute__((format_arg (2)));


I'm seeing this pop up in Debian/unstable, where -Werror=format-security
is now encouraged to be the default.


there are also quite a few like "G_fatal_error(buff);", can anything
be done in the lib fn for them or do they all have to be changed to
"G_fatal_error("%s", buff);" ? [* many of those are hold-overs from pre-
GRASS 5 and a sprintf(buff,..) in the lines above can be moved into the
G_fatal_error()]
Lots of "G_warning(msg);" and "G_debug(3, db_get_string(&sql));" to
consider too.



thanks,
Hamish



More information about the grass-dev mailing list