Skip to content

Commit 74d91ab

Browse files
fdmananakdave
authored andcommitted
btrfs: send: directly return strcmp() result when comparing recorded refs
There's no point in converting the return values from strcmp() as all we need is that it returns a negative value if the first argument is less than the second, a positive value if it's greater and 0 if equal. We do not have a need for -1 instead of any other negative value and no need for 1 instead of any other positive value - that's all that rb_find() needs and no where else we need specific negative and positive values. So remove the intermediate local variable and checks and return directly the result from strcmp(). This also reduces the module's text size. Before: $ size fs/btrfs/btrfs.ko text data bss dec hex filename 1888116 161347 16136 2065599 1f84bf fs/btrfs/btrfs.ko After: $ size fs/btrfs/btrfs.ko text data bss dec hex filename 1888052 161347 16136 2065535 1f847f fs/btrfs/btrfs.ko Reviewed-by: Boris Burkov <boris@bur.io> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com>
1 parent 04cbb1b commit 74d91ab

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

fs/btrfs/send.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4628,7 +4628,6 @@ static int rbtree_ref_comp(const void *k, const struct rb_node *node)
46284628
{
46294629
const struct recorded_ref *data = k;
46304630
const struct recorded_ref *ref = rb_entry(node, struct recorded_ref, node);
4631-
int result;
46324631

46334632
if (data->dir > ref->dir)
46344633
return 1;
@@ -4642,12 +4641,7 @@ static int rbtree_ref_comp(const void *k, const struct rb_node *node)
46424641
return 1;
46434642
if (data->name_len < ref->name_len)
46444643
return -1;
4645-
result = strcmp(data->name, ref->name);
4646-
if (result > 0)
4647-
return 1;
4648-
if (result < 0)
4649-
return -1;
4650-
return 0;
4644+
return strcmp(data->name, ref->name);
46514645
}
46524646

46534647
static bool rbtree_ref_less(struct rb_node *node, const struct rb_node *parent)

0 commit comments

Comments
 (0)