From: Karel Zak Date: Fri, 18 Jul 2014 11:22:52 +0000 (+0200) Subject: wdctl: clean up columns[] usage X-Git-Tag: v2.25~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=059a91f8d0de7a1f2018d97e9e161cd68991f843;p=thirdparty%2Futil-linux.git wdctl: clean up columns[] usage Signed-off-by: Karel Zak --- diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c index 137649a3d7..0628c8ecae 100644 --- a/sys-utils/wdctl.c +++ b/sys-utils/wdctl.c @@ -105,8 +105,8 @@ static struct colinfo infos[] = { }; -#define NCOLS ARRAY_SIZE(infos) -static int columns[NCOLS], ncolumns; +static int columns[ARRAY_SIZE(infos) * 2]; +static int ncolumns; struct wdinfo { char *device; @@ -143,7 +143,7 @@ static int column2id(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)) return i; @@ -154,9 +154,8 @@ static int column2id(const char *name, size_t namesz) 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]; }