From d80aff0ae74993962a24f205a356ffae59eab5be Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 20 Jun 2011 15:12:10 -0600 Subject: [PATCH] test-stat: don't allocate PATH_MAX bytes POSIX allows systems (like Hurd) that don't define PATH_MAX, or which define it larger than a reasonable stack allocation should be. The test originally used stack allocation to avoid portability problems with getcwd, but the getcwd-lgpl module solves those. * tests/test-stat.h (test_stat_func): Don't stack-allocate a PATH_MAX-sized buffer. * modules/openat-tests (Depends-on): Add getcwd-lgpl, drop pathmax. * modules/stat-tests (Depends-on): Likewise. * tests/test-fstatat.c (includes): Drop pathmax.h. * tests/test-stat.c (includes): Likewise. Reported by Bruno Haible. Signed-off-by: Eric Blake --- ChangeLog | 11 +++++++++++ modules/openat-tests | 2 +- modules/stat-tests | 2 +- tests/test-fstatat.c | 1 - tests/test-stat.c | 1 - tests/test-stat.h | 4 ++-- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7fe901724..1758d670f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-06-20 Eric Blake + + test-stat: don't allocate PATH_MAX bytes + * tests/test-stat.h (test_stat_func): Don't stack-allocate a + PATH_MAX-sized buffer. + * modules/openat-tests (Depends-on): Add getcwd-lgpl, drop pathmax. + * modules/stat-tests (Depends-on): Likewise. + * tests/test-fstatat.c (includes): Drop pathmax.h. + * tests/test-stat.c (includes): Likewise. + Reported by Bruno Haible. + 2011-06-20 Bruno Haible float: Work around bugs on FreeBSD/x86, AIX with GCC, IRIX. diff --git a/modules/openat-tests b/modules/openat-tests index 8b0a2b9e8..b83fb721d 100644 --- a/modules/openat-tests +++ b/modules/openat-tests @@ -16,9 +16,9 @@ tests/signature.h tests/macros.h Depends-on: +getcwd-lgpl ignore-value mgetgroups -pathmax progname usleep stat-time diff --git a/modules/stat-tests b/modules/stat-tests index 74d558c8d..9c00ce54d 100644 --- a/modules/stat-tests +++ b/modules/stat-tests @@ -5,7 +5,7 @@ tests/signature.h tests/macros.h Depends-on: -pathmax +getcwd-lgpl same-inode stdbool symlink diff --git a/tests/test-fstatat.c b/tests/test-fstatat.c index dda0cd224..aef113655 100644 --- a/tests/test-fstatat.c +++ b/tests/test-fstatat.c @@ -31,7 +31,6 @@ SIGNATURE_CHECK (fstatat, int, (int, char const *, struct stat *, int)); #include #include "openat.h" -#include "pathmax.h" #include "progname.h" #include "same-inode.h" #include "ignore-value.h" diff --git a/tests/test-stat.c b/tests/test-stat.c index 4cda08908..cd74491f0 100644 --- a/tests/test-stat.c +++ b/tests/test-stat.c @@ -33,7 +33,6 @@ SIGNATURE_CHECK (stat, int, (char const *, struct stat *)); #include #include -#include "pathmax.h" #include "same-inode.h" #include "macros.h" diff --git a/tests/test-stat.h b/tests/test-stat.h index 22552dce0..3c8f7add0 100644 --- a/tests/test-stat.h +++ b/tests/test-stat.h @@ -27,9 +27,9 @@ test_stat_func (int (*func) (char const *, struct stat *), bool print) { struct stat st1; struct stat st2; - char cwd[PATH_MAX]; + char *cwd = getcwd (NULL, 0); - ASSERT (getcwd (cwd, PATH_MAX) == cwd); + ASSERT (cwd); ASSERT (func (".", &st1) == 0); ASSERT (func ("./", &st2) == 0); ASSERT (SAME_INODE (st1, st2)); -- 2.11.0