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

Re: [PATCH 2/2] compat/*.[ch]: remove extern from function declarations using spatch

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Sep 9, 2019, 18:58 UTC
Message-ID
<nycvar.QRO.7.76.6.1909092058020.5377@tvgsbejvaqbjf.bet>
In-Reply-To
<20190905032317.GA1381@archbookpro.localdomain>
Hi Denton,
On Wed, 4 Sep 2019, Denton Liu wrote:
Show 55 quoted lines
> On Wed, Sep 04, 2019 at 11:43:06PM +0200, Johannes Schindelin wrote:
> >
> > On Wed, 4 Sep 2019, Denton Liu wrote:
> >
> > > In 554544276a (*.[ch]: remove extern from function declarations using
> > > spatch, 2019-04-29), we removed externs from function declarations using
> > > spatch but we intentionally excluded files under compat/ since some are
> > > directly copied from an upstream and we should avoid churning them so
> > > that manually merging future updates will be simpler.
> > >
> > > In the last commit, we determined the files which taken from an upstream
> > > so we can exclude them and run spatch on the remainder.
> > >
> > > This was the Coccinelle patch used:
> > >
> > > 	@@
> > > 	type T;
> > > 	identifier f;
> > > 	@@
> > > 	- extern
> > > 	  T f(...);
> > >
> > > and it was run with:
> > >
> > > 	$ git ls-files compat/\*\*.{c,h} |
> > > 		xargs spatch --sp-file contrib/coccinelle/noextern.cocci --in-place
> > > 	$ git checkout -- \
> > > 		compat/regex/ \
> > > 		compat/inet_ntop.c \
> > > 		compat/inet_pton.c \
> > > 		compat/nedmalloc/ \
> > > 		compat/obstack.{c,h} \
> > > 		compat/poll/
> > >
> > > Coccinelle has some trouble dealing with `__attribute__` and varargs so
> > > we ran the following to ensure that no remaining changes were left
> > > behind:
> > >
> > > 	$ git ls-files compat/\*\*.{c,h} |
> > > 		xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/'
> > > 	$ git checkout -- \
> > > 		compat/regex/ \
> > > 		compat/inet_ntop.c \
> > > 		compat/inet_pton.c \
> > > 		compat/nedmalloc/ \
> > > 		compat/obstack.{c,h} \
> > > 		compat/poll/
> >
> > I wonder whether we want to make this part of the (slightly misnamed)
> > "Static Analysis" job in our CI.
>
> Do you mean running cocci on all of our source files as opposed to just
> the files we compile? These two patches are part of an experimental (and
> unsubmitted) patchset that does exactly that. Seeing that there's
> interest, I'll try to send it in soon.

I look forward to it! Dscho

Previous: Denton Liu
Message 8 of 8 in “cleanup compat/ sources using spatch”
  1. 0/2 cleanup compat/ sources using spatchDenton Liu, Sep 4, 2019
  2. 1/2 mingw: apply array.cocci ruleDenton Liu, Sep 4, 2019
  3. Johannes SchindelinSep 4, 2019
  4. Junio C HamanoSep 4, 2019
  5. 2/2 compat/*.[ch]: remove extern from function declarations using spatchDenton Liu, Sep 4, 2019
  6. Johannes SchindelinSep 4, 2019
  7. Denton LiuSep 5, 2019
  8. Johannes SchindelinSep 9, 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.