Commit 5faea08e authored by Seth Howell's avatar Seth Howell Committed by Tomasz Zawadzki
Browse files

scripts/check_format.sh: fix naming convention check.



I had previously implemented a portion of the naming convention
check that looked for symbols that had been moved by performing
two checks:

git diff commit1 commit2 -- libname | grep for added function
git diff commit2 commit1 --libname | grep for added functions

and then subtracting the values returned by the second check from
the values returned by the first check. That works as long as the two
diffs are reciprocal (i.e. the first diff is a mirror image of the
second). However, this has proven to not be the case.

This change fixes that check by performing the smae diff twice and
grepping for removed functions the same time.

Change-Id: I09c81921d68436baeee706f2d9a6d30db1d23976
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3229


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 9aeaafa1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ for c_file in "${changed_c_libs[@]}"; do
	# Capture just the names of newly added (or modified) functions that start with "spdk_"
	mapfile -t defined_symbols < <(git diff -U0 $commit_to_compare HEAD -- $c_file | sed -En 's/(^[+])(spdk[a-z,A-Z,0-9,_]*)(\(.*)/\2/p')
	# Capture the names of removed symbols to catch edge cases where we just move definitions around.
	mapfile -t removed_symbols < <(git diff -U0 HEAD $commit_to_compare -- $c_file | sed -En 's/(^[+])(spdk[a-z,A-Z,0-9,_]*)(\(.*)/\2/p')
	mapfile -t removed_symbols < <(git diff -U0 $commit_to_compare HEAD -- $c_file | sed -En 's/(^[-])(spdk[a-z,A-Z,0-9,_]*)(\(.*)/\2/p')
	for symbol in "${removed_symbols[@]}"; do
		defined_symbols=("${defined_symbols[@]/$symbol/}")
	done