diff mbox series

common/xfs: Fix _require_scratch_xfs_shrink bug

Message ID 1622194870-2085-1-git-send-email-xuyang2018.jy@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series common/xfs: Fix _require_scratch_xfs_shrink bug | expand

Commit Message

Yang Xu May 28, 2021, 9:41 a.m. UTC
Since local declaration can't pass function return value, this
helper never detects whether kernel or xfsprogs supports
xfs shrink feature successfully. Fit it by separating declaration
and assignment of local variables.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 common/xfs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Gao Xiang May 28, 2021, 11:58 a.m. UTC | #1
On Fri, May 28, 2021 at 05:41:10PM +0800, Yang Xu wrote:
> Since local declaration can't pass function return value, this
> helper never detects whether kernel or xfsprogs supports
> xfs shrink feature successfully. Fit it by separating declaration
> and assignment of local variables.
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

(It seems a post-modified occasional issue since I didn't
 use a local variable here in the original patchset...)

Thanks,
Gao Xiang

> ---
>  common/xfs | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/common/xfs b/common/xfs
> index d7f2a005..c5e39427 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -820,7 +820,8 @@ _require_scratch_xfs_shrink()
>  	. $tmp.mkfs
>  	_scratch_mount
>  	# here just to check if kernel supports, no need do more extra work
> -	local errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1)
> +	local errmsg
> +	errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1)
>  	if [ "$?" -ne 0 ]; then
>  		echo "$errmsg" | grep 'XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument' > /dev/null && \
>  			_notrun "kernel does not support shrinking"
> -- 
> 2.27.0
>
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index d7f2a005..c5e39427 100644
--- a/common/xfs
+++ b/common/xfs
@@ -820,7 +820,8 @@  _require_scratch_xfs_shrink()
 	. $tmp.mkfs
 	_scratch_mount
 	# here just to check if kernel supports, no need do more extra work
-	local errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1)
+	local errmsg
+	errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1)
 	if [ "$?" -ne 0 ]; then
 		echo "$errmsg" | grep 'XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument' > /dev/null && \
 			_notrun "kernel does not support shrinking"