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

[RFC PATCH] Makefile: create externcheck target

From
Denton Liu <liu.denton@gmail.com>
Date
Oct 8, 2020, 07:30 UTC
Message-ID
<1c2ee1c40ccde18a008262aeaf23a17da2064eae.1602142232.git.liu.denton@gmail.com>
In-Reply-To
<9e5a8625cab217bd6aaba68da081bc801354b903.1602059508.git.liu.denton@gmail.com>

In b199d7147a (*.[ch]: remove extern from function declarations using sed, 2019-04-29), we used sed to remove extern from function definitions. In order to help find and remove future instances of this, teach Makefile the `externcheck` target which runs the sed script included in that commit on all applicable source files.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
Notes:
    I run this target periodically to ensure that no new instances of extern
    function definitions are introduced. Is this something that we want to
    consider adding for real?
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index 5311b1d2c4..791faa24cf 100644
--- a/Makefile
+++ b/Makefile
@@ -2885,6 +2885,9 @@ COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES))
 	fi
 coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/coccinelle/*.cocci)))
 
+externcheck: $(filter-out $(THIRD_PARTY_SOURCES),$(filter %.c %.h,$(shell $(FIND_SOURCE_FILES))))
+	sed -i 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/' $^
+
 # See contrib/coccinelle/README
 coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci))
 
-- 
2.29.0.rc0.261.g7178c9af9c
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 7 in “compat/mingw.h: drop extern from function declaration”
  1. compat/mingw.h: drop extern from function declarationDenton Liu, Oct 7, 2020
  2. Johannes SchindelinOct 7, 2020
  3. Makefile: create externcheck targetDenton Liu, Oct 8, 2020
  4. Johannes SchindelinOct 8, 2020
  5. Denton LiuOct 8, 2020
  6. Johannes SchindelinOct 8, 2020
  7. Junio C HamanoOct 9, 2020

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.