[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 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?

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)


Reply to: