Re: [PATCH v7 16/19] xfs: Simplify xfs_attr_set_iter

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

 



On Tue, Feb 25, 2020 at 07:13:42PM -0700, Allison Collins wrote:
> On 2/25/20 2:21 AM, Dave Chinner wrote:
> > Heh. This is an example of exactly why I think this should be
> > factored into functions first. Move all the code you just
> > re-indented into xfs_attr_set_shortform(), and the goto disappears
> > because this code becomes:
> > 
> > 	if (xfs_attr_is_shortform(dp))
> > 		return xfs_attr_set_shortform(dp, args);
> > 
> > add_leaf:
> > 
> > That massively improves the readability of the code - it separates
> > the operation implementation from the decision logic nice and
> > cleanly, and lends itself to being implemented in the delayed attr
> > state machine without needing gotos at all.
> Sure, I actually had it more like that in the last version.  I flipped it
> around because I thought it would help people understand what the
> refactoring was for if they could see it in context with the states. But if
> the other way is more helpful, its easy to put back.  Will move :-)

In general, factoring first is best. Factoring should not change
behaviour, nor change the actual code much. Then when the logic
surrounding the new function gets changed later on, it's much easier
to see and understand the logic changes as they aren't hidden
amongst mass code movements (like re-indenting).

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