git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] Makefile: run coccicheck on more source files

From
Denton Liu <liu.denton@gmail.com>
Date
Sep 10, 2019, 16:07 UTC
Message-ID
<20190910160702.GA111040@archbookpro.localdomain>
In-Reply-To
<20190910132813.GJ32087@szeder.dev>
On Tue, Sep 10, 2019 at 03:28:13PM +0200, SZEDER Gábor wrote:
Show 53 quoted lines
> On Tue, Sep 10, 2019 at 12:44:31AM -0700, Denton Liu wrote:
> > Before, when running the "coccicheck" target, only the source files
> > which were being compiled would have been checked by Coccinelle.
> > However, just because we aren't compiling a source file doesn't mean we
> > have to exclude it from analysis. This will allow us to catch more
> > mistakes, in particular ones that affect Windows-only sources since
> > Coccinelle currently runs only on Linux.
> > 
> > Make the "coccicheck" target run on all C sources except for those that
> > are taken from some upstream. We don't want to patch these files since
> > we want them to be as close to upstream as possible so that it'll be
> > easier to pull in upstream updates.
> > 
> > This results in the following sources now being checked:
> > 
> > * block-sha1/sha1.c
> > * compat/access.c
> > * compat/basename.c
> > * compat/fileno.c
> > * compat/gmtime.c
> > * compat/hstrerror.c
> > * compat/memmem.c
> > * compat/mingw.c
> 
> When applying 'array.cocci' to 'compat/mingw.c' Coccinelle 1.0.4 (the
> version shipped in Ubuntu 16.04, i.e. what is used in our static
> analysis CI job) suggests to use the COPY_ARRAY macro instead of
> memcpy():
> 
> diff -u -p a/compat/mingw.c b/compat/mingw.c
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1265,7 +1265,7 @@ static wchar_t *make_environment_block(c
>  		}
>  
>  		ALLOC_ARRAY(result, size);
> -		memcpy(result, wenv, size * sizeof(*wenv));
> +		COPY_ARRAY(result, wenv, size);
>  		FreeEnvironmentStringsW(wenv);
>  		return result;
>  	}
> @@ -1309,7 +1309,7 @@ static wchar_t *make_environment_block(c
>  			continue;
>  
>  		size = wcslen(array[i]) + 1;
> -		memcpy(p, array[i], size * sizeof(*p));
> +		COPY_ARRAY(p, array[i], size);
>  		p += size;
>  	}
>  	*p = L'\0';
> 
> This patch series should apply these suggestions in preparatory
> patches to make sure that our CI builds still pass.

This patch series depends on the "dl/compat-cleanup" branch, which should've already made these changes.

Show 33 quoted lines
> 
> > * compat/mkdir.c
> > * compat/mkdtemp.c
> > * compat/mmap.c
> > * compat/msvc.c
> > * compat/pread.c
> > * compat/precompose_utf8.c
> > * compat/qsort.c
> > * compat/setenv.c
> > * compat/sha1-chunked.c
> > * compat/snprintf.c
> > * compat/stat.c
> > * compat/strcasestr.c
> > * compat/strdup.c
> > * compat/strtoimax.c
> > * compat/strtoumax.c
> > * compat/unsetenv.c
> > * compat/win32/dirent.c
> > * compat/win32/path-utils.c
> > * compat/win32/pthread.c
> > * compat/win32/syslog.c
> > * compat/win32/trace2_win32_process_info.c
> > * compat/win32mmap.c
> > * compat/winansi.c
> > * ppc/sha1.c
> > 
> > This also results in the following source now being excluded:
> > 
> > * compat/obstack.c
> 
> Why mention this file here, and, more importantly, why mention _only_
> this file here?  According to the previous patch, there should be a
> few more excluded files...

I guess this commit message is pretty weak since this only really applies to my system. I'll mention in a reroll that this was for a standard build with no additional flags on Arch Linux to be specific.

I got these lists by dumping the contents of $(COCCI_SOURCES) before and after applying the patch and, with my "standard" build, it seems like the only upstream file that was being checked before was compat/obstack.c.

I don't have build options like, for example, NO_REGEX enabled so the regex stuff wasn't being built in the first place but for users that might want to run coccicheck on such a platform (do they even exist?), this would benefit them.

Show 28 quoted lines
> 
> > Signed-off-by: Denton Liu <liu.denton@gmail.com>
> > ---
> >  Makefile | 8 ++------
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index 708df2c289..d468b7c9c4 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -2802,12 +2802,8 @@ check: command-list.h
> >  		exit 1; \
> >  	fi
> >  
> > -C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))
> > -ifdef DC_SHA1_SUBMODULE
> > -COCCI_SOURCES = $(filter-out sha1collisiondetection/%,$(C_SOURCES))
> > -else
> > -COCCI_SOURCES = $(filter-out sha1dc/%,$(C_SOURCES))
> > -endif
> > +FIND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES)))
> > +COCCI_SOURCES = $(filter-out $(UPSTREAM_SOURCES),$(FIND_C_SOURCES))
> >  
> >  %.cocci.patch: %.cocci $(COCCI_SOURCES)
> >  	@echo '    ' SPATCH $<; \
> > -- 
> > 2.23.0.248.g3a9dd8fb08
> > 
Previous: SZEDER GáborNext: SZEDER Gábor
Message 5 of 29 in “Makefile: run coccicheck on all non-upstream sources”
  1. 0/2 Makefile: run coccicheck on all non-upstream sourcesDenton Liu, Sep 10, 2019
  2. 1/2 Makefile: define UPSTREAM_SOURCESDenton Liu, Sep 10, 2019
  3. 2/2 Makefile: run coccicheck on more source filesDenton Liu, Sep 10, 2019
  4. SZEDER GáborSep 10, 2019
  5. Denton LiuSep 10, 2019
  6. SZEDER GáborSep 10, 2019
  7. 0/3 Makefile: run coccicheck on all non-upstream sourcesDenton Liu, Sep 12, 2019
  8. 1/3 Makefile: define THIRD_PARTY_SOURCESDenton Liu, Sep 12, 2019
  9. Junio C HamanoSep 12, 2019
  10. 2/3 Makefile: strip leading ./ in $(FIND_SOURCE_FILES)Denton Liu, Sep 12, 2019
  11. Junio C HamanoSep 12, 2019
  12. SZEDER GáborSep 13, 2019
  13. 3/3 Makefile: run coccicheck on more source filesDenton Liu, Sep 12, 2019
  14. Junio C HamanoSep 12, 2019
  15. SZEDER GáborSep 13, 2019
  16. Denton LiuSep 13, 2019
  17. SZEDER GáborSep 13, 2019
  18. Denton LiuSep 13, 2019
  19. Junio C HamanoSep 13, 2019
  20. 0/4 Makefile: run coccicheck on all non-upstream sourcesDenton Liu, Sep 16, 2019
  21. 1/4 Makefile: strip leading ./ in $(LIB_H)Denton Liu, Sep 16, 2019
  22. 2/4 Makefile: define THIRD_PARTY_SOURCESDenton Liu, Sep 16, 2019
  23. Junio C HamanoSep 16, 2019
  24. fixup! Makefile: define THIRD_PARTY_SOURCESDenton Liu, Sep 16, 2019
  25. 3/4 Makefile: strip leading ./ in $(FIND_SOURCE_FILES)Denton Liu, Sep 16, 2019
  26. 4/4 Makefile: run coccicheck on more source filesDenton Liu, Sep 16, 2019
  27. Junio C HamanoSep 16, 2019
  28. SZEDER GáborSep 17, 2019
  29. Junio C HamanoSep 17, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.