[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/3] xenbaked: properly use time_t in dump_stats()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 18 Aug 2022 16:05:37 +0200
  • 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=ikzkcZ37zHqRA4Dqg0pshN1gxxIDaS6qACe6NnbT6Qk=; b=AIN7gmgZOpPgJUq94pOgGKuqkUmbKz0clooKrCLSNQuRhxZLKTTJv8IQENxuC6vSIDfrnzbCMIwBInLmSJi4gux1XeQe9I5kD8FObyW8f70OkJD9+P85Ye2/QHGRINKELk2jJpxySTZqBiz19U7Q/rOQnicLPWaYqLdR+wE/cUC+63Mik530t7sUga/kzKPQQE6BDfyUZE+ILMVPN+XYBBTSM2XuLQbiaqI482Vdl8fO6zeJM2bUiqeCbvlb+FuRxc4Dq9XHFnZD8seAL1U0Ua/8E7uOBtulBtiz9/JoMwsO98CDRHN6MLb1J6ur+9vU2DSJfk8TUUIrGltxGc422g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ja7fNlj6APz6aoc3bsYXpBkJccaGpTRFgpUx7arLTOFFHrTSi2pnmy2/9Fvmzaak7qA1wai7gE5/69SxsfzCVrI0rxKm3PBAo+SRIIK97Mx6wJxM5tghgh4v9VSPtPSy2LXbDxA/EmAMeLDYxari4TDDC7a3/4HUvkbo1j0io2Y9ZJ+/NGIxvok3KoknGWtNJ74gGfaDZoYao5kKtYJOuDZU05x/k4tTurW/jZfzi5V4rYu9cnctO+j617kvpEunnIIvRXxO3CbGp59hwX4IW44Il7dOtyYqwyc20wxfkXXp7ScBMFzxMeXYpn28/apUF989YCXd4aqvnDmI8dNhsQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Anthony Perard <anthony.perard@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 18 Aug 2022 14:05:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

"int" is not a suitable type to convert time()'s return value to. Avoid
casts and other extra fiddling by using difftime(), on the assumption
that the overhead of using "double" doesn't matter here.

Coverity ID: 1509374
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- unstable.orig/tools/xenmon/xenbaked.c       2022-01-06 16:12:39.000000000 
+0100
+++ unstable/tools/xenmon/xenbaked.c    2022-08-18 15:36:39.918706853 +0200
@@ -230,11 +230,7 @@ static void check_gotten_sum(void)
 static void dump_stats(void) 
 {
     stat_map_t *smt = stat_map;
-    time_t end_time, run_time;
-
-    time(&end_time);
-
-    run_time = end_time - start_time;
+    double run_time = difftime(time(NULL), start_time);
 
     printf("Event counts:\n");
     while (smt->text != NULL) {
@@ -242,13 +238,11 @@ static void dump_stats(void)
         smt++;
     }
 
-    printf("processed %d total records in %d seconds (%ld per second)\n",
-           rec_count, (int)run_time,
-           run_time ? (long)(rec_count/run_time) : 0L);
+    printf("processed %d total records in %0f seconds (%0f per second)\n",
+           rec_count, run_time, run_time ? rec_count / run_time : 0);
 
-    printf("woke up %d times in %d seconds (%ld per second)\n",
-           wakeups, (int) run_time,
-           run_time ? (long)(wakeups/run_time) : 0L);
+    printf("woke up %d times in %0f seconds (%0f per second)\n",
+           wakeups, run_time, run_time ? wakeups / run_time : 0);
 
     check_gotten_sum();
 }




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.