On Thu, Sep 03, 2020 at 04:28:38PM +0200, Carlos Maiolino wrote: > nameval is a variable-size array, so, define it as it, and remove all > the -1 magic number subtractions > > Signed-off-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx> > --- > > Changelog: > > V2: > - Drop wrong change to XFS_ATTR_SF_ENTSIZE_MAX > V3: > - Use XFS_ATTR_SF_ENTSIZE_BYNAME in xfs_attr_shortform_allfit() > - Remove int casting and fix spacing on > XFS_ATTR_SF_ENTSIZE_BYNAME > > fs/xfs/libxfs/xfs_attr_leaf.c | 10 ++++------ > fs/xfs/libxfs/xfs_attr_sf.h | 4 ++-- > fs/xfs/libxfs/xfs_da_format.h | 2 +- > 3 files changed, 7 insertions(+), 9 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c > index d920183b08a99..fb05c77fc8c9f 100644 > --- a/fs/xfs/libxfs/xfs_attr_leaf.c > +++ b/fs/xfs/libxfs/xfs_attr_leaf.c > @@ -992,9 +992,9 @@ xfs_attr_shortform_allfit( > return 0; > if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX) > return 0; > - bytes += sizeof(struct xfs_attr_sf_entry) - 1 > - + name_loc->namelen > - + be16_to_cpu(name_loc->valuelen); > + bytes += XFS_ATTR_SF_ENTSIZE_BYNAME( > + name_loc->namelen, > + be16_to_cpu(name_loc->valuelen)); This can be: bytes += XFS_ATTR_SF_ENTSIZE_BYNAME(name_loc->namelen, be16_to_cpu(name_loc->valuelen)); and would be way more readable that way. Otherwise looks good: Reviewed-by: Christoph Hellwig <hch@xxxxxx>