public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: xfs@oss.sgi.com
Subject: [report] potential uninitialized variable in xfs_dir2_node_to_leaf()
Date: Thu, 10 Mar 2016 16:28:16 +0300	[thread overview]
Message-ID: <20160310132816.GA16611@mwanda> (raw)

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@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

                 reply	other threads:[~2016-03-10 13:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160310132816.GA16611@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox