]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
irqtop: small cleanup
authorKarel Zak <kzak@redhat.com>
Thu, 25 Feb 2021 08:57:49 +0000 (09:57 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 25 Feb 2021 08:57:49 +0000 (09:57 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/irq-common.c
sys-utils/irq-common.h

index 79dce481e59836ea17c20739ed482788f577c2e0..4fb064251fa41cb1235dad843588a583fe4531bf 100644 (file)
@@ -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];
index 5dbc652f6434a4c235d8645474ed8f203fdeb55b..c4f1fa3a25b62433a93bc5aa287806ac141f1100 100644 (file)
@@ -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 */