char *prev_string, char *curr_string)
{
struct stats_cpu *scc;
- int j = 0, offset, cpu, colwidth;
+ int j = 0, offset, cpu, colwidth[NR_IRQS];
struct stats_irqcpu *p, *q, *p0, *q0;
char fmtspec[MAX_IRQ_LEN];
printf("\n");
}
+ /* Calculate column widths */
+ for (j = 0; j < ic_nr; j++) {
+ p0 = st_ic[curr] + j;
+ if (p0->irq_name[0] != '\0') { /* Nb of irq per proc may have varied... */
+ /* Width is IRQ name + 2 for the trailing "/s" */
+ colwidth[j] = strlen(p0->irq_name) + 2;
+ /* normal space for printing a number is 14 chars
+ * (space + 10 digits + period + mantissa) */
+ if (colwidth[j] < 14)
+ colwidth[j] = 10;
+ }
+ }
+
for (cpu = 1; cpu <= cpu_nr; cpu++) {
scc = st_cpu[curr] + cpu;
if (!strcmp(p0->irq_name, q0->irq_name) || !interval) {
p = st_ic[curr] + (cpu - 1) * ic_nr + j;
q = st_ic[prev] + (cpu - 1) * ic_nr + offset;
- /* Width is IRQ name + 2 for the /s */
- colwidth=strlen(p0->irq_name)+2;
- /* normal space for printing a number is 14 chars
- * (space + 10 digits + period + mantissa) */
- if(colwidth<14)
- colwidth=10;
- sprintf(fmtspec," %%%d.2f",colwidth);
+ snprintf(fmtspec, sizeof(fmtspec), " %%%d.2f", colwidth[j]);
printf(fmtspec,
S_VALUE(q->interrupt, p->interrupt, itv));
}