@@ -218,8 +218,9 @@ void write_irqcpu_stats(struct stats_irqcpu *st_ic[], int ic_nr, int dis,
218
218
char * prev_string , char * curr_string )
219
219
{
220
220
struct stats_cpu * scc ;
221
- int j = 0 , offset , cpu ;
221
+ int j = 0 , offset , cpu , colwidth [ NR_IRQS ] ;
222
222
struct stats_irqcpu * p , * q , * p0 , * q0 ;
223
+ char fmtspec [MAX_IRQ_LEN ];
223
224
224
225
/*
225
226
* Check if number of interrupts has changed.
@@ -253,6 +254,22 @@ void write_irqcpu_stats(struct stats_irqcpu *st_ic[], int ic_nr, int dis,
253
254
printf ("\n" );
254
255
}
255
256
257
+ /* Calculate column widths */
258
+ for (j = 0 ; j < ic_nr ; j ++ ) {
259
+ p0 = st_ic [curr ] + j ;
260
+ if (p0 -> irq_name [0 ] != '\0' ) {
261
+ /* Width is IRQ name + 2 for the trailing "/s" */
262
+ colwidth [j ] = strlen (p0 -> irq_name ) + 2 ;
263
+ /*
264
+ * Normal space for printing a number is 14 chars
265
+ * (space + 10 digits + period + mantissa).
266
+ */
267
+ if (colwidth [j ] < 14 ) {
268
+ colwidth [j ] = 10 ;
269
+ }
270
+ }
271
+ }
272
+
256
273
for (cpu = 1 ; cpu <= cpu_nr ; cpu ++ ) {
257
274
258
275
scc = st_cpu [curr ] + cpu ;
@@ -305,7 +322,8 @@ void write_irqcpu_stats(struct stats_irqcpu *st_ic[], int ic_nr, int dis,
305
322
if (!strcmp (p0 -> irq_name , q0 -> irq_name ) || !interval ) {
306
323
p = st_ic [curr ] + (cpu - 1 ) * ic_nr + j ;
307
324
q = st_ic [prev ] + (cpu - 1 ) * ic_nr + offset ;
308
- printf (" %10.2f" ,
325
+ snprintf (fmtspec , sizeof (fmtspec ), " %%%d.2f" , colwidth [j ]);
326
+ printf (fmtspec ,
309
327
S_VALUE (q -> interrupt , p -> interrupt , itv ));
310
328
}
311
329
else
0 commit comments