diff mbox series

[1/2] libsepol: harden availability check against user CFLAGS

Message ID 20241120131004.58662-1-cgoettsche@seltendoof.de (mailing list archive)
State Accepted
Commit d49a3ecb43f5
Delegated to: Petr Lautrbach
Headers show
Series [1/2] libsepol: harden availability check against user CFLAGS | expand

Commit Message

Christian Göttsche Nov. 20, 2024, 1:10 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

If CFLAGS set by the user contains the warnings override
`-Wno-error=implicit-function-declaration` the availability check does
not work properly.  Explicitly enable and treat this warnings as failure
by appending the appropriate flag.

Also include CPPFLAGS in the check.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Carter Nov. 22, 2024, 9:20 p.m. UTC | #1
On Wed, Nov 20, 2024 at 8:10 AM Christian Göttsche
<cgoettsche@seltendoof.de> wrote:
>
> From: Christian Göttsche <cgzones@googlemail.com>
>
> If CFLAGS set by the user contains the warnings override
> `-Wno-error=implicit-function-declaration` the availability check does
> not work properly.  Explicitly enable and treat this warnings as failure
> by appending the appropriate flag.
>
> Also include CPPFLAGS in the check.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For these two patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/src/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile
> index 7b0e8446..71fa3ed7 100644
> --- a/libsepol/src/Makefile
> +++ b/libsepol/src/Makefile
> @@ -31,7 +31,7 @@ endif
>
>  # check for reallocarray(3) availability
>  H := \#
> -ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
> +ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
>  override CFLAGS += -DHAVE_REALLOCARRAY
>  endif
>
> --
> 2.45.2
>
>
James Carter Dec. 4, 2024, 2:30 p.m. UTC | #2
On Fri, Nov 22, 2024 at 4:20 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Wed, Nov 20, 2024 at 8:10 AM Christian Göttsche
> <cgoettsche@seltendoof.de> wrote:
> >
> > From: Christian Göttsche <cgzones@googlemail.com>
> >
> > If CFLAGS set by the user contains the warnings override
> > `-Wno-error=implicit-function-declaration` the availability check does
> > not work properly.  Explicitly enable and treat this warnings as failure
> > by appending the appropriate flag.
> >
> > Also include CPPFLAGS in the check.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> For these two patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

These two patches have been merged.
Thanks,
Jim


> > ---
> >  libsepol/src/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile
> > index 7b0e8446..71fa3ed7 100644
> > --- a/libsepol/src/Makefile
> > +++ b/libsepol/src/Makefile
> > @@ -31,7 +31,7 @@ endif
> >
> >  # check for reallocarray(3) availability
> >  H := \#
> > -ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
> > +ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
> >  override CFLAGS += -DHAVE_REALLOCARRAY
> >  endif
> >
> > --
> > 2.45.2
> >
> >
diff mbox series

Patch

diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile
index 7b0e8446..71fa3ed7 100644
--- a/libsepol/src/Makefile
+++ b/libsepol/src/Makefile
@@ -31,7 +31,7 @@  endif
 
 # check for reallocarray(3) availability
 H := \#
-ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
+ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
 override CFLAGS += -DHAVE_REALLOCARRAY
 endif