Re: [PATCH 01/25] [btrfs] BUG to BUG_ON changes

From: Stoyan Gaydarov
Date: Tue Mar 10 2009 - 14:16:20 EST


On Tue, Mar 10, 2009 at 4:16 AM, David John <davidjonx@xxxxxxxxx> wrote:
> Stoyan Gaydarov wrote:
>> Signed-off-by: Stoyan Gaydarov <stoyboyker@xxxxxxxxx>
>> ---
>> Âfs/btrfs/ctree.c      Â|  Â3 +--
>> Âfs/btrfs/extent-tree.c   Â|  Â3 +--
>> Âfs/btrfs/free-space-cache.c | Â Â3 +--
>> Âfs/btrfs/tree-log.c     |  Â3 +--
>> Â4 files changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
>> index 37f31b5..2c590b0 100644
>> --- a/fs/btrfs/ctree.c
>> +++ b/fs/btrfs/ctree.c
>> @@ -2174,8 +2174,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root
>> Â Â Â BUG_ON(!path->nodes[level]);
>> Â Â Â lower = path->nodes[level];
>> Â Â Â nritems = btrfs_header_nritems(lower);
>> - Â Â if (slot > nritems)
>> - Â Â Â Â Â Â BUG();
>> + Â Â BUG_ON(slot > nritems);
>> Â Â Â if (nritems == BTRFS_NODEPTRS_PER_BLOCK(root))
>> Â Â Â Â Â Â Â BUG();
>
> ^ You seem to have missed one.

Actually that one was left on purpose because BUG_ON calls are not to
have any side effects and I do not know enough about btrfs to know
what BTRFS_NODEPTRS_PER_BLOCK does so it was left as is.

>
>> Â Â Â if (slot != nritems) {
>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>> index 9abf81f..0314ab6 100644
>> --- a/fs/btrfs/extent-tree.c
>> +++ b/fs/btrfs/extent-tree.c
>> @@ -672,8 +672,7 @@ static noinline int insert_extents(struct btrfs_trans_handle *trans,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â keys+i, data_size+i, total-i);
>> Â Â Â Â Â Â Â BUG_ON(ret < 0);
>>
>> - Â Â Â Â Â Â if (last && ret > 1)
>> - Â Â Â Â Â Â Â Â Â Â BUG();
>> + Â Â Â Â Â Â BUG_ON(last && ret > 1);
>>
>> Â Â Â Â Â Â Â leaf = path->nodes[0];
>> Â Â Â Â Â Â Â for (c = 0; c < ret; c++) {
>> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
>> index d1e5f0e..b0c7661 100644
>> --- a/fs/btrfs/free-space-cache.c
>> +++ b/fs/btrfs/free-space-cache.c
>> @@ -267,8 +267,7 @@ static int __btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
>> Âout:
>> Â Â Â if (ret) {
>> Â Â Â Â Â Â Â printk(KERN_ERR "btrfs: unable to add free space :%d\n", ret);
>> - Â Â Â Â Â Â if (ret == -EEXIST)
>> - Â Â Â Â Â Â Â Â Â Â BUG();
>> + Â Â Â Â Â Â BUG_ON(ret == -EEXIST);
>> Â Â Â }
>>
>> Â Â Â kfree(alloc_info);
>> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
>> index 9c462fb..2c892f6 100644
>> --- a/fs/btrfs/tree-log.c
>> +++ b/fs/btrfs/tree-log.c
>> @@ -1150,8 +1150,7 @@ insert:
>> Â Â Â ret = insert_one_name(trans, root, path, key->objectid, key->offset,
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â name, name_len, log_type, &log_key);
>>
>> - Â Â if (ret && ret != -ENOENT)
>> - Â Â Â Â Â Â BUG();
>> + Â Â BUG_ON(ret && ret != -ENOENT);
>> Â Â Â goto out;
>> Â}
>>
>
>

--

-Stoyan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/