diff mbox series

common/filter: prepend 0 to treat offset as octal

Message ID 20191212031152.1906287-1-naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series common/filter: prepend 0 to treat offset as octal | expand

Commit Message

Naohiro Aota Dec. 12, 2019, 3:11 a.m. UTC
The offsets printed by "od" are octal numbers. So, we need to add "0" at
the head of the $offset to parse it as an octal number.

Fixes: 37520a314bd4 ("fstests: Don't use gawk's strtonum")
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 common/filter | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Darrick J. Wong Dec. 12, 2019, 6:04 a.m. UTC | #1
On Thu, Dec 12, 2019 at 12:11:52PM +0900, Naohiro Aota wrote:
> The offsets printed by "od" are octal numbers. So, we need to add "0" at
> the head of the $offset to parse it as an octal number.
> 
> Fixes: 37520a314bd4 ("fstests: Don't use gawk's strtonum")
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

<grumble> Did the original patch author run all the tests that use
_filter_od to make sure there weren't any regressions.  This fixes
xfs/139 for me, so...

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  common/filter | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/filter b/common/filter
> index 6140e58368d7..88fcb6ef68ee 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -495,7 +495,7 @@ _filter_od()
>  		fi
>  
>  		offset="${line%% *}"
> -		printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
> +		printf '%o%s\n' $(("0$offset" / BLOCK_SIZE)) "${line#$offset}"
>  	done
>  }
>  
> -- 
> 2.24.0
>
Darrick J. Wong Dec. 12, 2019, 6:10 a.m. UTC | #2
On Wed, Dec 11, 2019 at 10:04:37PM -0800, Darrick J. Wong wrote:
> On Thu, Dec 12, 2019 at 12:11:52PM +0900, Naohiro Aota wrote:
> > The offsets printed by "od" are octal numbers. So, we need to add "0" at
> > the head of the $offset to parse it as an octal number.
> > 
> > Fixes: 37520a314bd4 ("fstests: Don't use gawk's strtonum")
> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> 
> <grumble> Did the original patch author run all the tests that use
> _filter_od to make sure there weren't any regressions.  This fixes
> xfs/139 for me, so...
> 
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

...also, thank you for fixing this problem. :)

--D

> --D
> 
> > ---
> >  common/filter | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/common/filter b/common/filter
> > index 6140e58368d7..88fcb6ef68ee 100644
> > --- a/common/filter
> > +++ b/common/filter
> > @@ -495,7 +495,7 @@ _filter_od()
> >  		fi
> >  
> >  		offset="${line%% *}"
> > -		printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
> > +		printf '%o%s\n' $(("0$offset" / BLOCK_SIZE)) "${line#$offset}"
> >  	done
> >  }
> >  
> > -- 
> > 2.24.0
> >
Kusanagi Kouichi Dec. 12, 2019, 10 a.m. UTC | #3
On 2019-12-11 22:04:37 -0800, Darrick J. Wong wrote:
> On Thu, Dec 12, 2019 at 12:11:52PM +0900, Naohiro Aota wrote:
> > The offsets printed by "od" are octal numbers. So, we need to add "0" at
> > the head of the $offset to parse it as an octal number.
> > 
> > Fixes: 37520a314bd4 ("fstests: Don't use gawk's strtonum")
> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> 
> <grumble> Did the original patch author run all the tests that use
> _filter_od to make sure there weren't any regressions.  This fixes
> xfs/139 for me, so...

I'm sorry. I didn't test well. Eryu, can you revert commit 37520a314bd4?
Eryu Guan Dec. 15, 2019, 4:07 p.m. UTC | #4
On Wed, Dec 11, 2019 at 10:04:37PM -0800, Darrick J. Wong wrote:
> On Thu, Dec 12, 2019 at 12:11:52PM +0900, Naohiro Aota wrote:
> > The offsets printed by "od" are octal numbers. So, we need to add "0" at
> > the head of the $offset to parse it as an octal number.
> > 
> > Fixes: 37520a314bd4 ("fstests: Don't use gawk's strtonum")
> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> 
> <grumble> Did the original patch author run all the tests that use
> _filter_od to make sure there weren't any regressions.  This fixes
> xfs/139 for me, so...

My apologies, I did test tests that use _filter_od, but clearly not
include xfs/139..

Eryu

> 
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> --D
> 
> > ---
> >  common/filter | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/common/filter b/common/filter
> > index 6140e58368d7..88fcb6ef68ee 100644
> > --- a/common/filter
> > +++ b/common/filter
> > @@ -495,7 +495,7 @@ _filter_od()
> >  		fi
> >  
> >  		offset="${line%% *}"
> > -		printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
> > +		printf '%o%s\n' $(("0$offset" / BLOCK_SIZE)) "${line#$offset}"
> >  	done
> >  }
> >  
> > -- 
> > 2.24.0
> >
Eryu Guan Dec. 15, 2019, 4:08 p.m. UTC | #5
On Thu, Dec 12, 2019 at 07:00:09PM +0900, Kusanagi Kouichi wrote:
> On 2019-12-11 22:04:37 -0800, Darrick J. Wong wrote:
> > On Thu, Dec 12, 2019 at 12:11:52PM +0900, Naohiro Aota wrote:
> > > The offsets printed by "od" are octal numbers. So, we need to add "0" at
> > > the head of the $offset to parse it as an octal number.
> > > 
> > > Fixes: 37520a314bd4 ("fstests: Don't use gawk's strtonum")
> > > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> > 
> > <grumble> Did the original patch author run all the tests that use
> > _filter_od to make sure there weren't any regressions.  This fixes
> > xfs/139 for me, so...
> 
> I'm sorry. I didn't test well. Eryu, can you revert commit 37520a314bd4?

Sure, I'll just revert it for now.

Eryu
diff mbox series

Patch

diff --git a/common/filter b/common/filter
index 6140e58368d7..88fcb6ef68ee 100644
--- a/common/filter
+++ b/common/filter
@@ -495,7 +495,7 @@  _filter_od()
 		fi
 
 		offset="${line%% *}"
-		printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
+		printf '%o%s\n' $(("0$offset" / BLOCK_SIZE)) "${line#$offset}"
 	done
 }