summaryrefslogtreecommitdiffstats
path: root/sys-utils/swapon.c
diff options
context:
space:
mode:
authorKarel Zak2014-04-03 10:57:05 +0200
committerKarel Zak2014-04-03 12:29:20 +0200
commite516634844464b5854b0f7ef182de1d66ab40947 (patch)
tree02d106f76fad4208a2319624dbb5563c11d56a0e /sys-utils/swapon.c
parentprlimit: clean up scols usage (diff)
downloadkernel-qcow2-util-linux-e516634844464b5854b0f7ef182de1d66ab40947.tar.gz
kernel-qcow2-util-linux-e516634844464b5854b0f7ef182de1d66ab40947.tar.xz
kernel-qcow2-util-linux-e516634844464b5854b0f7ef182de1d66ab40947.zip
swapon: clean up scols usage
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/swapon.c')
-rw-r--r--sys-utils/swapon.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 9e3a1faf8..a3cfbabc8 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -150,10 +150,8 @@ static void add_scols_line(struct libscols_table *table, struct libmnt_fs *fs, i
assert(fs);
line = scols_table_new_line(table, NULL);
- if (!line) {
- warn(_("failed to add line to output"));
- return;
- }
+ if (!line)
+ err(EXIT_FAILURE, _("failed to initialize output line"));
for (i = 0; i < ncolumns; i++) {
char *str = NULL;
@@ -190,7 +188,7 @@ static void add_scols_line(struct libscols_table *table, struct libmnt_fs *fs, i
}
if (str)
- scols_line_set_data(line, i, str);
+ scols_line_refer_data(line, i, str);
}
return;
}
@@ -231,8 +229,7 @@ static int show_table(int bytes)
struct libmnt_table *st = get_swaps();
struct libmnt_iter *itr = NULL;
struct libmnt_fs *fs;
-
- int i, rc = 0;
+ int i;
struct libscols_table *table = NULL;
if (!st)
@@ -243,31 +240,26 @@ static int show_table(int bytes)
err(EXIT_FAILURE, _("failed to initialize libmount iterator"));
table = scols_new_table(NULL);
- if (!table) {
- warn(_("failed to initialize output table"));
- goto done;
- }
+ if (!table)
+ err(EXIT_FAILURE, _("failed to initialize output table"));
+
scols_table_set_raw(table, raw);
scols_table_set_no_headings(table, no_headings);
for (i = 0; i < ncolumns; i++) {
struct colinfo *col = get_column_info(i);
- if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
- warnx(_("failed to initialize output column"));
- rc = -1;
- goto done;
- }
+ if (!scols_table_new_column(table, col->name, col->whint, col->flags))
+ err(EXIT_FAILURE, _("failed to initialize output column"));
}
while (mnt_table_next_fs(st, itr, &fs) == 0)
add_scols_line(table, fs, bytes);
scols_print_table(table);
- done:
- mnt_free_iter(itr);
scols_unref_table(table);
- return rc;
+ mnt_free_iter(itr);
+ return 0;
}
/* calls mkswap */