Re: [PATCH 28/31] xfs: clean up the ATTR_REPLACE checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 17, 2020 at 01:59:54PM +0100, Christoph Hellwig wrote:
> Remove superflous braces, elses after return statements and use a goto
> label to merge common error handling.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> Reviewed-by: Chandan Rajendra <chandanrlinux@xxxxxxxxx>
> Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> ---
>  fs/xfs/libxfs/xfs_attr.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 3b1db2afb104..9c629c7c912d 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -423,9 +423,9 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
>  	trace_xfs_attr_sf_addname(args);
>  
>  	retval = xfs_attr_shortform_lookup(args);
> -	if ((args->flags & ATTR_REPLACE) && (retval == -ENOATTR)) {
> +	if ((args->flags & ATTR_REPLACE) && retval == -ENOATTR)
>  		return retval;
> -	} else if (retval == -EEXIST) {
> +	if (retval == -EEXIST) {
>  		if (args->flags & ATTR_CREATE)
>  			return retval;

If we are cleaning up this code, I'd prefer that the retval vs flags
order was made consistent. i.e.

	if (retval == -ENOATTR && (args->flags & ATTR_REPLACE))
		return retval;
	if (retval == -EEXIST) {
		 if (args->flags & ATTR_CREATE)
			return retval;
	.....

Because then it is clear we are stacking error conditions that are
only relevant to specific operations.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux