Re: [PATCH V2 4/4] xfs: Convert xfs_attr_sf macros to inline functions

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

 



> 
> /me suspects you could (ab)use struct_size here too, e.g.
> 
> 	return struct_size((struct xfs_attr_sf_entry *)NULL, nameval,
> 			nlen + vlen);
> 
> Though now I look at the casting mess and think NAH.
> Ok never mind. :)

I think this could work, yes, but it just makes the inline function hard to read
with no real gain IMHO.

> 
> The patch looks ok, modulo that spacing thing from above.

Fixing. Thanks for the review :)

> 
> --D
> 
> > +}
> > +
> > +/* space an entry uses */
> > +static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep) {
> > +	return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen);
> > +}
> > +
> > +/* next entry in struct */
> > +static inline struct xfs_attr_sf_entry *
> > +xfs_attr_sf_nextentry(struct xfs_attr_sf_entry *sfep) {
> > +	return (struct xfs_attr_sf_entry *)((char *)(sfep) +
> > +					    xfs_attr_sf_entsize(sfep));
> > +}
> >  
> >  #endif	/* __XFS_ATTR_SF_H__ */
> > diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
> > index 4eb1d6faecfb2..8f8837fe21cf0 100644
> > --- a/fs/xfs/xfs_attr_list.c
> > +++ b/fs/xfs/xfs_attr_list.c
> > @@ -96,7 +96,7 @@ xfs_attr_shortform_list(
> >  			 */
> >  			if (context->seen_enough)
> >  				break;
> > -			sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
> > +			sfe = xfs_attr_sf_nextentry(sfe);
> >  		}
> >  		trace_xfs_attr_list_sf_all(context);
> >  		return 0;
> > @@ -136,7 +136,7 @@ xfs_attr_shortform_list(
> >  		/* These are bytes, and both on-disk, don't endian-flip */
> >  		sbp->valuelen = sfe->valuelen;
> >  		sbp->flags = sfe->flags;
> > -		sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
> > +		sfe = xfs_attr_sf_nextentry(sfe);
> >  		sbp++;
> >  		nsbuf++;
> >  	}
> > -- 
> > 2.26.2
> > 
> 

-- 
Carlos




[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