[report] potential uninitialized variable in xfs_dir2_node_to_leaf()

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

 



Hello XFS devs,

I get the following static checker warning:

	fs/xfs/libxfs/xfs_dir2_leaf.c:1726 xfs_dir2_node_to_leaf()
	error: potentially using uninitialized 'rval'.

fs/xfs/libxfs/xfs_dir2_leaf.c
  1691          int                     rval;           /* successful free trim? */
                                        ^^^^

  1692          xfs_trans_t             *tp;            /* transaction pointer */
  1693          struct xfs_dir3_icleaf_hdr leafhdr;
  1694          struct xfs_dir3_icfree_hdr freehdr;
  1695  
  1696          /*
  1697           * There's more than a leaf level in the btree, so there must
  1698           * be multiple leafn blocks.  Give up.
  1699           */
  1700          if (state->path.active > 1)
  1701                  return 0;
  1702          args = state->args;
  1703  
  1704          trace_xfs_dir2_node_to_leaf(args);
  1705  
  1706          mp = state->mp;
  1707          dp = args->dp;
  1708          tp = args->trans;
  1709          /*
  1710           * Get the last offset in the file.
  1711           */
  1712          if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK))) {
  1713                  return error;
  1714          }
  1715          fo -= args->geo->fsbcount;
  1716          /*
  1717           * If there are freespace blocks other than the first one,
  1718           * take this opportunity to remove trailing empty freespace blocks
  1719           * that may have been left behind during no-space-reservation
  1720           * operations.
  1721           */
  1722          while (fo > args->geo->freeblk) {
  1723                  if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) {
                                                                        ^^^^
The first "return 0" happens before "rval" is initialized.

  1724                          return error;
  1725                  }
  1726                  if (rval)
                            ^^^^
  1727                          fo -= args->geo->fsbcount;
  1728                  else
  1729                          return 0;
  1730          }

regards,
dan carpenter

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux