Re: [PATCH 2/4] xfs: create a predicate to determine if two xfs_names are the same

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

 



On Tue, Jan 02, 2024 at 03:13:05AM -0800, Christoph Hellwig wrote:
> On Sun, Dec 31, 2023 at 12:06:47PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@xxxxxxxxxx>
> > 
> > Create a simple predicate to determine if two xfs_names are the same
> > objects or have the exact same name.  The comparison is always case
> > sensitive.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
> > ---
> >  fs/xfs/libxfs/xfs_dir2.h |    9 +++++++++
> >  fs/xfs/scrub/dir.c       |    4 ++--
> >  2 files changed, 11 insertions(+), 2 deletions(-)
> > 
> > 
> > diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> > index 7d7cd8d808e4d..ac3c264402dda 100644
> > --- a/fs/xfs/libxfs/xfs_dir2.h
> > +++ b/fs/xfs/libxfs/xfs_dir2.h
> > @@ -24,6 +24,15 @@ struct xfs_dir3_icleaf_hdr;
> >  extern const struct xfs_name	xfs_name_dotdot;
> >  extern const struct xfs_name	xfs_name_dot;
> >  
> > +static inline bool
> > +xfs_dir2_samename(
> > +	const struct xfs_name	*n1,
> > +	const struct xfs_name	*n2)
> > +{
> > +	return n1 == n2 || (n1->len == n2->len &&
> > +			    !memcmp(n1->name, n2->name, n1->len));
> 
> Nit, but to me the formatting looks weird, why not:
> 
> 	return n1 == n2 ||
> 		(n1->len == n2->len && !memcmp(n1->name, n2->name, n1->len));
> 
> Or even more verbose:
> 
> 	if (n1 == n2)
> 		return true;
> 	if (n1->len != n2->len)
> 		return false;
> 	return !memcmp(n1->name, n2->name, n1->len);

Yeah, I'll do that instead of the multiline thing.

> Otherwise this looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>

Thanks!

--D




[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