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

Re: [PATCH 7/7] libbb.h: Handle missing HOST_NAME_MAX; ensure MAXFOOLEN agrees with FOO_MAX



On 8 Oct 2017, at 02:40, Kang-Che Sung <explorer09@gmail.com> wrote:
> On Sun, Oct 8, 2017 at 1:53 AM, James Clarke <jrtc27@jrtc27.com> wrote:
>> Signed-off-by: James Clarke <jrtc27@jrtc27.com>
>> ---
>> include/libbb.h | 19 ++++++++++++++++++-
>> 1 file changed, 18 insertions(+), 1 deletion(-)
>> 
>> diff --git a/include/libbb.h b/include/libbb.h
>> index daccf154a..56f4f4cb3 100644
>> --- a/include/libbb.h
>> +++ b/include/libbb.h
>> @@ -181,7 +181,24 @@ extern char **environ;
>> /* klogctl is in libc's klog.h, but we cheat and not #include that */
>> int klogctl(int type, char *b, int len);
>> #ifndef PATH_MAX
>> -# define PATH_MAX 256
>> +# ifdef MAXPATHLEN
>> +#  define PATH_MAX MAXPATHLEN
>> +# else
>> +#  define PATH_MAX 256
>> +# endif
>> +#endif
>> +#ifndef MAXPATHLEN
>> +# define MAXPATHLEN PATH_MAX
>> +#endif
>> +#ifndef HOST_NAME_MAX
>> +# ifdef MAXHOSTNAMELEN
>> +#  define HOST_NAME_MAX MAXHOSTNAMELEN
>> +# else
>> +#  define HOST_NAME_MAX 256
>> +# endif
>> +#endif
>> +#ifndef MAXHOSTNAMELEN
>> +# define MAXHOSTNAMELEN HOST_NAME_MAX
>> #endif
>> #ifndef BUFSIZ
>> # define BUFSIZ 4096
> 
> 
> Um, why do we need to define MAXPATHLEN and MAXHOSTNAMELEN where there have
> been no use in BusyBox, and there have been standard macros available?

That's not actually true (any more); util-linux/fdisk_osf.c, whilst
Linux-specific, does use MAXPATHLEN, and networking/traceroute.c uses
MAXHOSTNAMELEN. These could be changed to use {PATH,HOST_NAME}_MAX, but it's
highly likely that a future change will re-introduce a use of one of those
macros and break the build on the Hurd, so why not just define them?

> While we are at it, could you also please change the HOST_NAME_MAX fallback
> definition to 255? 255 is the POSIX defined minimum.
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
> (see _POSIX_HOST_NAME_MAX value)

Ok, that makes sense. I will do so in the next revision.

Regards,
James


Reply to: