Sign mismatch in format string in dump_flags_type (formatting a guint with %d)
Submitted by John Beard
Link to original bug (#785089)
Description
In the function dump_flags_type(), the value field of a GFlagsValue struct is passed to a format string with a %d formatter:
GFlagsValue *value = &(klass->values[i]);
escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%d\"/>\n",
value->value_name, value->value_nick, value->value);
The value field is guint, so this throws -Wformat warnings. For example, when compiling gucharmap:
<snip>
/gucharmap/gucharmap/tmp-introspectjimc0g67/Gucharmap-2.90.c: In function ‘dump_flags_type’:
<snip>
/gucharmap/gucharmap/tmp-introspectjimc0g67/Gucharmap-2.90.c:319:74: warning: format ‘%d’
expects argument of type ‘int’, but argument 5 has type ‘guint {aka unsigned int}’ [-Wformat=]
escaped_printf (out, " <member name="%s" nick="%s" value="%d"/>\n",
~^
%d
value->value_name, value->value_nick, value->value)
I believe just changing %d to %u would suffice to silence this warning?