Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: jbacik@fb.com
Cc: linux-btrfs@vger.kernel.org
Subject: re: Btrfs: remove empty block groups automatically
Date: Fri, 18 Mar 2016 08:38:28 +0300	[thread overview]
Message-ID: <20160318053828.GC2111@mwanda> (raw)

Hello Josef Bacik,

The patch 47ab2a6c6899: "Btrfs: remove empty block groups
automatically" from Sep 18, 2014, leads to the following static
checker warning:

	fs/btrfs/extent-tree.c:10584 btrfs_delete_unused_bgs()
	warn: 'ret' can be either negative or positive

The warning here is because we treat positives and negatives as error
codes where normally the kernel uses negative error codes.

fs/btrfs/volumes.c
  1450  static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
  1451                            struct btrfs_device *device,
  1452                            u64 start, u64 *dev_extent_len)
  1453  {
  1454          int ret;
  1455          struct btrfs_path *path;
  1456          struct btrfs_root *root = device->dev_root;
  1457          struct btrfs_key key;
  1458          struct btrfs_key found_key;
  1459          struct extent_buffer *leaf = NULL;
  1460          struct btrfs_dev_extent *extent = NULL;
  1461  
  1462          path = btrfs_alloc_path();
  1463          if (!path)
  1464                  return -ENOMEM;
  1465  
  1466          key.objectid = device->devid;
  1467          key.offset = start;
  1468          key.type = BTRFS_DEV_EXTENT_KEY;
  1469  again:
  1470          ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
  1471          if (ret > 0) {
  1472                  ret = btrfs_previous_item(root, path, key.objectid,
  1473                                            BTRFS_DEV_EXTENT_KEY);


btrfs_previous_item() returns 0 if something is found, 1 if nothing was
found and < 0 on error.  We propogate the 1 to other callers who treat
it like an error code but it's not documented what the 1 means.

  1474                  if (ret)
  1475                          goto out;
  1476                  leaf = path->nodes[0];
  1477                  btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
  1478                  extent = btrfs_item_ptr(leaf, path->slots[0],

regards,
dan carpenter

                 reply	other threads:[~2016-03-18  5:38 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=20160318053828.GC2111@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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