[Top][All Lists]

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

Re: PATH_MAX on the Hurd

From: Paul Eggert
Subject: Re: PATH_MAX on the Hurd
Date: Fri, 05 Aug 2011 16:19:51 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20110617 Thunderbird/3.1.11

On 08/05/2011 03:33 PM, Bruno Haible wrote:
>>> int a = PATH_MAX;
>> >
>> > Shouldn't this be:
>> >
>> > static int a[PATH_MAX];
> Maybe. Or possibly:
>   enum { a = PATH_MAX };
> Are there cases when these three declarations don't all succeed and don't
> all fail?

Oh yes.  :-)

"int a = PATH_MAX;" would allow a float PATH_MAX, which presumably
you'd rather reject.  "static int a[PATH_MAX];" might warn you about
an array too large if PATH_MAX == SIZE_MAX; I'd make it "static char
a[PATH_MAX];".  "enum { a = PATH_MAX };" won't work if PATH_MAX
exceeds INT_MAX, and also it doesn't check that PATH_MAX is positive;
these problems are both fixable, but since the intended use of
PATH_MAX is likely array sizes, the array's probably your best bet.

reply via email to

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