From 09e1e6c6fdb3bc4fa4b0d4cfdeb175b874e093cc Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 17 Oct 2025 11:53:20 +0200 Subject: [PATCH] Rewrite NR_MAC UE_iterator() to limit variable scope Especially in pf_dl()/pf_ul(), we use a first loop using UE_iterator(), then iterate over a subset of UEs. It has happened a couple of times that I was using variable "UE" (from the iterator), when it should only be used in the first UE_iterator() loop. Rewrite UE_iterator() to effectively limit the scope of the iterator variables to the body of the UE_iterator. This should also make it possible to reuse multiple UE_iterator()s with the same variables in sequence. --- openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 5bd786df90..f64b94fb47 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -819,7 +819,7 @@ typedef struct { nr_beam_mode_t beam_mode; } NR_beam_info_t; -#define UE_iterator(BaSe, VaR) NR_UE_info_t ** VaR##pptr=BaSe, *VaR; while ((VaR=*(VaR##pptr++))) +#define UE_iterator(BaSe, VaR) for (NR_UE_info_t **VaR##pptr=BaSe, *VaR=*VaR##pptr; VaR; VaR=*(++VaR##pptr)) typedef struct { /// current frame for DCI