Skip to content

Commit 3f84633

Browse files
committed
Merge branch 'dl/cocci-everywhere'
Coccinelle checks are done on more source files than before now. * dl/cocci-everywhere: Makefile: run coccicheck on more source files Makefile: strip leading ./ in $(FIND_SOURCE_FILES) Makefile: define THIRD_PARTY_SOURCES Makefile: strip leading ./ in $(LIB_H)
2 parents caf150c + 9027af5 commit 3f84633

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

Makefile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ SCRIPT_SH =
598598
SCRIPT_LIB =
599599
TEST_BUILTINS_OBJS =
600600
TEST_PROGRAMS_NEED_X =
601+
THIRD_PARTY_SOURCES =
601602

602603
# Having this variable in your environment would break pipelines because
603604
# you cause "cd" to echo its destination to stdout. It can also take
@@ -818,12 +819,12 @@ VCSSVN_LIB = vcs-svn/lib.a
818819

819820
GENERATED_H += command-list.h
820821

821-
LIB_H := $(sort $(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \
822+
LIB_H := $(sort $(patsubst ./%,%,$(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \
822823
$(FIND) . \
823824
-name .git -prune -o \
824825
-name t -prune -o \
825826
-name Documentation -prune -o \
826-
-name '*.h' -print))
827+
-name '*.h' -print)))
827828

828829
LIB_OBJS += abspath.o
829830
LIB_OBJS += advice.o
@@ -1146,6 +1147,20 @@ BUILTIN_OBJS += builtin/verify-tag.o
11461147
BUILTIN_OBJS += builtin/worktree.o
11471148
BUILTIN_OBJS += builtin/write-tree.o
11481149

1150+
# THIRD_PARTY_SOURCES is a list of patterns compatible with the
1151+
# $(filter) and $(filter-out) family of functions. They specify source
1152+
# files which are taken from some third-party source where we want to be
1153+
# less strict about issues such as coding style so we don't diverge from
1154+
# upstream unnecessarily (making merging in future changes easier).
1155+
THIRD_PARTY_SOURCES += compat/inet_ntop.c
1156+
THIRD_PARTY_SOURCES += compat/inet_pton.c
1157+
THIRD_PARTY_SOURCES += compat/nedmalloc/%
1158+
THIRD_PARTY_SOURCES += compat/obstack.%
1159+
THIRD_PARTY_SOURCES += compat/poll/%
1160+
THIRD_PARTY_SOURCES += compat/regex/%
1161+
THIRD_PARTY_SOURCES += sha1collisiondetection/%
1162+
THIRD_PARTY_SOURCES += sha1dc/%
1163+
11491164
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB)
11501165
EXTLIBS =
11511166

@@ -2600,6 +2615,7 @@ FIND_SOURCE_FILES = ( \
26002615
-o \( -name 'trash*' -type d -prune \) \
26012616
-o \( -name '*.[hcS]' -type f -print \) \
26022617
-o \( -name '*.sh' -type f -print \) \
2618+
| sed -e 's|^\./||' \
26032619
)
26042620

26052621
$(ETAGS_TARGET): FORCE
@@ -2769,7 +2785,7 @@ EXCEPT_HDRS := $(GEN_HDRS) compat/% xdiff/%
27692785
ifndef GCRYPT_SHA256
27702786
EXCEPT_HDRS += sha256/gcrypt.h
27712787
endif
2772-
CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(patsubst ./%,%,$(LIB_H)))
2788+
CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(LIB_H))
27732789
HCO = $(patsubst %.h,%.hco,$(CHK_HDRS))
27742790

27752791
$(HCO): %.hco: %.h FORCE
@@ -2792,12 +2808,8 @@ check: command-list.h
27922808
exit 1; \
27932809
fi
27942810

2795-
C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))
2796-
ifdef DC_SHA1_SUBMODULE
2797-
COCCI_SOURCES = $(filter-out sha1collisiondetection/%,$(C_SOURCES))
2798-
else
2799-
COCCI_SOURCES = $(filter-out sha1dc/%,$(C_SOURCES))
2800-
endif
2811+
FOUND_C_SOURCES = $(filter %.c,$(shell $(FIND_SOURCE_FILES)))
2812+
COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES))
28012813

28022814
%.cocci.patch: %.cocci $(COCCI_SOURCES)
28032815
@echo ' ' SPATCH $<; \

0 commit comments

Comments
 (0)