On 06/18/2011 02:22 PM, Bruno Haible wrote:
> Hi,
> 
> On HP-UX 11.31 I'm seeing this compilation failure:
> 
> cc -Ae -D_XOPEN_SOURCE=500 -O -DHAVE_CONFIG_H -I.  -DGNULIB_STRICT_CHECKING=1 
> -I. -I. -I.. -I./.. -I../gllib -I./../gllib 
> -I/home/haible/prefix-hpux113-cc/include  -g -c -o test-getcwd.o test-getcwd.c
> cc: "test-getcwd.c", line 53: error 1588: "PATH_MAX" undefined.
> cc: "test-getcwd.c", line 53: error 1563: Expression in if must be scalar.
> gmake[4]: *** [test-getcwd.o] Error 1
> 
> PATH_MAX on HP-UX 11.31 is
>   1) not defined if _XOPEN_SOURCE is defined to 500 or greater,
>   2) otherwise defined to 1023, with a comment saying
>      "max number of characters in a pathname (not including terminating null)"
> 
> Apparently the reason is that POSIX specifies that PATH_MAX needs to include
> the terminating NUL, but HP-UX PATH_MAX traditionally does not include it.
> So they chose to remove PATH_MAX from their headers.
> 
> Here is a proposed patch. The second patch is obvious, I'm committing it
> directly.

Actually, I agree with the first:

> 
> 
> 2011-06-18  Bruno Haible  <br...@clisp.org>
> 
>       pathmax: Ensure correct value for PATH_MAX on HP-UX.
>       * lib/pathmax.h (PATH_MAX) [HP-UX]: Define to 1024.
> 

But dislike the second:

> 
> 2011-06-18  Bruno Haible  <br...@clisp.org>
> 
>       getcwd tests: Avoid compilation error on HP-UX 11.31.
>       * modules/getcwd-tests (Depends-on): Add pathmax.
>       * tests/test-getcwd.c: Include pathmax.h.

pathmax.h guarantees that PATH_MAX will be defined (even if it is to a
non-constant value), which is in contrast to <limits.h> that only
defines it if it is constant.  But later on in test-getcwd, we have code
that does #ifndef PATH_MAX, which is no longer reachable because of our
guarantee that PATH_MAX is always defined in pathmax.h.

I think we need to revert this test, and instead fix the program to not
use PATH_MAX without first checking for its definition; we also need to
avoid a stack-allocation of PATH_MAX bytes.

Patch coming up.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to