diff mbox series

btrfs-progs: replace sizeof() with ARRAY_SIZE() macro

Message ID 20241109093704.84519-1-integral@archlinuxcn.org (mailing list archive)
State New
Headers show
Series btrfs-progs: replace sizeof() with ARRAY_SIZE() macro | expand

Commit Message

Integral Nov. 9, 2024, 9:37 a.m. UTC
Use ARRAY_SIZE() macro to simplify for loop.

Signed-off-by: Integral <integral@archlinuxcn.org>
---
 common/format-output.c | 2 +-
 common/sort-utils.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/common/format-output.c b/common/format-output.c
index 3b333ed5..f150a4f2 100644
--- a/common/format-output.c
+++ b/common/format-output.c
@@ -149,7 +149,7 @@  static bool fmt_set_unquoted(struct format_ctx *fctx, const struct rowspec *row,
 {
 	static const char *types[] = { "%llu", "bool" };
 
-	for (int i = 0; i < sizeof(types) / sizeof(types[0]); i++)
+	for (int i = 0; i < ARRAY_SIZE(types); i++)
 		if (strcmp(types[i], row->fmt) == 0)
 			return true;
 
diff --git a/common/sort-utils.h b/common/sort-utils.h
index 09be7b7d..a8af9658 100644
--- a/common/sort-utils.h
+++ b/common/sort-utils.h
@@ -56,7 +56,7 @@  void test() {
 	const char *sortby[] = { "size", "id" };
 
 	compare_init(&comp, sortit);
-	for (i = 0; i < sizeof(sortby) / sizeof(sortby[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(sortby); i++) {
 		ret = compare_add_sort_key(&comp, sortby[i]);
 		if (ret < 0) {
 			printf("ERROR adding sort key %s\n", sortby[i]);