[Openmp-commits] [openmp] 52cac54 - [OpenMP] libomp: cleanup: minor fixes to silence static analyzer.
via Openmp-commits
openmp-commits at lists.llvm.org
Mon Aug 16 03:39:34 PDT 2021
Author: AndreyChurbanov
Date: 2021-08-16T13:39:23+03:00
New Revision: 52cac541d4316a516632f6b71ab6d0a1d7c2be37
URL: https://github.com/llvm/llvm-project/commit/52cac541d4316a516632f6b71ab6d0a1d7c2be37
DIFF: https://github.com/llvm/llvm-project/commit/52cac541d4316a516632f6b71ab6d0a1d7c2be37.diff
LOG: [OpenMP] libomp: cleanup: minor fixes to silence static analyzer.
Added couple more checks to silence KlocWork static code analyzer.
Differential Revision: https://reviews.llvm.org/D107348
Added:
Modified:
openmp/runtime/src/kmp_affinity.cpp
openmp/runtime/src/kmp_alloc.cpp
openmp/runtime/src/kmp_dispatch.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index d0a70d292a51..404586487f4b 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -2386,7 +2386,10 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line,
unsigned val;
if ((p == NULL) || (KMP_SSCANF(p + 1, "%u\n", &val) != 1))
goto no_val;
- KMP_ASSERT(nodeIdIndex + level <= maxIndex);
+ // validate the input before using level:
+ if (level > (unsigned)__kmp_xproc) { // level is too big
+ level = __kmp_xproc;
+ }
if (threadInfo[num_avail][nodeIdIndex + level] != UINT_MAX)
goto dup_field;
threadInfo[num_avail][nodeIdIndex + level] = val;
diff --git a/openmp/runtime/src/kmp_alloc.cpp b/openmp/runtime/src/kmp_alloc.cpp
index d379e71f921e..a67d298ec756 100644
--- a/openmp/runtime/src/kmp_alloc.cpp
+++ b/openmp/runtime/src/kmp_alloc.cpp
@@ -883,7 +883,7 @@ static void bpool(kmp_info_t *th, void *buf, bufsize len) {
__kmp_bget_dequeue(th); /* Release any queued buffers */
#ifdef SizeQuant
- len &= ~(SizeQuant - 1);
+ len &= ~((bufsize)(SizeQuant - 1));
#endif
if (thr->pool_len == 0) {
thr->pool_len = len;
diff --git a/openmp/runtime/src/kmp_dispatch.cpp b/openmp/runtime/src/kmp_dispatch.cpp
index cc2d0012bf38..c97ffb2dd336 100644
--- a/openmp/runtime/src/kmp_dispatch.cpp
+++ b/openmp/runtime/src/kmp_dispatch.cpp
@@ -668,6 +668,8 @@ void __kmp_dispatch_init_algorithm(ident_t *loc, int gtid,
case kmp_sch_static_chunked:
case kmp_sch_dynamic_chunked:
dynamic_init:
+ if (tc == 0)
+ break;
if (pr->u.p.parm1 <= 0)
pr->u.p.parm1 = KMP_DEFAULT_CHUNK;
else if (pr->u.p.parm1 > tc)
More information about the Openmp-commits
mailing list