]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
find_api_violations: fix sed expression
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 9 May 2020 17:11:42 +0000 (13:11 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Sat, 9 May 2020 17:11:42 +0000 (13:11 -0400)
Apparently, GNU grep version 3.4 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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[sandeen: note grep version not OS version]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
tools/find-api-violations.sh

index b175ca100005465f2c0a190ee52eb79c96a0a7d6..c25fccca1244c59ee133caebcb0331b12de79872 100755 (executable)
@@ -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