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

Re: [PATCH] avoid assuming MAXPATHLEN in config(8)



2011/7/7 Ed Schouten <ed@80386.nl>:
> * Robert Millan <rmh@debian.org>, 20110707 11:33:
>> config(8) assumes MAXPATHLEN is defined in a few places, but presence
>> of this macro isn't garanteed (POSIX says that it is only present when
>> a file length limit exists, which may not be the case).
>
> Even though it is good to make our code conform to standards as much as
> possible, do keep in mind that your patch also causes a lot of
> regressions in that area. The code now uses asprintf(), which is not
> part of POSIX. I also think the use of __GLIBC__ is frowned upon.

Uhm... you're right.  Actually I knew asprintf() is not part of POSIX,
it just didn't occur to me that this contradicted my point about
MAXPATHLEN [1].

As for the __GLIBC__ bit, it is difficult to handle this without a
function that canonicalizes arbitrary-length pathnames.  Would you
prefer something like:

#ifdef MAXPATHLEN
// use realpath on a statically-allocated buffer
#else
// assume canonicalize_file_name() is present
#endif

[1] Btw, POSIX itself is quite contradictory too: it doesn't let you
assume MAXPATHLEN, but it doesn't give you the facilities you need in
case it isn't present (e.g. asprintf and canonicalize_file_name but
gethostname and getline / fgetln come to mind too).

-- 
Robert Millan


Reply to: