[2/3] find_api_violations: fix sed expression
diff mbox series

Message ID 158904178381.982835.124483584305094681.stgit@magnolia
State Accepted
Headers show
Series
  • xfsprogs: random fixes
Related show

Commit Message

Darrick J. Wong May 9, 2020, 4:29 p.m. UTC
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(-)

Comments

Christoph Hellwig May 9, 2020, 4:36 p.m. UTC | #1
On Sat, May 09, 2020 at 09:29:43AM -0700, Darrick J. Wong wrote:
> 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.

Mentioning the actual sed version would be a lot more helpful..

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong May 9, 2020, 4:38 p.m. UTC | #2
On Sat, May 09, 2020 at 09:36:44AM -0700, Christoph Hellwig wrote:
> On Sat, May 09, 2020 at 09:29:43AM -0700, Darrick J. Wong wrote:
> > 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.
> 
> Mentioning the actual sed version would be a lot more helpful..

GNU grep 3.4.

--D

> Otherwise looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
Christoph Hellwig May 9, 2020, 4:44 p.m. UTC | #3
On Sat, May 09, 2020 at 09:38:21AM -0700, Darrick J. Wong wrote:
> On Sat, May 09, 2020 at 09:36:44AM -0700, Christoph Hellwig wrote:
> > On Sat, May 09, 2020 at 09:29:43AM -0700, Darrick J. Wong wrote:
> > > 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.
> > 
> > Mentioning the actual sed version would be a lot more helpful..
> 
> GNU grep 3.4.

That should go into the changelog for commit instead of the distro
version.
Eric Sandeen May 9, 2020, 5:10 p.m. UTC | #4
On 5/9/20 11:44 AM, Christoph Hellwig wrote:
> On Sat, May 09, 2020 at 09:38:21AM -0700, Darrick J. Wong wrote:
>> On Sat, May 09, 2020 at 09:36:44AM -0700, Christoph Hellwig wrote:
>>> On Sat, May 09, 2020 at 09:29:43AM -0700, Darrick J. Wong wrote:
>>>> 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.
>>>
>>> Mentioning the actual sed version would be a lot more helpful..
>>
>> GNU grep 3.4.
> 
> That should go into the changelog for commit instead of the distro
> version.
> 

I've fixed it on merge

Patch
diff mbox series

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