Replace UTIL_ARRAY_SIZE with ARRAY_SIZE

Replace `UTIL_ARRAY_SIZE` with `ARRAY_SIZE` and remove it from
`util_base.h`.

Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2020-03-20 10:57:57 +01:00
committed by Jan Höppner
parent 6cf7f31746
commit c673bacd7e
6 changed files with 9 additions and 11 deletions

View File

@@ -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++) {

View File

@@ -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");

View File

@@ -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));

View File

@@ -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;

View File

@@ -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;

View File

@@ -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");