Btrfs: remove empty block groups automatically
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