diff options
author | David Sterba <dsterba@suse.com> | 2016-01-06 15:08:46 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-01-12 15:01:08 +0100 |
commit | 3823cc2771cc55a8ca4c4266192f1c5a973d1fcd (patch) | |
tree | d6ddbb8dbe0ab32c06752ec5f2cc8906ddc56e05 /cmds-check.c | |
parent | 6aff5d74bdf1add66e27b876eb79074bc210599d (diff) |
btrfs-progs: return errors from get_root_rec, fail in callers
get_root_rec return value is enahanced, callers will just BUG_ON now
and will be fixed one by one.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r-- | cmds-check.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cmds-check.c b/cmds-check.c index 66ef0f23..c8cea4f1 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -3040,13 +3040,16 @@ static struct root_record *get_root_rec(struct cache_tree *root_cache, rec = container_of(cache, struct root_record, cache); } else { rec = calloc(1, sizeof(*rec)); + if (!rec) + return ERR_PTR(-ENOMEM); rec->objectid = objectid; INIT_LIST_HEAD(&rec->backrefs); rec->cache.start = objectid; rec->cache.size = 1; ret = insert_cache_extent(root_cache, &rec->cache); - BUG_ON(ret); + if (ret) + return ERR_PTR(-EEXIST); } return rec; } @@ -3104,6 +3107,7 @@ static int add_root_backref(struct cache_tree *root_cache, struct root_backref *backref; rec = get_root_rec(root_cache, root_id); + BUG_ON(IS_ERR(rec)); backref = get_root_backref(rec, ref_root, dir, index, name, namelen); backref->errors |= errors; @@ -3209,6 +3213,7 @@ static int check_root_refs(struct btrfs_root *root, int errors = 0; rec = get_root_rec(root_cache, BTRFS_FS_TREE_OBJECTID); + BUG_ON(IS_ERR(rec)); rec->found_ref = 1; /* fixme: this can not detect circular references */ @@ -3230,6 +3235,7 @@ static int check_root_refs(struct btrfs_root *root, ref_root = get_root_rec(root_cache, backref->ref_root); + BUG_ON(IS_ERR(ref_root)); if (ref_root->found_ref > 0) continue; @@ -3476,6 +3482,7 @@ static int check_fs_root(struct btrfs_root *root, if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) { rec = get_root_rec(root_cache, root->root_key.objectid); + BUG_ON(IS_ERR(rec)); if (btrfs_root_refs(root_item) > 0) rec->found_root_item = 1; } |