diff mbox series

[2/3] btrfs-progs: print-tree: cleanup __print_readable_flag()

Message ID 01d915834db71e870dc93d675ee16db3d14e527a.1728020867.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: print-tree: cleanup for regular bitmap based flags print | expand

Commit Message

Qu Wenruo Oct. 4, 2024, 5:52 a.m. UTC
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>
---
 kernel-shared/print-tree.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 14f7dcdf0ee9..bbd625d9b1eb 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -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;
 
@@ -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)