diff mbox series

Makefile: fix conditional around sparse

Message ID 20250201012936.2816101-1-gwendal@chromium.org (mailing list archive)
State New
Headers show
Series Makefile: fix conditional around sparse | expand

Commit Message

Gwendal Grignou Feb. 1, 2025, 1:29 a.m. UTC
sparse would always be invoked, since `ifdef C` is always true afet `C ?= xx`.
Instead, use ifeq to check if C is 0 or 1.

Fixes f884bfe684f ("mmc-utils: Make functions static for local scope enforcement")

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Avri Altman Feb. 1, 2025, 7:07 a.m. UTC | #1
Hi,
> 
> sparse would always be invoked, since `ifdef C` is always true afet `C ?= xx`.
> Instead, use ifeq to check if C is 0 or 1.
> 
> Fixes f884bfe684f ("mmc-utils: Make functions static for local scope
> enforcement")
The commit log of the above say:
" Run Sparse and fix its warnings.  Apparently, running make C=1 is rarely
    done, so make running sparse default."

So this was intentional.
You need to provide further reasoning why you want to revert it.
You also forgot to sign your commit.

Thanks,
Avri

> 
> ---
>  Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 06ae0f7..c0284bb 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -27,14 +27,14 @@ progs = mmc
> 
>  # make C=1 to enable sparse - default
>  C ?= 1
> -ifdef C
> +ifeq "$(C)" "1"
>         check = sparse $(CHECKFLAGS) $(AM_CFLAGS)  endif
> 
>  all: $(progs)
> 
>  .c.o:
> -ifdef C
> +ifeq "$(C)" "1"
>         $(check) $<
>  endif
>         $(CC) $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
> --
> 2.48.1.362.g079036d154-goog
Gwendal Grignou Feb. 3, 2025, 5:29 p.m. UTC | #2
On Fri, Jan 31, 2025 at 11:07 PM Avri Altman <Avri.Altman@wdc.com> wrote:
>
> Hi,
> >
> > sparse would always be invoked, since `ifdef C` is always true afet `C ?= xx`.
> > Instead, use ifeq to check if C is 0 or 1.
> >
> > Fixes f884bfe684f ("mmc-utils: Make functions static for local scope
> > enforcement")
> The commit log of the above say:
> " Run Sparse and fix its warnings.  Apparently, running make C=1 is rarely
>     done, so make running sparse default."
>
> So this was intentional.
> You need to provide further reasoning why you want to revert it.
This patch is not a revert. It ensures that when `make C=0` is
invoked, sparse is not called.

> You also forgot to sign your commit.
Added in v2.
>
> Thanks,
> Avri
>
> >
> > ---
> >  Makefile | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 06ae0f7..c0284bb 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -27,14 +27,14 @@ progs = mmc
> >
> >  # make C=1 to enable sparse - default
> >  C ?= 1
> > -ifdef C
> > +ifeq "$(C)" "1"
> >         check = sparse $(CHECKFLAGS) $(AM_CFLAGS)  endif
> >
> >  all: $(progs)
> >
> >  .c.o:
> > -ifdef C
> > +ifeq "$(C)" "1"
> >         $(check) $<
> >  endif
> >         $(CC) $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
> > --
> > 2.48.1.362.g079036d154-goog
>
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 06ae0f7..c0284bb 100644
--- a/Makefile
+++ b/Makefile
@@ -27,14 +27,14 @@  progs = mmc
 
 # make C=1 to enable sparse - default
 C ?= 1
-ifdef C
+ifeq "$(C)" "1"
 	check = sparse $(CHECKFLAGS) $(AM_CFLAGS)
 endif
 
 all: $(progs)
 
 .c.o:
-ifdef C
+ifeq "$(C)" "1"
 	$(check) $<
 endif
 	$(CC) $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) -c $< -o $@