From 7379717ddfd8a0834f7fde0aaab8ffa95d39b8be Mon Sep 17 00:00:00 2001
From: Xue Song <xuesong@cn.fujitsu.com>
Date: Mon, 31 May 2021 17:36:18 +0900
Subject: [PATCH] Remove duplicate code In the UE executable, delete the
 initialization of NR.nrrrc and check the NULL of NR.nrrrc

---
 executables/nr-softmodem.c                | 25 -----------------------
 executables/nr-uesoftmodem.c              |  4 ----
 openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c |  2 +-
 3 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index b803b6e79ea..7fb9f8b19f9 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -377,31 +377,6 @@ int create_gNB_tasks(uint32_t gnb_nb) {
     }
   }
 
-  if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==1)){
-    if (gnb_nb > 0) {
-      if(NGAP_CONF_MODE){
-        if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) {
-          LOG_E(NGAP, "Create task for NGAP failed\n");
-          return -1;
-        }
-      } else {
-          LOG_E(NGAP, "Ngap task not created\n");
-      }
-
-      if(!emulate_rf){
-        if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) {
-          LOG_E(UDP_, "Create task for UDP failed\n");
-          return -1;
-        }
-      }
-
-      if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) {
-        LOG_E(GTPU, "Create task for GTPV1U failed\n");
-        return -1;
-      }
-    }
-  }
-
   if (gnb_nb > 0) {
     if (itti_create_task (TASK_GNB_APP, gNB_app_task, NULL) < 0) {
       LOG_E(GNB_APP, "Create task for gNB APP failed\n");
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index 4bdcfa23a0e..a61f3ea8811 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -452,10 +452,6 @@ int main( int argc, char **argv ) {
 #endif
   LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
 
-  RC.nrrrc = (gNB_RRC_INST **)malloc(1*sizeof(gNB_RRC_INST *));
-  RC.nrrrc[0] = (gNB_RRC_INST*)malloc(sizeof(gNB_RRC_INST));
-  RC.nrrrc[0]->node_type = ngran_gNB;
-
   init_NR_UE(1,rrc_config_path);
   if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa)
 	  init_pdcp();
diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
index 7c69b72c2a2..fa504bb1bf1 100644
--- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
+++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
@@ -607,7 +607,7 @@ srb_found:
   LOG_D(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, srb_id, size);
   //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]);
   //printf("\n");
-  if (!NODE_IS_CU(RC.nrrrc[0]->node_type)) {
+  if ((RC.nrrrc == NULL) || (!NODE_IS_CU(RC.nrrrc[0]->node_type))) {
     ctxt.module_id = 0;
     ctxt.enb_flag = 1;
     ctxt.instance = 0;
-- 
GitLab