bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATH_MAX on HP-UX


From: Eric Blake
Subject: Re: PATH_MAX on HP-UX
Date: Mon, 20 Jun 2011 15:35:42 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

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  <address@hidden>
> 
>       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  <address@hidden>
> 
>       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   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]