Subject: Re: [PATCH v4 2/4] Makefile/coccicheck: speed up and fix bug with duplicate hunks

From: Junio C Hamano <[email-masked]>
Date: Mon, 22 Mar 2021 12:09:06 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> Change the coccicheck target to run on all of our *.c and *.h files
> with --include-headers-for-types, instead of trusting it to find *.h
> files and other includes to modify from its recursive walking of
> includes as it has been doing with only --all-includes.

Meaning '--all-includes' that is fed a C source would use all the
headers included (recursively) in it, but if we add the other
option, --include-headers-for-types, some *.h files are missed?

If so, the above explains both hunks in the patch well (although it
is unclear where that need to include *.h independently comes from,
e.g. if it is working around a bug in spatch that we may expect for
it to be fixed someday).

> diff --git a/Makefile b/Makefile
> index eef99b4705d..e43a9618df5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1199,7 +1199,8 @@ SPARSE_FLAGS ?=
>  SP_EXTRA_FLAGS = -Wno-universal-initializer
>  
>  # For the 'coccicheck' target
> -SPATCH_FLAGS = --all-includes --patch .
> +SPATCH_FLAGS = --all-includes --include-headers-for-types --patch .
> +
>  # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
>  # usually result in less CPU usage at the cost of higher peak memory.
>  # Setting it to 0 will feed all files in a single spatch invocation.
> @@ -2860,7 +2861,7 @@ check: config-list.h command-list.h
>  		exit 1; \
>  	fi
>  
> -FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES)))
> +FOUND_C_SOURCES = $(filter %.c %.h,$(shell $(FIND_SOURCE_FILES)))
>  COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES))
>  
>  %.cocci.patch: %.cocci $(COCCI_SOURCES)