diff options
author | Eric Biggers <ebiggers@google.com> | 2023-01-21 12:32:02 -0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2023-01-27 12:33:59 -0500 |
commit | b575249eb334e3f95319eea68c9606f43db05a07 (patch) | |
tree | 81c1399a3a51f21cc1b41172cb61ab8be3bf5eb6 | |
parent | 8eb4a1d71d539a3867b4ddc1ab7c924b033218a6 (diff) | |
download | e2fsprogs-b575249eb334e3f95319eea68c9606f43db05a07.tar.gz |
lib/blkid: suppress -Wunused-result warning in blkid_flush_cache()
When _FORTIFY_SOURCE is defined, glibc annotates link() with the
warn_unused_result function attribute. With gcc, that makes
'(void) link()' cause a -Wunused-result warning, despite the explicit
cast to void. That's annoying, since the use case in lib/blkid/save.c
is legitimate (opportunistic backup). So let's suppress this warning.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | lib/blkid/save.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/blkid/save.c b/lib/blkid/save.c index 036f07a4a..6f4499cfd 100644 --- a/lib/blkid/save.c +++ b/lib/blkid/save.c @@ -154,7 +154,15 @@ int blkid_flush_cache(blkid_cache cache) if (backup) { sprintf(backup, "%s.old", filename); unlink(backup); +#if defined(__GNUC__) && __GNUC__ >= 5 +/* explicit (void) cast is not enough with glibc and _FORTIFY_SOURCE */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" +#endif (void) link(filename, backup); +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic pop +#endif free(backup); } if (rename(opened, filename) < 0) |