diff mbox series

[2/7] filter: fix assumed whitespace in _filefrag_filter regex

Message ID 20190121163316.20616-2-jeffm@suse.com (mailing list archive)
State New, archived
Headers show
Series [1/7] btrfs/010: don't run without /sys/fs/btrfs | expand

Commit Message

Jeff Mahoney Jan. 21, 2019, 4:33 p.m. UTC
From: Jeff Mahoney <jeffm@suse.com>

The regex assumes there will be whitespace after the .. in the ranges
and, with larger offsets, there may not be any.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 common/filter | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dave Chinner Jan. 21, 2019, 10:51 p.m. UTC | #1
On Mon, Jan 21, 2019 at 11:33:11AM -0500, jeffm@suse.com wrote:
> From: Jeff Mahoney <jeffm@suse.com>
> 
> The regex assumes there will be whitespace after the .. in the ranges
> and, with larger offsets, there may not be any.

Does more than this, right?

> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> ---
>  common/filter | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/filter b/common/filter
> index ed082d24..b4443a34 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -532,7 +532,7 @@ _filter_filefrag()
>  		next
>  	}
>  	($ext, $logical, $physical, $length) =
> -		(/^\s*(\d+):\s+(\d+)..\s+\d+:\s+(\d+)..\s+\d+:\s+(\d+):/)
> +		(/^\s*(\d+):\s+(\d+)\.\.\s*\d+:\s+(\d+)\.\.\s*\d+:\s+(\d+):/)

This is escaping "..", too, isn't it? 

Cheers,

Dave.
Jeff Mahoney Jan. 23, 2019, 1:38 a.m. UTC | #2
On 1/21/19 5:51 PM, Dave Chinner wrote:
> On Mon, Jan 21, 2019 at 11:33:11AM -0500, jeffm@suse.com wrote:
>> From: Jeff Mahoney <jeffm@suse.com>
>>
>> The regex assumes there will be whitespace after the .. in the ranges
>> and, with larger offsets, there may not be any.
> 
> Does more than this, right?

I suppose.  It converts the interpreted .. into a literal .., which I
believe was the original intent.

>> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
>> ---
>>  common/filter | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/common/filter b/common/filter
>> index ed082d24..b4443a34 100644
>> --- a/common/filter
>> +++ b/common/filter
>> @@ -532,7 +532,7 @@ _filter_filefrag()
>>  		next
>>  	}
>>  	($ext, $logical, $physical, $length) =
>> -		(/^\s*(\d+):\s+(\d+)..\s+\d+:\s+(\d+)..\s+\d+:\s+(\d+):/)
>> +		(/^\s*(\d+):\s+(\d+)\.\.\s*\d+:\s+(\d+)\.\.\s*\d+:\s+(\d+):/)
> 
> This is escaping "..", too, isn't it? 

Yes, but what else could the .. in the original regex have been
referring to?  I don't recall seeing any other filefrag format that
would match otherwise.

I don't have a problem documenting it further, though.

-Jeff
Dave Chinner Jan. 23, 2019, 4:16 a.m. UTC | #3
On Tue, Jan 22, 2019 at 08:38:17PM -0500, Jeff Mahoney wrote:
> On 1/21/19 5:51 PM, Dave Chinner wrote:
> > On Mon, Jan 21, 2019 at 11:33:11AM -0500, jeffm@suse.com wrote:
> >> From: Jeff Mahoney <jeffm@suse.com>
> >>
> >> The regex assumes there will be whitespace after the .. in the ranges
> >> and, with larger offsets, there may not be any.
> > 
> > Does more than this, right?
> 
> I suppose.  It converts the interpreted .. into a literal .., which I
> believe was the original intent.
> 
> >> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> >> ---
> >>  common/filter | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/common/filter b/common/filter
> >> index ed082d24..b4443a34 100644
> >> --- a/common/filter
> >> +++ b/common/filter
> >> @@ -532,7 +532,7 @@ _filter_filefrag()
> >>  		next
> >>  	}
> >>  	($ext, $logical, $physical, $length) =
> >> -		(/^\s*(\d+):\s+(\d+)..\s+\d+:\s+(\d+)..\s+\d+:\s+(\d+):/)
> >> +		(/^\s*(\d+):\s+(\d+)\.\.\s*\d+:\s+(\d+)\.\.\s*\d+:\s+(\d+):/)
> > 
> > This is escaping "..", too, isn't it? 
> 
> Yes, but what else could the .. in the original regex have been
> referring to?  I don't recall seeing any other filefrag format that
> would match otherwise.

Neither do I. My point was it was a change that was not documented
in the commit message and so there might be something I was missing.

> I don't have a problem documenting it further, though.

That'd be great, thanks!

Cheers,

Dave.
diff mbox series

Patch

diff --git a/common/filter b/common/filter
index ed082d24..b4443a34 100644
--- a/common/filter
+++ b/common/filter
@@ -532,7 +532,7 @@  _filter_filefrag()
 		next
 	}
 	($ext, $logical, $physical, $length) =
-		(/^\s*(\d+):\s+(\d+)..\s+\d+:\s+(\d+)..\s+\d+:\s+(\d+):/)
+		(/^\s*(\d+):\s+(\d+)\.\.\s*\d+:\s+(\d+)\.\.\s*\d+:\s+(\d+):/)
 	or next;
 	($flags) = /.*:\s*(\S*)$/;
 	print $physical * $blocksize, "#",