@@ -406,6 +406,7 @@ void xml_close(
406
406
int i , j , at , max ;
407
407
ip_t * addr ;
408
408
char name [MAX_FORMAT_STR ];
409
+ char buf [128 ];
409
410
410
411
printf ("<?xml version=\"1.0\"?>\n" );
411
412
printf ("<MTR SRC=\"%s\" DST=\"%s\"" , ctl -> LocalHostname ,
@@ -438,9 +439,6 @@ void xml_close(
438
439
if (j <= 0 )
439
440
continue ; /* Field nr 0, " " shouldn't be printed in this method. */
440
441
441
- snprintf (name , sizeof (name ), "%s%s%s" , " <%s>" ,
442
- data_fields [j ].format , "</%s>\n" );
443
-
444
442
/* XML doesn't allow "%" in tag names, rename Loss% to just Loss */
445
443
title = data_fields [j ].title ;
446
444
if (strcmp (data_fields [j ].title , "Loss%" ) == 0 ) {
@@ -449,11 +447,12 @@ void xml_close(
449
447
450
448
/* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
451
449
if (strchr (data_fields [j ].format , 'f' )) {
452
- printf (name ,
453
- title , data_fields [j ].net_xxx (at ) / 1000.0 , title );
450
+ snprintf (buf , sizeof (buf ), data_fields [j ].format , data_fields [j ].net_xxx (at ) / 1000.0 );
454
451
} else {
455
- printf ( name , title , data_fields [j ].net_xxx (at ), title );
452
+ snprintf ( buf , sizeof ( buf ) , data_fields [j ].format , data_fields [ j ]. net_xxx (at ));
456
453
}
454
+ trim (buf , 0 );
455
+ printf (" <%s>%s</%s>\n" , title , buf , title );
457
456
}
458
457
printf (" </HUB>\n" );
459
458
}
0 commit comments