Fix: libcounter bad compare
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 26 Nov 2020 20:38:19 +0000 (15:38 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 26 Nov 2020 20:38:19 +0000 (15:38 -0500)
Identified by Coverity.

>>>     CID 1437325:  Incorrect expression  (BAD_COMPARE)
>>>     Comparing pointer "counter_cpu_fds" against "NULL" using anything besides "==" or "!=" is likely to be incorrect.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0d21112a0266d67fafde7a6b81e0062a7a43dce0

libcounter/counter.c

index 640705d32d4bdc7d2f8e50d951c781bf17d633cf..91506faf084fcbdf253855f35ff34e50b0017924 100644 (file)
@@ -188,7 +188,7 @@ int validate_args(const struct lib_counter_config *config,
                return -1;
        if (!(config->alloc & COUNTER_ALLOC_PER_CPU) && counter_cpu_fds)
                return -1;
-       if (!(config->alloc & COUNTER_ALLOC_PER_CPU) && counter_cpu_fds >= 0)
+       if (!(config->alloc & COUNTER_ALLOC_PER_CPU) && nr_counter_cpu_fds >= 0)
                return -1;
        if (counter_cpu_fds && nr_cpus != nr_counter_cpu_fds)
                return -1;
This page took 0.027469 seconds and 4 git commands to generate.