]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
scriptreplay: fix uninitialized value [coverity scan]
authorKarel Zak <kzak@redhat.com>
Tue, 4 Jun 2024 11:19:13 +0000 (13:19 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 4 Jun 2024 11:19:13 +0000 (13:19 +0200)
* fix uninitialized value "rc"

* simplify if(rc) block

Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/scriptreplay.c

index 7535c8586614355de9f1898464c814a5766bd07d..a2afd1c86d728f6e5eb69aca1a0dacbbce40465f 100644 (file)
@@ -168,7 +168,7 @@ main(int argc, char *argv[])
                   *log_tm = NULL;
        double divi = 1;
        int diviopt = FALSE, idx;
-       int ch, rc, crmode = REPLAY_CRMODE_AUTO, summary = 0;
+       int ch, rc = 0, crmode = REPLAY_CRMODE_AUTO, summary = 0;
        enum {
                OPT_SUMMARY = CHAR_MAX + 1
        };
@@ -340,13 +340,12 @@ main(int argc, char *argv[])
                                        replay_set_delay_div(setup, divi);
                                } else if (ch == 'C') { /* Right arrow */
                                        rc = replay_emit_step_data(setup, step, STDOUT_FILENO);
-                                       if (!rc) {
+                                       if (!rc)
                                                rc = replay_get_next_step(setup, streams, &step);
-                                               if (!rc) {
-                                                       struct timeval *delay = replay_step_get_delay(step);
-                                                       if (delay && timerisset(delay))
-                                                               step_delay = *delay;
-                                               }
+                                       if (!rc) {
+                                               struct timeval *delay = replay_step_get_delay(step);
+                                               if (delay && timerisset(delay))
+                                                       step_delay = *delay;
                                        }
                                }
                        }
@@ -373,7 +372,7 @@ main(int argc, char *argv[])
                        rc = replay_emit_step_data(setup, step, STDOUT_FILENO);
                if (rc)
                        break;
-               
+
                rc = replay_get_next_step(setup, streams, &step);
                if (rc)
                        break;