This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa] some -Wformat-nonliteral changes


As promised, here are the easy -Wformat-nonliteral changes.  Most of
them consist of replacing calls like fprintf(stream, foo) with
fputs(foo, stream).  A few of them consist of replacing error(msg)
with error("%s",msg).  And one of them is an actual bug fix - there's
a call to internal_error that left out __FILE__ and __LINE__.

Insert expression of disbelief:


-      internal_error ("Error converting character `%d' from `%s' to `%s' "
+      internal_error (__FILE__, __LINE__,
+		      "Error converting character `%d' from `%s' to `%s' "
                       "character set: %s",
                       from_char, ci->from->name, ci->to->name,
                       safe_strerror (errno));

The other changes are also, arguably, bug fixes. There's no guarentee that there isn't a % in the buffer.


Having said that, there's still a lot of warnings triggered by
-Wformat-nonliteral; some of them are in situations with a fairly easy
workaround, but some of them are a little more delicate.  I would
definitely recommend that the -Wformat-nonliteral patch be reverted
for the time being, because it's breaking compiles for some of us.

I've tested this with GCC 3.2, i686-pc-linux-gnu, DWARF-2; no new
regressions.  It also doesn't turn up any regressions on GDB 6.0; I'd
lean towards applying the internal_error bug fix part of it to the
branch, but I don't have much of an opinion one way or another about
applying the entire patch.

OK to apply?  It should all be obvious, but I might as well have
another set of eyes proofreading it.

Yes, ok, and yes, the internal_error patch should go onto the branch.


Before reverting -Wformat-nonliteral, I'd like to see exactly what the damange is - it's clearly finding bugs.

Andrew



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]