Skip to content

Commit 52cac54

Browse files
[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
1 parent 7313a6d commit 52cac54

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎openmp/runtime/src/kmp_affinity.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2386,7 +2386,10 @@ static bool __kmp_affinity_create_cpuinfo_map(int *line,
23862386
unsigned val;
23872387
if ((p == NULL) || (KMP_SSCANF(p + 1, "%u\n", &val) != 1))
23882388
goto no_val;
2389-
KMP_ASSERT(nodeIdIndex + level <= maxIndex);
2389+
// validate the input before using level:
2390+
if (level > (unsigned)__kmp_xproc) { // level is too big
2391+
level = __kmp_xproc;
2392+
}
23902393
if (threadInfo[num_avail][nodeIdIndex + level] != UINT_MAX)
23912394
goto dup_field;
23922395
threadInfo[num_avail][nodeIdIndex + level] = val;

‎openmp/runtime/src/kmp_alloc.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ static void bpool(kmp_info_t *th, void *buf, bufsize len) {
883883
__kmp_bget_dequeue(th); /* Release any queued buffers */
884884

885885
#ifdef SizeQuant
886-
len &= ~(SizeQuant - 1);
886+
len &= ~((bufsize)(SizeQuant - 1));
887887
#endif
888888
if (thr->pool_len == 0) {
889889
thr->pool_len = len;

‎openmp/runtime/src/kmp_dispatch.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,8 @@ void __kmp_dispatch_init_algorithm(ident_t *loc, int gtid,
668668
case kmp_sch_static_chunked:
669669
case kmp_sch_dynamic_chunked:
670670
dynamic_init:
671+
if (tc == 0)
672+
break;
671673
if (pr->u.p.parm1 <= 0)
672674
pr->u.p.parm1 = KMP_DEFAULT_CHUNK;
673675
else if (pr->u.p.parm1 > tc)

0 commit comments

Comments
 (0)