From 5faea08e71bb305d1768e23484f6f14ac5353d70 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 6 Jul 2020 12:31:27 -0700 Subject: [PATCH] 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: Seth Howell Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3229 Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- scripts/check_format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index b9182c710..f4df5c41b 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -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