Skip to content

Commit

Permalink
btrfs-progs: print-tree: cleanup __print_readable_flag()
Browse files Browse the repository at this point in the history
This includes:

- Remove the "__" prefix
  Now the "__" is no longer recommended, and there is no function taking
  the "print_readable_flag" in the first place.

- Move the supported flags calculation into print_readable_flag()
  Since all callers are doing the same work before calling the function.

Signed-off-by: Qu Wenruo <wqu@suse.com>
  • Loading branch information
adam900710 committed Nov 4, 2024
1 parent d2c40c1 commit 010b93f
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions kernel-shared/print-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1933,13 +1933,17 @@ static struct readable_flag_entry super_flags_array[] = {
};
static const int super_flags_num = ARRAY_SIZE(super_flags_array);

static void __print_readable_flag(u64 flag, struct readable_flag_entry *array,
int array_size, u64 supported_flags)
static void print_readable_flag(u64 flag, struct readable_flag_entry *array,
int array_size)
{
int i;
int first = 1;
u64 supported_flags = 0;
struct readable_flag_entry *entry;

for (i = 0; i < array_size; i++)
supported_flags |= array[i].bit;

if (!flag)
return;

Expand All @@ -1966,33 +1970,20 @@ static void __print_readable_flag(u64 flag, struct readable_flag_entry *array,

static void print_readable_compat_ro_flag(u64 flag)
{
u64 print_flags = 0;

for (int i = 0; i < compat_ro_flags_num; i++)
print_flags |= compat_ro_flags_array[i].bit;
return __print_readable_flag(flag, compat_ro_flags_array,
compat_ro_flags_num,
print_flags);
return print_readable_flag(flag, compat_ro_flags_array,
compat_ro_flags_num);
}

static void print_readable_incompat_flag(u64 flag)
{
u64 print_flags = 0;

for (int i = 0; i < incompat_flags_num; i++)
print_flags |= incompat_flags_array[i].bit;
return __print_readable_flag(flag, incompat_flags_array,
incompat_flags_num, print_flags);
return print_readable_flag(flag, incompat_flags_array,
incompat_flags_num);
}

static void print_readable_super_flag(u64 flag)
{
u64 print_flags = 0;

for (int i = 0; i < super_flags_num; i++)
print_flags |= super_flags_array[i].bit;
return __print_readable_flag(flag, super_flags_array,
super_flags_num, print_flags);
return print_readable_flag(flag, super_flags_array,
super_flags_num);
}

static void print_sys_chunk_array(struct btrfs_super_block *sb)
Expand Down

0 comments on commit 010b93f

Please sign in to comment.