From d78deddc6d9d11bfef79b8d6acec1febb248a2c7 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 18 Jul 2014 13:22:52 +0200 Subject: losetup: clean up columns[] usage Signed-off-by: Karel Zak --- sys-utils/losetup.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'sys-utils/losetup.c') diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c index b1fda7368..95e99bb8c 100644 --- a/sys-utils/losetup.c +++ b/sys-utils/losetup.c @@ -73,16 +73,13 @@ static struct colinfo infos[] = { [COL_MAJMIN] = { "MAJ:MIN", 3, 0, N_("loop device major:minor number")}, }; -#define NCOLS ARRAY_SIZE(infos) - -static int columns[NCOLS] = {-1}; +static int columns[ARRAY_SIZE(infos) * 2] = {-1}; static int ncolumns; static int get_column_id(int num) { - assert(ARRAY_SIZE(columns) == NCOLS); assert(num < ncolumns); - assert(columns[num] < (int) NCOLS); + assert(columns[num] < (int) ARRAY_SIZE(infos)); return columns[num]; } @@ -95,7 +92,7 @@ static int column_name_to_id(const char *name, size_t namesz) { size_t i; - for (i = 0; i < NCOLS; i++) { + for (i = 0; i < ARRAY_SIZE(infos); i++) { const char *cn = infos[i].name; if (!strncasecmp(name, cn, namesz) && !*(cn + namesz)) @@ -400,7 +397,7 @@ static void usage(FILE *out) fputs(USAGE_VERSION, out); fputs(_("\nAvailable --list columns:\n"), out); - for (i = 0; i < NCOLS; i++) + for (i = 0; i < ARRAY_SIZE(infos); i++) fprintf(out, " %12s %s\n", infos[i].name, _(infos[i].help)); fprintf(out, USAGE_MAN_TAIL("losetup(8)")); -- cgit v1.2.3-55-g7522