Fix bugs found by static analysis. 49/305449/1
authorMichal Bloch <m.bloch@samsung.com>
Thu, 1 Feb 2024 15:39:10 +0000 (16:39 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 1 Feb 2024 17:59:10 +0000 (18:59 +0100)
Change-Id: I13168087ef460e74c203ab0f0311b91f6f2421f5

src/libdlogutil/logretrieve.c
src/logger/qos.c

index 58a5ca0..f9cca21 100644 (file)
@@ -418,9 +418,9 @@ static int refill_fdi_buffers_special(dlogutil_state_s *state, int timeout)
        }
 
        // FIXME: can the sleep be interrupted via signals etc?
-       // also FIXME: can `needed_timeout` be -1 at this point?
+       if (needed_timeout > 0)
+               usleep(needed_timeout * USEC_PER_MSEC);
 
-       usleep(needed_timeout * USEC_PER_MSEC);
        for (int i = 0; i < state->fd_count; ++i) {
                if (!state->enabled[i])
                        continue;
index b5b7f3b..0959120 100644 (file)
@@ -56,6 +56,9 @@ void qos_create_limits_file(struct qos_module *qos, bool is_limiting)
 
        const int len = aggr_count * 32;
        __attribute__((cleanup(free_ptr))) char *buf = malloc(len);
+       if (!buf)
+               return;
+
        int pos = 0;
        for (int i = 0; i < aggr_count; ++i)
                if (aggr_infos[i].count >= 0) {