[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] xenperf: omit meaningless trailing zeroes from output
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Tue, 21 Dec 2021 10:59:27 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ayGzQ0a7dhRSTBTGqrdb54DYbHONXB0mWBYHh+Q3Iyc=; b=a7roMgcefFSQmtW+8Swq3ejcMXVzUBCsAbuc9yS6l9qKVQ1Rv6hzzMxAeWx73dNA0SDBjpSrgbyTUVvY7LLwa5V8WgeKHVrYac5M2iiBQrYF4t1yGkBLFGIaL4ZcTRp9vD72SDsuW2ExeTMlL59epA81/5rwgBx52YAsyVvJsLo4USx6x8FooEQFwD7lTa7e+aIlGDrDhsUpoZ5piBspsW+x7ozOs/4RuNeoJkC1lFm7EigxhBaQIgprXPBhVpmEsQCgBWspgYl0yzPTaBl/dayU9INEdPyCjminrubFmbhhM+Z3rNOD/VYogjtGpxmkOw/B8BoEkBgLzpFP/PRu4A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iy0FVB/ohj6QEvNN49hIq4jmm/CWfAx/M5DFFbShNCaWlk8OnSq7pzPJaRdHZS9sbXn269Yj9QWch49peL/4th1QEWlc5TASMfKfUKqFGOKcaTMCEFdyg1cY0AktdKZbYwGKqT/B7qOBHYU8NwillY0J5iX/3hKDr147BhZdUZJ0TOmEiSs7VA/v47Nyakcq6hVB2RXXjxPSiITrU7WH32WDNYfiwt6wRHUrN0rS80H9kSvO22mZoC9RkX11HFR6F5ws3jilekA1J/v/mR+DxABoaCW9MDiKKZyLLKUX69ZBuZv1e8Jp9QJ/ctH88Z8aH0eH8TU24TAO3W0JuInxVA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
- Delivery-date: Tue, 21 Dec 2021 09:59:50 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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@xxxxxxxx>
--- 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) )
{
|