Commit f07728d5 authored by Dan Carpenter's avatar Dan Carpenter Committed by David Sterba

btrfs: clean up NULL checks in qgroup_unreserve_range()

Smatch complains that this code dereferences "entry" before checking
whether it's NULL on the next line.  Fortunately, rb_entry() will never
return NULL so it doesn't cause a problem.  We can clean up the NULL
checking a bit to silence the warning and make the code more clear.
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent fca3a45d
...@@ -3435,24 +3435,20 @@ static int qgroup_unreserve_range(struct btrfs_inode *inode, ...@@ -3435,24 +3435,20 @@ static int qgroup_unreserve_range(struct btrfs_inode *inode,
{ {
struct rb_node *node; struct rb_node *node;
struct rb_node *next; struct rb_node *next;
struct ulist_node *entry = NULL; struct ulist_node *entry;
int ret = 0; int ret = 0;
node = reserved->range_changed.root.rb_node; node = reserved->range_changed.root.rb_node;
if (!node)
return 0;
while (node) { while (node) {
entry = rb_entry(node, struct ulist_node, rb_node); entry = rb_entry(node, struct ulist_node, rb_node);
if (entry->val < start) if (entry->val < start)
node = node->rb_right; node = node->rb_right;
else if (entry)
node = node->rb_left;
else else
break; node = node->rb_left;
} }
/* Empty changeset */
if (!entry)
return 0;
if (entry->val > start && rb_prev(&entry->rb_node)) if (entry->val > start && rb_prev(&entry->rb_node))
entry = rb_entry(rb_prev(&entry->rb_node), struct ulist_node, entry = rb_entry(rb_prev(&entry->rb_node), struct ulist_node,
rb_node); rb_node);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment