Discussion:
[ARM] Fix _unlink prototype under ARM_RDI_MONITOR.
Christophe Lyon
2018-10-01 21:28:51 UTC
Permalink
Hi,

I noticed that "path" is actually used when compiling with
ARM_RDI_MONITOR, so this small patch removes the unused attribute in
that case.

OK?

Christophe
Eric Blake
2018-10-01 22:15:47 UTC
Permalink
Post by Christophe Lyon
Hi,
I noticed that "path" is actually used when compiling with
ARM_RDI_MONITOR, so this small patch removes the unused attribute in
that case.
OK?
Personally, I'd rather not take this patch.
Post by Christophe Lyon
int
+#ifdef ARM_RDI_MONITOR
+_unlink (const char *path)
+#else
_unlink (const char *path __attribute__ ((unused)))
+#endif
GCC (and thus clang when copying it) defined __attribute__((unused)) to
merely mean "might be unused, so suppress warnings about it being unused
even it if turns out to be used after all", and not "must be unused, so
warn if it actually gets used". It is specifically designed this way so
that you DON'T have to add a bunch of #ifdefs around code to apply the
attribute. If there is at least one path through the rest of a
function's existing #ifdef maze where the attribute matters, then use
the attribute unconditionally, rather than making the #ifdef maze worse.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
Christophe Lyon
2018-10-02 06:35:48 UTC
Permalink
Post by Eric Blake
Post by Christophe Lyon
Hi,
I noticed that "path" is actually used when compiling with
ARM_RDI_MONITOR, so this small patch removes the unused attribute in
that case.
OK?
Personally, I'd rather not take this patch.
Post by Christophe Lyon
int
+#ifdef ARM_RDI_MONITOR
+_unlink (const char *path)
+#else
_unlink (const char *path __attribute__ ((unused)))
+#endif
GCC (and thus clang when copying it) defined __attribute__((unused)) to
merely mean "might be unused, so suppress warnings about it being unused
even it if turns out to be used after all", and not "must be unused, so
warn if it actually gets used". It is specifically designed this way so
that you DON'T have to add a bunch of #ifdefs around code to apply the
attribute. If there is at least one path through the rest of a
function's existing #ifdef maze where the attribute matters, then use
the attribute unconditionally, rather than making the #ifdef maze worse.
OK, makes sense.

Thanks
Post by Eric Blake
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
Loading...