From c673bacd7e6cbdd2379ceb28a1d5660cd09d1753 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Fri, 20 Mar 2020 10:57:57 +0100 Subject: [PATCH] Replace UTIL_ARRAY_SIZE with ARRAY_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace `UTIL_ARRAY_SIZE` with `ARRAY_SIZE` and remove it from `util_base.h`. Acked-by: Jan Höppner Reviewed-by: Philipp Rudo Reviewed-by: Stefan Haberland Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- dasdinfo/dasdinfo.c | 2 +- dasdview/dasdview.c | 2 +- fdasd/fdasd.c | 10 +++++----- include/lib/util_base.h | 2 -- libutil/util_libc.c | 2 +- libutil/util_panic.c | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/dasdinfo/dasdinfo.c b/dasdinfo/dasdinfo.c index 3d46e3b5..c3797bf9 100644 --- a/dasdinfo/dasdinfo.c +++ b/dasdinfo/dasdinfo.c @@ -290,7 +290,7 @@ static int dinfo_create_devnode(dev_t dev, char **devno) mode = S_IFBLK | S_IRWXU; /* Try several locations for the temporary device node. */ - for (path = 0; path < UTIL_ARRAY_SIZE(pathname); path++) { + for (path = 0; path < ARRAY_SIZE(pathname); path++) { if (pathname[path] == NULL) continue; for (retry = 0; retry < TEMP_DEV_MAX_RETRIES; retry++) { diff --git a/dasdview/dasdview.c b/dasdview/dasdview.c index ea122e75..ad8b022d 100644 --- a/dasdview/dasdview.c +++ b/dasdview/dasdview.c @@ -404,7 +404,7 @@ dasdview_print_extended_info(dasdview_info_t *info) if (dasd_info->features == DASD_FEATURE_DEFAULT) { printf("default\n"); } else { - for (i = 0; i < UTIL_ARRAY_SIZE(flist); i++) + for (i = 0; i < ARRAY_SIZE(flist); i++) if (dasd_info->features & flist[i].mask) printf("%s ", flist[i].name); printf("\n"); diff --git a/fdasd/fdasd.c b/fdasd/fdasd.c index 89dce9ed..516f164d 100644 --- a/fdasd/fdasd.c +++ b/fdasd/fdasd.c @@ -75,7 +75,7 @@ static int get_part_name_by_dsname(char *dsname, char **name) return 0; } - for (i = 0; i < UTIL_ARRAY_SIZE(partition_types); i++) { + for (i = 0; i < ARRAY_SIZE(partition_types); i++) { if (strstr(dsname, partition_types[i].dsname) != NULL) { *name = partition_types[i].name; return 0; @@ -97,7 +97,7 @@ static int get_part_type_by_dsname(char *dsname, int *type) return 0; } - for (i = 0; i < UTIL_ARRAY_SIZE(partition_types); i++) { + for (i = 0; i < ARRAY_SIZE(partition_types); i++) { if (strstr(dsname, partition_types[i].dsname) != NULL) { *type = partition_types[i].type; return 0; @@ -112,7 +112,7 @@ static int get_part_type_by_dsname(char *dsname, int *type) */ static int get_part_dsname_by_type(unsigned int type, char **dsname) { - if (type > UTIL_ARRAY_SIZE(partition_types)) + if (type > ARRAY_SIZE(partition_types)) return 1; if (type == 0) @@ -1205,7 +1205,7 @@ static void fdasd_list_known_partitions(void) unsigned int i; for (i = VALID_PARTITION_OFFSET; - i < UTIL_ARRAY_SIZE(partition_types); i++) { + i < ARRAY_SIZE(partition_types); i++) { printf("%3d %s\n", partition_types[i].type, partition_types[i].name); } @@ -1622,7 +1622,7 @@ static void fdasd_change_part_type(fdasd_anchor_t *anc) part_type = 0; while (part_type < 1 || - part_type > UTIL_ARRAY_SIZE(partition_types) - 1) { + part_type > ARRAY_SIZE(partition_types) - 1) { do { part_type = read_char("new partition type: "); } while (!isdigit(part_type)); diff --git a/include/lib/util_base.h b/include/lib/util_base.h index 60c9561b..b1c5c5aa 100644 --- a/include/lib/util_base.h +++ b/include/lib/util_base.h @@ -21,8 +21,6 @@ void util_hexdump_grp(FILE *fh, const char *tag, const void *data, int group, int cnt, int indent); void util_print_indented(const char *str, int indent); -#define UTIL_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - static inline void util_ptr_vec_free(void **ptr_vec, int count) { int i; diff --git a/libutil/util_libc.c b/libutil/util_libc.c index d3e76766..8ea421b4 100644 --- a/libutil/util_libc.c +++ b/libutil/util_libc.c @@ -29,7 +29,7 @@ static void format_size(char *str, size_t size) {"byte", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}; unsigned int i; - for (i = 0; i < UTIL_ARRAY_SIZE(unit_vec); i++) { + for (i = 0; i < ARRAY_SIZE(unit_vec); i++) { if (size / 1024 == 0) { sprintf(str, "%zu %s", size, unit_vec[i]); return; diff --git a/libutil/util_panic.c b/libutil/util_panic.c index d0132b93..59a9a9e0 100644 --- a/libutil/util_panic.c +++ b/libutil/util_panic.c @@ -31,7 +31,7 @@ static void print_backtrace(void) char **strings; fprintf(stderr, "Backtrace:\n\n"); - size = backtrace(array, UTIL_ARRAY_SIZE(array)); + size = backtrace(array, ARRAY_SIZE(array)); strings = backtrace_symbols(array, size); if (strings == NULL) { fprintf(stderr, " Could not obtain backtrace (ENOMEM)\n");