Re: [PATCH v3 2/4] compat/regex: move stdlib.h up in inclusion chain

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

 




On 27/04/2020 15:22, Đoàn Trần Công Danh wrote:
> In Linux with musl libc, we have this inclusion chain:
> 
> compat/regex/regex.c:69
> `-> compat/regex/regex_internal.h
>    `-> /usr/include/stdlib.h
>       `-> /usr/include/features.h
>       `-> /usr/include/alloca.h
> 
> In that inclusion chain, `<features.h>` claims it's _BSD_SOURCE
> compatible when it's NOT asked to be either
> {_POSIX,_GNU,_XOPEN,_BSD}_SOURCE, or __STRICT_ANSI__.
> And, `<stdlib.h>` will include `<alloca.h>` to be compatible with
> software written for GNU and BSD. Thus, redefine `alloca` macro,
> which was defined before at compat/regex/regex.c:66.
> 
> Considering this is only compat code, we've taken from other project,
> it's not our business to decide which source should we adhere to.
> 
> Include `<stdlib.h>` early to prevent the redefinition of alloca.
> This also remove a potential warning about alloca not defined on:
> 	#undef alloca
> 
> Helped-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@xxxxxxxxx>
> ---
> 
> Notes:
>     There is another warning about un-match declaration and definition of
>     re_string_context_at.
>     
>     It's arguably, a bug in sparse itself.
>     Consider that there's a fix for it in their development version already,
>     and, we expect they'll fix the zero-ing pattern in 1/? before enable it again.

Ahem, yes I still haven't found time to find that patch yet.
Sorry about that. :(

>     There're no point to change that pair of declaration/definition.
> 
>     This patch is technically Ramsay's work.
>     Since <alloca.h> is likely unportable, my patch will be likely unusable.
>     I took Ramsay's work and write the commit message instead.
> 
>     I would love to see Ramsay's SoB on reply to this patch.

I think 'Helped-by:' is all that is necessary (you did the hard work,
including testing on musl-libc), but if you prefer:

Signed-off-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx>

ATB,
Ramsay Jones

> 
>  compat/regex/regex.c          | 1 +
>  compat/regex/regex_internal.h | 1 -
>  2 files changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/compat/regex/regex.c b/compat/regex/regex.c
> index f3e03a9eab..e6f4a5d177 100644
> --- a/compat/regex/regex.c
> +++ b/compat/regex/regex.c
> @@ -60,6 +60,7 @@
>     #undefs RE_DUP_MAX and sets it to the right value.  */
>  #include <limits.h>
>  #include <stdint.h>
> +#include <stdlib.h>
>  
>  #ifdef GAWK
>  #undef alloca
> diff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h
> index 3ee8aae59d..0bad8b841e 100644
> --- a/compat/regex/regex_internal.h
> +++ b/compat/regex/regex_internal.h
> @@ -23,7 +23,6 @@
>  #include <assert.h>
>  #include <ctype.h>
>  #include <stdio.h>
> -#include <stdlib.h>
>  #include <string.h>
>  
>  #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
> 



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux