All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] build: Fix make warning if there is no cppcheck
@ 2022-05-20 10:49 Bertrand Marquis
  2022-05-20 11:06 ` Jan Beulich
  2022-05-20 12:02 ` Julien Grall
  0 siblings, 2 replies; 4+ messages in thread
From: Bertrand Marquis @ 2022-05-20 10:49 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Jan Beulich, Julien Grall,
	Stefano Stabellini, Wei Liu

If cppcheck is not present, the following warning appears during build:
which: no cppcheck in ([...])
/bin/sh: cppcheck: command not found

Fix this by hiding the error output from which and only try to execute
cppcheck --version if we have a cppcheck.

Reported-by: Julien Grall <julien@xen.org>
Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index 15388703bc..f42be3d0ab 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -694,12 +694,13 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
 	$(call if_changed,cppcheck_xml)
 
 cppcheck-version:
-ifeq ($(shell which $(CPPCHECK)),)
+ifeq ($(shell which $(CPPCHECK) 2> /dev/null),)
 	$(error Cannot find cppcheck executable: $(CPPCHECK))
-endif
+else
 ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
 	$(error Please upgrade your cppcheck to version 2.7 or greater)
 endif
+endif
 
 # Put this in generated headers this way it is cleaned by include/Makefile
 $(objtree)/include/generated/compiler-def.h:
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] build: Fix make warning if there is no cppcheck
  2022-05-20 10:49 [PATCH] build: Fix make warning if there is no cppcheck Bertrand Marquis
@ 2022-05-20 11:06 ` Jan Beulich
  2022-05-20 12:10   ` Bertrand Marquis
  2022-05-20 12:02 ` Julien Grall
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2022-05-20 11:06 UTC (permalink / raw)
  To: Bertrand Marquis
  Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
	Wei Liu, xen-devel

On 20.05.2022 12:49, Bertrand Marquis wrote:
> --- a/xen/Makefile
> +++ b/xen/Makefile
> @@ -694,12 +694,13 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
>  	$(call if_changed,cppcheck_xml)
>  
>  cppcheck-version:
> -ifeq ($(shell which $(CPPCHECK)),)
> +ifeq ($(shell which $(CPPCHECK) 2> /dev/null),)
>  	$(error Cannot find cppcheck executable: $(CPPCHECK))
> -endif
> +else
>  ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
>  	$(error Please upgrade your cppcheck to version 2.7 or greater)
>  endif
> +endif

While I agree this will silence things, I still would prefer if you
switched to $(if ...) inside the rule - there's no need to invoke the
shell while parsing the makefile. Anything like this only needlessly
slows down the build. Not by much, but it sums up.

Jan



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] build: Fix make warning if there is no cppcheck
  2022-05-20 10:49 [PATCH] build: Fix make warning if there is no cppcheck Bertrand Marquis
  2022-05-20 11:06 ` Jan Beulich
@ 2022-05-20 12:02 ` Julien Grall
  1 sibling, 0 replies; 4+ messages in thread
From: Julien Grall @ 2022-05-20 12:02 UTC (permalink / raw)
  To: Bertrand Marquis, xen-devel
  Cc: Andrew Cooper, George Dunlap, Jan Beulich, Stefano Stabellini, Wei Liu

Hi Bertrand,

On 20/05/2022 11:49, Bertrand Marquis wrote:
> If cppcheck is not present, the following warning appears during build:
> which: no cppcheck in ([...])
> /bin/sh: cppcheck: command not found
> 
> Fix this by hiding the error output from which and only try to execute
> cppcheck --version if we have a cppcheck.
> 
> Reported-by: Julien Grall <julien@xen.org>
> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>

This solves the warning so:

Acked-by: Julien Grall <jgrall@amazon.com>

In the long term, I think using what Jan suggested would be better.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] build: Fix make warning if there is no cppcheck
  2022-05-20 11:06 ` Jan Beulich
@ 2022-05-20 12:10   ` Bertrand Marquis
  0 siblings, 0 replies; 4+ messages in thread
From: Bertrand Marquis @ 2022-05-20 12:10 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
	Wei Liu, xen-devel

Hi Jan,

> On 20 May 2022, at 12:06, Jan Beulich <jbeulich@suse.com> wrote:
> 
> On 20.05.2022 12:49, Bertrand Marquis wrote:
>> --- a/xen/Makefile
>> +++ b/xen/Makefile
>> @@ -694,12 +694,13 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
>> 	$(call if_changed,cppcheck_xml)
>> 
>> cppcheck-version:
>> -ifeq ($(shell which $(CPPCHECK)),)
>> +ifeq ($(shell which $(CPPCHECK) 2> /dev/null),)
>> 	$(error Cannot find cppcheck executable: $(CPPCHECK))
>> -endif
>> +else
>> ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
>> 	$(error Please upgrade your cppcheck to version 2.7 or greater)
>> endif
>> +endif
> 
> While I agree this will silence things, I still would prefer if you
> switched to $(if ...) inside the rule - there's no need to invoke the
> shell while parsing the makefile. Anything like this only needlessly
> slows down the build. Not by much, but it sums up.

I will submit a v2 to solve this properly.

Cheers
Bertrand

> 
> Jan
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-20 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 10:49 [PATCH] build: Fix make warning if there is no cppcheck Bertrand Marquis
2022-05-20 11:06 ` Jan Beulich
2022-05-20 12:10   ` Bertrand Marquis
2022-05-20 12:02 ` Julien Grall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.