All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xenperf: omit meaningless trailing zeroes from output
@ 2021-12-21  9:59 Jan Beulich
  2021-12-21 10:44 ` Anthony PERARD
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2021-12-21  9:59 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Anthony Perard

There's no point producing a long chain of zeroes when the previously
calculated total value was zero. To guard against mistakenly skipping
non-zero individual fields, widen "sum" to "unsigned long long".

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/tools/misc/xenperf.c
+++ b/tools/misc/xenperf.c
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
     DECLARE_HYPERCALL_BUFFER(xc_perfc_val_t, pcv);
     xc_perfc_val_t  *val;
     int num_desc, num_val;
-    unsigned int    sum, reset = 0, full = 0, pretty = 0;
+    unsigned int     reset = 0, full = 0, pretty = 0;
     char hypercall_name[36];
 
     if ( argc > 1 )
@@ -158,14 +158,15 @@ int main(int argc, char *argv[])
     val = pcv;
     for ( i = 0; i < num_desc; i++ )
     {
+        unsigned long long sum = 0;
+
         printf ("%-35s ", pcd[i].name);
         
-        sum = 0;
         for ( j = 0; j < pcd[i].nr_vals; j++ )
             sum += val[j];
-        printf ("T=%10u ", (unsigned int)sum);
+        printf("T=%10llu ", sum);
 
-        if ( full || (pcd[i].nr_vals <= 4) )
+        if ( sum && (full || (pcd[i].nr_vals <= 4)) )
         {
             if ( pretty && (strcmp(pcd[i].name, "hypercalls") == 0) )
             {



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] xenperf: omit meaningless trailing zeroes from output
  2021-12-21  9:59 [PATCH] xenperf: omit meaningless trailing zeroes from output Jan Beulich
@ 2021-12-21 10:44 ` Anthony PERARD
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony PERARD @ 2021-12-21 10:44 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Wei Liu

On Tue, Dec 21, 2021 at 10:59:27AM +0100, Jan Beulich wrote:
> There's no point producing a long chain of zeroes when the previously
> calculated total value was zero. To guard against mistakenly skipping
> non-zero individual fields, widen "sum" to "unsigned long long".
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-21 10:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21  9:59 [PATCH] xenperf: omit meaningless trailing zeroes from output Jan Beulich
2021-12-21 10:44 ` Anthony PERARD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.