diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2021-05-12 16:37:16 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2021-05-12 16:44:11 -0400 |
commit | 9a952fe5a25a4fa7d1d7cc1e0c37f08036b29f06 (patch) | |
tree | 289b99befbde70596780f17622e21abc06ba51de /test_utils | |
parent | 942cd1a5e1ce4e1450cecafa2674f71aea0263a4 (diff) | |
download | libarchive-9a952fe5a25a4fa7d1d7cc1e0c37f08036b29f06.tar.gz |
Avoid getcwd(0, PATH_MAX) for GNU libc
Recent versions of GNU libc and GCC produce a warning on getcwd(0, PATH_MAX):
test_main.c: In function ‘get_refdir’:
test_main.c:3684:8: error: argument 1 is null but the corresponding size argument 2 value is 4096 [-Werror=nonnull]
3684 | pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */
This is because getcwd() is marked with the 'write_only (1, 2)' attribute.
Using the alternate getcwd(NULL, 0) path which is supported by GNU libc avoids this.
Diffstat (limited to 'test_utils')
-rw-r--r-- | test_utils/test_main.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test_utils/test_main.c b/test_utils/test_main.c index ef066eb6..c1c03cda 100644 --- a/test_utils/test_main.c +++ b/test_utils/test_main.c @@ -3680,7 +3680,7 @@ get_refdir(const char *d) } /* Get the current dir. */ -#ifdef PATH_MAX +#if defined(PATH_MAX) && !defined(__GLIBC__) pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */ #else pwd = getcwd(NULL, 0); @@ -3775,7 +3775,7 @@ main(int argc, char **argv) (void)argc; /* UNUSED */ /* Get the current dir. */ -#ifdef PATH_MAX +#if defined(PATH_MAX) && !defined(__GLIBC__) pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */ #else pwd = getcwd(NULL, 0); |