Re: [PATCH 2/4] xfs_db: fix unitialized variable ifake->if_levels

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

 



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@xxxxxxxxxx>
> > ---
> >  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





[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