]> granicus.if.org Git - procps-ng/commitdiff
lib: Initialise uptime variables
authorCraig Small <csmall@dropbear.xyz>
Tue, 2 Nov 2021 06:23:37 +0000 (17:23 +1100)
committerCraig Small <csmall@dropbear.xyz>
Tue, 2 Nov 2021 06:23:37 +0000 (17:23 +1100)
upminutes and uphours could both not get initialised in the
procps_uptime_sprint_short() function.

Error was probably introduced at the referenced commit.

References:
 Coverity 240787 Uninitialized scalar variable
 Coverity 240776 Uninitialized scalar variable
 commit 0496b39876d569fe1cecb76ad5ef212cd14c0374

Signed-off-by: Craig Small <csmall@dropbear.xyz>
proc/uptime.c

index 39ba51883e7ed9951da28789f904351427dfc7d0..088cd68a8b6a446ad79c5d83fdf2e0f554efff8c 100644 (file)
@@ -151,7 +151,7 @@ PROCPS_EXPORT char *procps_uptime_sprint(void)
  */
 PROCPS_EXPORT char *procps_uptime_sprint_short(void)
 {
-    int updecades, upyears, upweeks, updays, uphours, upminutes;
+    int updecades, upyears, upweeks, updays, uphours, upminutes = 0;
     int pos = 3;
     int comma = 0;
     double uptime_secs, idle_secs;