diff options
author | Eric Biggers <ebiggers@google.com> | 2023-01-21 12:32:03 -0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2023-01-27 12:33:59 -0500 |
commit | c093c7527d4c2baedef32d6eb31175e48af3b99d (patch) | |
tree | 68f8ea32ddcc32c33ddf17c63ecc7e63281d5e6b | |
parent | b575249eb334e3f95319eea68c9606f43db05a07 (diff) | |
download | e2fsprogs-c093c7527d4c2baedef32d6eb31175e48af3b99d.tar.gz |
lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup()
Unfortunately, gcc gets confused by blkid_strndup() and incorrectly
thinks the destination string is not being null-terminated. This is
part of -Wstringop-truncation, enabled automatically by -Wall in gcc 8
and later. Let's just suppress this warning here.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | lib/blkid/devno.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c index 34ceb3c48..b1cadc9df 100644 --- a/lib/blkid/devno.c +++ b/lib/blkid/devno.c @@ -37,6 +37,12 @@ #include "blkidP.h" +#if defined(__GNUC__) && __GNUC__ >= 8 +/* gcc incorrectly thinks the destination string is not being null-terminated */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + char *blkid_strndup(const char *s, int length) { char *ret; @@ -55,6 +61,10 @@ char *blkid_strndup(const char *s, int length) return ret; } +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic pop +#endif + char *blkid_strdup(const char *s) { return blkid_strndup(s, 0); |