summaryrefslogtreecommitdiffstats
path: root/sys-utils/swapon.c
diff options
context:
space:
mode:
authorKarel Zak2014-07-18 13:22:52 +0200
committerKarel Zak2014-07-18 13:53:02 +0200
commita560a3487b4187894c705946a5363b7809c3da51 (patch)
tree8e9f647fb4e86e700bde38c578f04cf5eb06d655 /sys-utils/swapon.c
parentlosetup: clean up columns[] usage (diff)
downloadkernel-qcow2-util-linux-a560a3487b4187894c705946a5363b7809c3da51.tar.gz
kernel-qcow2-util-linux-a560a3487b4187894c705946a5363b7809c3da51.tar.xz
kernel-qcow2-util-linux-a560a3487b4187894c705946a5363b7809c3da51.zip
swapon: clean up columns[] usage
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/swapon.c')
-rw-r--r--sys-utils/swapon.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 77af46557..b50016aff 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -105,8 +105,9 @@ struct colinfo infos[] = {
[COL_USED] = { "USED", 0.20, SCOLS_FL_RIGHT, N_("bytes in use")},
[COL_PRIO] = { "PRIO", 0.20, SCOLS_FL_RIGHT, N_("swap priority")},
};
-#define NCOLS ARRAY_SIZE(infos)
-static int columns[NCOLS], ncolumns;
+
+static int columns[ARRAY_SIZE(infos) * 2];
+static int ncolumns;
static int column_name_to_id(const char *name, size_t namesz)
{
@@ -114,7 +115,7 @@ static int column_name_to_id(const char *name, size_t namesz)
assert(name);
- 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))
@@ -126,9 +127,8 @@ static int column_name_to_id(const char *name, size_t namesz)
static inline 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];
}
@@ -710,7 +710,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
" * if no policy is selected both discard types are enabled. (default)\n"), out);
fputs(_("\nAvailable columns (for --show):\n"), out);
- for (i = 0; i < NCOLS; i++)
+ for (i = 0; i < ARRAY_SIZE(infos); i++)
fprintf(out, " %4s %s\n", infos[i].name, _(infos[i].help));
fprintf(out, USAGE_MAN_TAIL("swapon(8)"));