misc: consolidate smartcols error messages

... just to keep translators happy

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2017-05-18 11:39:34 +02:00
parent 7f77c5e196
commit 780ce22cda
14 changed files with 106 additions and 85 deletions

View File

@ -169,8 +169,10 @@ void list_disklabel(struct fdisk_context *cxt)
if (fdisk_partition_to_string(pa, cxt, ids[i], &data))
continue;
if (scols_line_refer_data(ln, i, data))
fdisk_warn(cxt, _("failed to refer output data"));
if (scols_line_refer_data(ln, i, data)) {
fdisk_warn(cxt, _("failed to add output data"));
goto done;
}
}
}
@ -267,7 +269,10 @@ void list_freespace(struct fdisk_context *cxt)
for (i = 0; i < ARRAY_SIZE(colids); i++) {
if (fdisk_partition_to_string(pa, cxt, colids[i], &data))
continue;
scols_line_refer_data(ln, i, data);
if (scols_line_refer_data(ln, i, data)) {
fdisk_warn(cxt, _("failed to add output data"));
goto done;
}
}
if (fdisk_partition_has_size(pa))

View File

@ -578,7 +578,7 @@ static int add_scols_line(struct libscols_table *table, blkid_partition par)
line = scols_table_new_line(table, NULL);
if (!line) {
warn(_("failed to add line to output"));
warn(_("failed to allocate output line"));
return -ENOMEM;
}
@ -641,7 +641,7 @@ static int add_scols_line(struct libscols_table *table, blkid_partition par)
else if (str)
rc = scols_line_refer_data(line, i, str);
if (rc) {
warn(_("failed to add data to output table"));
warn(_("failed to add output data"));
break;
}
}
@ -664,7 +664,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
scols_init_debug(0);
table = scols_new_table();
if (!table) {
warn(_("failed to initialize output table"));
warn(_("failed to allocate output table"));
return -1;
}
scols_table_enable_raw(table, !!(scols_flags & PARTX_RAW));
@ -675,7 +675,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
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"));
warnx(_("failed to allocate output column"));
goto done;
}
}

View File

@ -915,7 +915,7 @@ static struct libscols_table *setup_table(struct lslogins_control *ctl)
int n = 0;
if (!table)
errx(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
if (ctl->noheadings)
scols_table_enable_noheadings(table, 1);
@ -972,6 +972,9 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri
return;
ln = scols_table_new_line(tb, NULL);
if (!ln)
err(EXIT_FAILURE, _("failed to allocate output line"));
while (n < ncolumns) {
int rc = 0;
@ -1067,8 +1070,8 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri
err(EXIT_FAILURE, _("internal error: unknown column"));
}
if (rc != 0)
err(EXIT_FAILURE, _("failed to set data"));
if (rc)
err(EXIT_FAILURE, _("failed to add output data"));
++n;
}
return;

View File

@ -120,7 +120,7 @@ static int add_output_data(struct fincore_control *ctl,
ln = scols_table_new_line(ctl->tb, NULL);
if (!ln)
err(EXIT_FAILURE, _("failed to initialize output line"));
err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < ncolumns; i++) {
int rc = 0;
@ -359,7 +359,7 @@ int main(int argc, char ** argv)
scols_init_debug(0);
ctl.tb = scols_new_table();
if (!ctl.tb)
err(EXIT_FAILURE, _("failed to create output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_noheadings(ctl.tb, ctl.noheadings);
scols_table_enable_raw(ctl.tb, ctl.raw);
@ -371,7 +371,7 @@ int main(int argc, char ** argv)
const struct colinfo *col = get_column_info(i);
if (!scols_table_new_column(ctl.tb, col->name, col->whint, col->flags))
err(EXIT_FAILURE, _("failed to initialize output column"));
err(EXIT_FAILURE, _("failed to allocate output column"));
}
for(; optind < argc; optind++) {

View File

@ -684,12 +684,13 @@ static struct libscols_line *add_line(struct libscols_table *table, struct libmn
size_t i;
struct libscols_line *line = scols_table_new_line(table, parent);
if (!line) {
warn(_("failed to add line to output"));
return NULL;
if (!line)
err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < ncolumns; i++) {
if (scols_line_refer_data(line, i, get_data(fs, i)))
err(EXIT_FAILURE, _("failed to add output data"));
}
for (i = 0; i < ncolumns; i++)
scols_line_refer_data(line, i, get_data(fs, i));
scols_line_set_userdata(line, fs);
return line;
@ -701,13 +702,14 @@ static struct libscols_line *add_tabdiff_line(struct libscols_table *table, stru
size_t i;
struct libscols_line *line = scols_table_new_line(table, NULL);
if (!line) {
warn(_("failed to add line to output"));
return NULL;
if (!line)
err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < ncolumns; i++) {
if (scols_line_refer_data(line, i,
get_tabdiff_data(old_fs, new_fs, change, i)))
err(EXIT_FAILURE, _("failed to add output data"));
}
for (i = 0; i < ncolumns; i++)
scols_line_refer_data(line, i,
get_tabdiff_data(old_fs, new_fs, change, i));
return line;
}
@ -1593,7 +1595,7 @@ int main(int argc, char *argv[])
scols_init_debug(0);
table = scols_new_table();
if (!table) {
warn(_("failed to initialize output table"));
warn(_("failed to allocate output table"));
goto leave;
}
scols_table_enable_raw(table, !!(flags & FL_RAW));
@ -1619,7 +1621,7 @@ int main(int argc, char *argv[])
}
if (!scols_table_new_column(table, get_column_name(i),
get_column_whint(i), fl)) {
warn(_("failed to initialize output column"));
warn(_("failed to allocate output column"));
goto leave;
}
}

View File

@ -1161,8 +1161,8 @@ static void set_scols_data(struct blkdev_cxt *cxt, int col, int id, struct libsc
break;
};
if (str)
scols_line_refer_data(ln, col, str);
if (str && scols_line_refer_data(ln, col, str))
err(EXIT_FAILURE, _("failed to add output data"));
}
static void fill_table_line(struct blkdev_cxt *cxt, struct libscols_line *scols_parent)
@ -1171,7 +1171,7 @@ static void fill_table_line(struct blkdev_cxt *cxt, struct libscols_line *scols_
cxt->scols_line = scols_table_new_line(lsblk->table, scols_parent);
if (!cxt->scols_line)
return;
err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < ncolumns; i++)
set_scols_data(cxt, i, get_column_id(i), cxt->scols_line);
@ -1894,7 +1894,7 @@ int main(int argc, char *argv[])
* initialize output columns
*/
if (!(lsblk->table = scols_new_table()))
errx(EXIT_FAILURE, _("failed to initialize output table"));
errx(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(lsblk->table, !!(lsblk->flags & LSBLK_RAW));
scols_table_enable_export(lsblk->table, !!(lsblk->flags & LSBLK_EXPORT));
scols_table_enable_ascii(lsblk->table, !!(lsblk->flags & LSBLK_ASCII));
@ -1916,7 +1916,7 @@ int main(int argc, char *argv[])
cl = scols_table_new_column(lsblk->table, ci->name, ci->whint, fl);
if (!cl) {
warn(_("failed to initialize output column"));
warn(_("failed to allocate output column"));
goto leave;
}
if (!lsblk->sort_col && lsblk->sort_id == id) {

View File

@ -387,10 +387,8 @@ static void add_scols_line(struct libscols_table *table, struct lock *l, struct
assert(table);
line = scols_table_new_line(table, NULL);
if (!line) {
warn(_("failed to add line to output"));
return;
}
if (!line)
err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < ncolumns; i++) {
char *str = NULL;
@ -434,8 +432,8 @@ static void add_scols_line(struct libscols_table *table, struct lock *l, struct
break;
}
if (str)
scols_line_set_data(line, i, str);
if (str && scols_line_set_data(line, i, str))
err(EXIT_FAILURE, _("failed to add output data"));
}
}
@ -447,10 +445,9 @@ static int show_locks(struct list_head *locks)
struct libscols_table *table;
table = scols_new_table();
if (!table) {
warn(_("failed to initialize output table"));
return -1;
}
if (!table)
err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(table, raw);
scols_table_enable_json(table, json);
scols_table_enable_noheadings(table, no_headings);
@ -461,11 +458,8 @@ static int show_locks(struct list_head *locks)
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 allocate output column"));
}
/* prepare data for output */

View File

@ -225,6 +225,7 @@ static int set_scols_data(struct loopdev_cxt *lc, struct libscols_line *ln)
const char *p = NULL; /* external data */
char *np = NULL; /* allocated here */
uint64_t x = 0;
int rc;
switch(get_column_id(i)) {
case COL_NAME:
@ -285,9 +286,12 @@ static int set_scols_data(struct loopdev_cxt *lc, struct libscols_line *ln)
if (p)
scols_line_set_data(ln, i, p); /* calls strdup() */
rc = scols_line_set_data(ln, i, p); /* calls strdup() */
else if (np)
scols_line_refer_data(ln, i, np); /* only refers */
rc = scols_line_refer_data(ln, i, np); /* only refers */
if (rc)
err(EXIT_FAILURE, _("failed to add output data"));
}
return 0;
@ -307,7 +311,7 @@ static int show_table(struct loopdev_cxt *lc,
scols_init_debug(0);
if (!(tb = scols_new_table()))
err(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(tb, raw);
scols_table_enable_json(tb, json);
scols_table_enable_noheadings(tb, no_headings);
@ -319,14 +323,14 @@ static int show_table(struct loopdev_cxt *lc,
struct colinfo *ci = get_column_info(i);
if (!scols_table_new_column(tb, ci->name, ci->whint, ci->flags))
err(EXIT_FAILURE, _("failed to initialize output column"));
err(EXIT_FAILURE, _("failed to allocate output column"));
}
/* only one loopdev requested (already assigned to loopdev_cxt) */
if (loopcxt_get_device(lc)) {
ln = scols_table_new_line(tb, NULL);
if (!ln)
err(EXIT_FAILURE, _("failed to initialize output line"));
err(EXIT_FAILURE, _("failed to allocate output line"));
rc = set_scols_data(lc, ln);
/* list all loopdevs */
@ -355,7 +359,7 @@ static int show_table(struct loopdev_cxt *lc,
ln = scols_table_new_line(tb, NULL);
if (!ln)
err(EXIT_FAILURE, _("failed to initialize output column"));
err(EXIT_FAILURE, _("failed to allocate output line"));
rc = set_scols_data(lc, ln);
if (rc)
break;

View File

@ -1757,7 +1757,7 @@ print_readable(struct lscpu_desc *desc, int cols[], int ncols,
table = scols_new_table();
if (!table)
err(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
if (mod->json) {
scols_table_enable_json(table, 1);
scols_table_set_name(table, "cpus");
@ -1766,7 +1766,7 @@ print_readable(struct lscpu_desc *desc, int cols[], int ncols,
for (i = 0; i < ncols; i++) {
data = get_cell_header(desc, cols[i], mod, buf, sizeof(buf));
if (!scols_table_new_column(table, data, 0, 0))
err(EXIT_FAILURE, _("failed to initialize output column"));
err(EXIT_FAILURE, _("failed to allocate output column"));
}
for (i = 0; i < desc->ncpuspos; i++) {
@ -1783,7 +1783,7 @@ print_readable(struct lscpu_desc *desc, int cols[], int ncols,
line = scols_table_new_line(table, NULL);
if (!line)
err(EXIT_FAILURE, _("failed to initialize output line"));
err(EXIT_FAILURE, _("failed to allocate output line"));
for (c = 0; c < ncols; c++) {
data = get_cell_data(desc, i, cols[c], mod,
@ -1791,7 +1791,7 @@ print_readable(struct lscpu_desc *desc, int cols[], int ncols,
if (!data || !*data)
data = "-";
if (scols_line_set_data(line, c, data))
err_oom();
err(EXIT_FAILURE, _("failed to add output data"));
}
}
@ -1811,7 +1811,7 @@ static void __attribute__ ((__format__(printf, 3, 4)))
va_list args;
if (!ln)
err(EXIT_FAILURE, _("failed to initialize output line"));
err(EXIT_FAILURE, _("failed to allocate output line"));
/* description column */
scols_line_set_data(ln, 0, txt);
@ -1821,8 +1821,8 @@ static void __attribute__ ((__format__(printf, 3, 4)))
xvasprintf(&data, fmt, args);
va_end(args);
if (data)
scols_line_refer_data(ln, 1, data);
if (data && scols_line_refer_data(ln, 1, data))
err(EXIT_FAILURE, _("failed to add output data"));
}
#define add_summary_n(tb, txt, num) add_summary_sprint(tb, txt, "%d", num)
@ -1860,7 +1860,7 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
tb = scols_new_table();
if (!tb)
err(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_noheadings(tb, 1);
if (mod->json) {

View File

@ -335,7 +335,8 @@ static struct libscols_table *new_table(struct lsipc_control *ctl)
struct libscols_table *table = scols_new_table();
if (!table)
errx(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
if (ctl->noheadings)
scols_table_enable_noheadings(table, 1);
@ -466,7 +467,7 @@ static void global_set_data(struct libscols_table *tb, const char *resource,
ln = scols_table_new_line(tb, NULL);
if (!ln)
err_oom();
err(EXIT_FAILURE, _("failed to allocate output line"));
for (n = 0; n < ncolumns; n++) {
int rc = 0;
@ -500,7 +501,7 @@ static void global_set_data(struct libscols_table *tb, const char *resource,
}
if (rc != 0)
err(EXIT_FAILURE, _("failed to set data"));
err(EXIT_FAILURE, _("failed to add output data"));
}
}
@ -538,7 +539,10 @@ static void do_sem(int id, struct lsipc_control *ctl, struct libscols_table *tb)
}
for (semdsp = semds; semdsp->next != NULL || id > -1; semdsp = semdsp->next) {
size_t n;
ln = scols_table_new_line(tb, NULL);
if (!ln)
err(EXIT_FAILURE, _("failed to allocate output line"));
for (n = 0; n < ncolumns; n++) {
int rc = 0;
@ -622,7 +626,7 @@ static void do_sem(int id, struct lsipc_control *ctl, struct libscols_table *tb)
break;
}
if (rc != 0)
err(EXIT_FAILURE, _("failed to set data"));
err(EXIT_FAILURE, _("failed to add output data"));
arg = NULL;
}
@ -639,6 +643,9 @@ static void do_sem(int id, struct lsipc_control *ctl, struct libscols_table *tb)
struct sem_elem *e = &semds->elements[i];
struct libscols_line *sln = scols_table_new_line(sub, NULL);
if (!sln)
err(EXIT_FAILURE, _("failed to allocate output line"));
/* SEMNUM */
xasprintf(&arg, "%zu", i);
rc = scols_line_refer_data(sln, 0, arg);
@ -728,6 +735,9 @@ static void do_msg(int id, struct lsipc_control *ctl, struct libscols_table *tb)
size_t n;
ln = scols_table_new_line(tb, NULL);
if (!ln)
err(EXIT_FAILURE, _("failed to allocate output line"));
/* no need to call getpwuid() for the same user */
if (!(pw && pw->pw_uid == msgdsp->msg_perm.uid))
pw = getpwuid(msgdsp->msg_perm.uid);
@ -885,8 +895,9 @@ static void do_shm(int id, struct lsipc_control *ctl, struct libscols_table *tb)
for (shmdsp = shmds; shmdsp->next != NULL || id > -1 ; shmdsp = shmdsp->next) {
size_t n;
ln = scols_table_new_line(tb, NULL);
if (!ln)
err_oom();
err(EXIT_FAILURE, _("failed to allocate output line"));
for (n = 0; n < ncolumns; n++) {
int rc = 0;

View File

@ -226,7 +226,7 @@ static void add_scols_line(struct libscols_table *table, struct prlimit *l)
line = scols_table_new_line(table, NULL);
if (!line)
err(EXIT_FAILURE, _("failed to initialize output line"));
err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < ncolumns; i++) {
char *str = NULL;
@ -257,8 +257,8 @@ static void add_scols_line(struct libscols_table *table, struct prlimit *l)
break;
}
if (str)
scols_line_refer_data(line, i, str);
if (str && scols_line_refer_data(line, i, str))
err(EXIT_FAILURE, _("failed to add output data"));
}
}
@ -294,7 +294,7 @@ static int show_limits(struct list_head *lims)
table = scols_new_table();
if (!table)
err(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(table, raw);
scols_table_enable_noheadings(table, no_headings);
@ -303,10 +303,9 @@ static int show_limits(struct list_head *lims)
struct colinfo *col = get_column_info(i);
if (!scols_table_new_column(table, col->name, col->whint, col->flags))
err(EXIT_FAILURE, _("failed to initialize output column"));
err(EXIT_FAILURE, _("failed to allocate output column"));
}
list_for_each_safe(p, pnext, lims) {
struct prlimit *lim = list_entry(p, struct prlimit, lims);

View File

@ -173,7 +173,8 @@ static void add_scols_line(const struct swapon_ctl *ctl, struct libscols_table *
line = scols_table_new_line(table, NULL);
if (!line)
err(EXIT_FAILURE, _("failed to initialize output line"));
err(EXIT_FAILURE, _("failed to allocate output line"));
data = mnt_fs_get_source(fs);
if (access(data, R_OK) == 0)
pr = get_swap_prober(data);
@ -219,8 +220,8 @@ static void add_scols_line(const struct swapon_ctl *ctl, struct libscols_table *
break;
}
if (str)
scols_line_refer_data(line, i, str);
if (str && scols_line_refer_data(line, i, str))
err(EXIT_FAILURE, _("failed to add output data"));
}
if (pr)
blkid_free_probe(pr);
@ -277,7 +278,7 @@ static int show_table(struct swapon_ctl *ctl)
table = scols_new_table();
if (!table)
err(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(table, ctl->raw);
scols_table_enable_noheadings(table, ctl->no_heading);
@ -286,7 +287,7 @@ static int show_table(struct swapon_ctl *ctl)
struct colinfo *col = get_column_info(ctl, i);
if (!scols_table_new_column(table, col->name, col->whint, col->flags))
err(EXIT_FAILURE, _("failed to initialize output column"));
err(EXIT_FAILURE, _("failed to allocate output column"));
}
while (mnt_table_next_fs(st, itr, &fs) == 0)

View File

@ -212,7 +212,7 @@ static void add_flag_line(struct libscols_table *table, struct wdinfo *wd, const
line = scols_table_new_line(table, NULL);
if (!line) {
warn(_("failed to initialize output line"));
warn(_("failed to allocate output line"));
return;
}
@ -239,8 +239,10 @@ static void add_flag_line(struct libscols_table *table, struct wdinfo *wd, const
break;
}
if (str)
scols_line_set_data(line, i, str);
if (str && scols_line_set_data(line, i, str)) {
warn(_("failed to add output data"));
break;
}
}
}
@ -256,7 +258,7 @@ static int show_flags(struct wdinfo *wd, uint32_t wanted)
/* create output table */
table = scols_new_table();
if (!table) {
warn(_("failed to initialize output table"));
warn(_("failed to allocate output table"));
return -1;
}
scols_table_enable_raw(table, raw);
@ -267,7 +269,7 @@ static int show_flags(struct wdinfo *wd, uint32_t wanted)
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"));
warnx(_("failed to allocate output column"));
goto done;
}
}

View File

@ -406,7 +406,7 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
ln = scols_table_new_line(tb, NULL);
if (!ln)
err(EXIT_FAILURE, _("failed to initialize output line"));
err(EXIT_FAILURE, _("failed to allocate output line"));
for (i = 0; i < (size_t) ncolumns; i++) {
char *str = NULL;
@ -471,8 +471,8 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
str = get_mm_stat(z, MM_NUM_MIGRATED, inbytes);
break;
}
if (str)
scols_line_refer_data(ln, i, str);
if (str && scols_line_refer_data(ln, i, str))
err(EXIT_FAILURE, _("failed to add output data"))
}
}
@ -485,7 +485,7 @@ static void status(struct zram *z)
tb = scols_new_table();
if (!tb)
err(EXIT_FAILURE, _("failed to initialize output table"));
err(EXIT_FAILURE, _("failed to allocate output table"));
scols_table_enable_raw(tb, raw);
scols_table_enable_noheadings(tb, no_headings);