Message ID | 20240613181745.1052423-3-bodonnel@redhat.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | xfsprogs: coverity fixes | expand |
On Thu, Jun 13, 2024 at 01:07:06PM -0500, Bill O'Donnell wrote: > Initialize if_levels to 0. > > Coverity-id: 1596600, 1596597 > > Signed-off-by: Bill O'Donnell <bodonnel@redhat.com> > --- > db/bmap_inflate.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/db/bmap_inflate.c b/db/bmap_inflate.c > index 33b0c954..8232f486 100644 > --- a/db/bmap_inflate.c > +++ b/db/bmap_inflate.c > @@ -351,6 +351,7 @@ build_new_datafork( > /* Set up staging for the new bmbt */ > ifake.if_fork = kmem_cache_zalloc(xfs_ifork_cache, 0); > ifake.if_fork_size = xfs_inode_fork_size(ip, XFS_DATA_FORK); > + ifake.if_levels = 0; > bmap_cur = libxfs_bmbt_stage_cursor(ip->i_mount, ip, &ifake); > > /* > @@ -404,6 +405,7 @@ estimate_size( > > ifake.if_fork = kmem_cache_zalloc(xfs_ifork_cache, 0); > ifake.if_fork_size = xfs_inode_fork_size(ip, XFS_DATA_FORK); > + ifake.if_levels = 0; Maybe initialize it at declaration time by doing: struct xbtree_ifakeroot ifake = { }; to future-proof against adding more fields?
On Thu, Jun 13, 2024 at 11:36:51AM -0700, Christoph Hellwig wrote: > On Thu, Jun 13, 2024 at 01:07:06PM -0500, Bill O'Donnell wrote: > > Initialize if_levels to 0. > > > > Coverity-id: 1596600, 1596597 > > > > Signed-off-by: Bill O'Donnell <bodonnel@redhat.com> > > --- > > db/bmap_inflate.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/db/bmap_inflate.c b/db/bmap_inflate.c > > index 33b0c954..8232f486 100644 > > --- a/db/bmap_inflate.c > > +++ b/db/bmap_inflate.c > > @@ -351,6 +351,7 @@ build_new_datafork( > > /* Set up staging for the new bmbt */ > > ifake.if_fork = kmem_cache_zalloc(xfs_ifork_cache, 0); > > ifake.if_fork_size = xfs_inode_fork_size(ip, XFS_DATA_FORK); > > + ifake.if_levels = 0; > > bmap_cur = libxfs_bmbt_stage_cursor(ip->i_mount, ip, &ifake); > > > > /* > > @@ -404,6 +405,7 @@ estimate_size( > > > > ifake.if_fork = kmem_cache_zalloc(xfs_ifork_cache, 0); > > ifake.if_fork_size = xfs_inode_fork_size(ip, XFS_DATA_FORK); > > + ifake.if_levels = 0; > > Maybe initialize it at declaration time by doing: > > struct xbtree_ifakeroot ifake = { }; > > to future-proof against adding more fields? > Makes sense, I'll send a new version. Thanks- Bill
diff --git a/db/bmap_inflate.c b/db/bmap_inflate.c index 33b0c954..8232f486 100644 --- a/db/bmap_inflate.c +++ b/db/bmap_inflate.c @@ -351,6 +351,7 @@ build_new_datafork( /* Set up staging for the new bmbt */ ifake.if_fork = kmem_cache_zalloc(xfs_ifork_cache, 0); ifake.if_fork_size = xfs_inode_fork_size(ip, XFS_DATA_FORK); + ifake.if_levels = 0; bmap_cur = libxfs_bmbt_stage_cursor(ip->i_mount, ip, &ifake); /* @@ -404,6 +405,7 @@ estimate_size( ifake.if_fork = kmem_cache_zalloc(xfs_ifork_cache, 0); ifake.if_fork_size = xfs_inode_fork_size(ip, XFS_DATA_FORK); + ifake.if_levels = 0; bmap_cur = libxfs_bmbt_stage_cursor(ip->i_mount, ip, &ifake); error = -libxfs_btree_bload_compute_geometry(bmap_cur, &bmap_bload,
Initialize if_levels to 0. Coverity-id: 1596600, 1596597 Signed-off-by: Bill O'Donnell <bodonnel@redhat.com> --- db/bmap_inflate.c | 2 ++ 1 file changed, 2 insertions(+)