[PATCH 2/3] find_api_violations: fix sed expression

Darrick J. Wong
2020-05-09T16:31:47Z

From: Darrick J. Wong <darrick.wong@oracle.com>

Apparently, the grep program in Ubuntu 20.04 is pickier about requiring
'(' to be escaped inside range expressions. This causes a regression in
xfs/437, so fix it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
tools/find-api-violations.sh | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/find-api-violations.sh b/tools/find-api-violations.sh
index b175ca10..c25fccca 100755
--- a/tools/find-api-violations.sh
+++ b/tools/find-api-violations.sh
@@ -18,8 +18,14 @@ check_if_api_calls() {
while read f; do grep "^$f(" libxfs/*.c; done | sed -e 's/^.*:xfs_/xfs_/g' -e 's/.$//g'
}

+# Generate a grep search expression for troublesome API call sites.
+# " foo(", ",foo(", "-foo(", and "(foo(" are examples.
+grep_pattern() {
+ sed -e 's/^/[[:space:],-\\(]/g' -e 's/$/(/g'
+}
+
find_libxfs_violations() {
- grep -r -n -f <(find_possible_api_calls | check_if_api_calls | sed -e 's/^/[[:space:],-(]/g' -e 's/$/(/g' ) $tool_dirs
+ grep -r -n -f <(find_possible_api_calls | check_if_api_calls | grep_pattern) $tool_dirs
}

# libxfs calls without negated error codes
@@ -33,7 +39,7 @@ find_possible_libxfs_api_calls() {
}

find_libxfs_api_violations() {
- grep -r -n -f <(find_possible_libxfs_api_calls | sed -e 's/^/[[:space:],-(]/g' -e 's/$/(/g') $tool_dirs
+ grep -r -n -f <(find_possible_libxfs_api_calls | grep_pattern) $tool_dirs
}

(find_libxfs_violations ; find_errcode_violations ; find_libxfs_api_violations) | sort -g -t ':' -k 2 | sort -g -t ':' -k 1 | uniq