Re: [patch] cleanup: Wunused corefile.c

Tom Tromey
2013-01-31T20:24:40Z

>>>>> "Aleksandar" == Aleksandar Ristovski <aristovski@qnx.com> writes:

Aleksandar> In addition to already posted/committed Wunused I have a bunch of
Aleksandar> patches which work around unused vars by adding attribute unused.

You should probably try a --enable-targets=all build if you want to
enable -Wunused in configure...

Aleksandar> Rationale was: either it was unclear whether the assignment
Aleksandar> might have side-effects or there was something that should
Aleksandar> have been done (e.g. this case) with the variable.

Aleksandar> Let me know if this is acceptable approach.

It definitely isn't in this form, and perhaps not in other forms.

First, in this case, the is just buggy. If stat fails, then st.st_mtime
isn't necessarily set, and so the subsequent test is reading garbage.
This is the sort of bug that -Wunused helps to diagnose -- so adding an
attribute to silence the error isn't what we should do.

Second, using __attribute__ unconditionally isn't ok. We can use the
ATTRIBUTE_UNUSED macro; but I would imagine in most cases it would be
better to fix the problem in some other way.

Tom