From: Karel Zak Date: Thu, 25 Feb 2021 08:57:49 +0000 (+0100) Subject: irqtop: small cleanup X-Git-Tag: v2.37-rc1~90 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=61074478fa4066113944ed7496516951c4f3aa06;p=thirdparty%2Futil-linux.git irqtop: small cleanup Signed-off-by: Karel Zak --- diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c index 79dce481e5..4fb064251f 100644 --- a/sys-utils/irq-common.c +++ b/sys-utils/irq-common.c @@ -165,18 +165,22 @@ static struct libscols_table *new_scols_table(struct irq_output *out) return NULL; } +static struct libscols_line *new_scols_line(struct libscols_table *table) +{ + struct libscols_line *line = scols_table_new_line(table, NULL); + if (!line) { + warn(_("failed to add line to output")); + return NULL; + } + return line; +} + static void add_scols_line(struct irq_output *out, struct irq_info *info, struct libscols_table *table) { size_t i; - struct libscols_line *line; - - line = scols_table_new_line(table, NULL); - if (!line) { - warn(_("failed to add line to output")); - return; - } + struct libscols_line *line = new_scols_line(table); for (i = 0; i < out->ncolumns; i++) { char *str = NULL; @@ -460,11 +464,9 @@ struct libscols_table *get_scols_cpus_table(struct irq_output *out, } /* per cpu % of total */ - ln = scols_table_new_line(table, NULL); - if (!ln) { - warn(_("failed to add line to output")); + ln = new_scols_line(table); + if (!ln) goto err; - } if (!out->json) scols_line_set_data(ln, 0, "%irq:"); @@ -478,13 +480,11 @@ struct libscols_table *get_scols_cpus_table(struct irq_output *out, } /* per cpu % of delta */ - ln = scols_table_new_line(table, NULL); - if (!ln) { - warn(_("failed to add line to output")); + ln = new_scols_line(table); + if (!ln) goto err; - } if (!out->json) - scols_line_set_data(ln, 0, "%delta:"); + scols_line_set_data(ln, 0, _("%delta:")); for (i = 0; i < curr->nr_active_cpu; i++) { struct irq_cpu *cpu = &curr->cpus[i]; diff --git a/sys-utils/irq-common.h b/sys-utils/irq-common.h index 5dbc652f64..c4f1fa3a25 100644 --- a/sys-utils/irq-common.h +++ b/sys-utils/irq-common.h @@ -27,8 +27,8 @@ struct irq_cpu { }; struct irq_stat { - unsigned int nr_irq; /* number of irq vector */ - unsigned int nr_irq_info; /* number of irq info */ + unsigned long nr_irq; /* number of irq vector */ + unsigned long nr_irq_info; /* number of irq info */ struct irq_info *irq_info; /* array of irq_info */ struct irq_cpu *cpus; /* array of irq_cpu */ size_t nr_active_cpu; /* number of active cpu */