From 55ff8562b906794ed427e18a0257c16023568962 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 23 Jun 2026 14:42:09 +0200 Subject: [PATCH 1/2] Fix comparison-with-wider-type CodeQL issue CodeQL has complained about a loop with heap_num variable of 16 bit type and n_heaps of 32 bit type. --- src/coreclr/gc/gcinternal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/gcinternal.h b/src/coreclr/gc/gcinternal.h index faebce7fbf38a3..94976807c28623 100644 --- a/src/coreclr/gc/gcinternal.h +++ b/src/coreclr/gc/gcinternal.h @@ -1325,10 +1325,10 @@ class heap_select uint16_t proc_no[MAX_SUPPORTED_HEAPS]; uint16_t node_no[MAX_SUPPORTED_HEAPS]; uint16_t max_node_no = 0; - uint16_t heap_num; + int heap_num; for (heap_num = 0; heap_num < n_heaps; heap_num++) { - if (!GCToOSInterface::GetProcessorForHeap (heap_num, &proc_no[heap_num], &node_no[heap_num])) + if (!GCToOSInterface::GetProcessorForHeap ((uint16_t)heap_num, &proc_no[heap_num], &node_no[heap_num])) break; assert(proc_no[heap_num] < GCToOSInterface::GetMaxProcessorCount()); if (!do_numa || node_no[heap_num] == NUMA_NODE_UNDEFINED) From 92407211307361863f3f0eaf793b96f29af95779 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Tue, 23 Jun 2026 14:56:26 +0200 Subject: [PATCH 2/2] Copilot feedback --- src/coreclr/gc/gcinternal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/gcinternal.h b/src/coreclr/gc/gcinternal.h index 94976807c28623..f39def775faa3d 100644 --- a/src/coreclr/gc/gcinternal.h +++ b/src/coreclr/gc/gcinternal.h @@ -1328,7 +1328,7 @@ class heap_select int heap_num; for (heap_num = 0; heap_num < n_heaps; heap_num++) { - if (!GCToOSInterface::GetProcessorForHeap ((uint16_t)heap_num, &proc_no[heap_num], &node_no[heap_num])) + if (!GCToOSInterface::GetProcessorForHeap (static_cast(heap_num), &proc_no[heap_num], &node_no[heap_num])) break; assert(proc_no[heap_num] < GCToOSInterface::GetMaxProcessorCount()); if (!do_numa || node_no[heap_num] == NUMA_NODE_UNDEFINED)