From de016f27561290ec9f8bf69c4f040fd292a54e5f Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Wed, 23 Sep 2020 07:51:57 -0400 Subject: [PATCH] scripts/check_format: match exact string when moving symbols Original code removed $symbol prefix from every entry in $defined_symbols. This was incorrect shown by example patch next in series. Original function spdk_json_decode_object() was moved and spdk_json_decode_object_relaxed() was added. This resulted in $defined_symbols containing entry "_relaxed". Now each entry in $defined_symbols is checked separatly to match exactly to the removed $symbol. Reported-by: Jacek Kalwas Signed-off-by: Tomasz Zawadzki Change-Id: I1d9931d2e93dc85465ce47a838a176c6ab5f1587 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4357 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Michal Berger --- scripts/check_format.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index d7e1c5904..b52211534 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -283,7 +283,11 @@ function check_naming_conventions() { # Capture the names of removed symbols to catch edge cases where we just move definitions around. 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/}") + for i in "${!defined_symbols[@]}"; do + if [[ ${defined_symbols[i]} = "$symbol" ]]; then + unset -v 'defined_symbols[i]' + fi + done done # It's possible that we just modified a functions arguments so unfortunately we can't just look at changed lines in this function. # matching groups are 1. All leading whitespace 2. function name. Capture just the symbol name.