btrfs-progs: replace sizeof() with ARRAY_SIZE() macro
PATCH 1/1 btrfs-progs: replace sizeof() with ARRAY_SIZE() macro
Use ARRAY_SIZE() macro to simplify for loop.
Signed-off-by Integral <[email protected]>
--- common/format-output.c | 2 +- common/sort-utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
common/format-output.c +1 -1
@@ -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;
common/sort-utils.h +1 -1
@@ -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]);
Signature · 1 line
2.47.0