From d14ad6797e8dabbe9cce08782b8da5f75f28a632 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Fri, 15 Feb 2019 19:18:24 +0100 Subject: [PATCH] Applying the cppcheck fix on last files Signed-off-by: Raphael Defosseux --- .../LAYER2/MAC/eNB_scheduler_primitives.c | 8 +++--- openair2/RRC/LTE/rrc_eNB.c | 2 +- openair2/X2AP/x2ap_eNB_handler.c | 26 +++++++++++++++---- openair3/S1AP/s1ap_eNB_handlers.c | 26 +++++++++++++++++++ openair3/S1AP/s1ap_eNB_nas_procedures.c | 2 +- 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index a8ce15e4a7..deb766e7fe 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -820,11 +820,12 @@ void get_csi_params(COMMON_channels_t *cc, struct LTE_CQI_ReportPeriodic *cqi_ReportPeriodic, uint16_t *Npd, uint16_t *N_OFFSET_CQI, int *H) { + AssertFatal(cqi_ReportPeriodic != NULL, + "cqi_ReportPeriodic is null!\n"); + uint16_t cqi_PMI_ConfigIndex = cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex; uint8_t Jtab[6] = { 0, 2, 2, 3, 4, 4 }; - AssertFatal(cqi_ReportPeriodic != NULL, - "cqi_ReportPeriodic is null!\n"); if (cc->tdd_Config == NULL) { //FDD if (cqi_PMI_ConfigIndex <= 1) { // 2 ms CQI_PMI period @@ -2601,6 +2602,7 @@ int get_nb_subband(int N_RB_DL) { case 15: nb_sb = 4; // sb_size =4 + break; case 25: nb_sb = 7; // sb_size =4, 1 sb with 1PRB, 6 with 2 RBG, each has 2 PRBs @@ -2772,7 +2774,7 @@ dump_CCE_table(int *CCE_table, const int nCCE, break; } - printf("rnti %x, Yk*L = %d, nCCE %d (nCCE/L %d),nb_cand*L %d\n", rnti, + printf("rnti %x, Yk*L = %u, nCCE %d (nCCE/L %d),nb_cand*L %d\n", rnti, Yk * L, nCCE, nCCE / L, nb_candidates * L); } diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index cc3b7a6dc3..5a30ad4822 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -5140,7 +5140,7 @@ rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ct ctxt_pP->module_id, // get_adjacent_cell_mod_id(mobilityInfo->targetPhysCellId), ue_context_pP->ue_context.rnti); mobilityInfo->additionalSpectrumEmission = CALLOC(1, sizeof(*mobilityInfo->additionalSpectrumEmission)); - *mobilityInfo->additionalSpectrumEmission = 1; //Check this value! + *mobilityInfo->additionalSpectrumEmission = (LTE_AdditionalSpectrumEmission_t) 1; //Check this value! mobilityInfo->t304 = LTE_MobilityControlInfo__t304_ms200; // need to configure an appropriate value here // New UE Identity (C-RNTI) to identify an UE uniquely in a cell mobilityInfo->newUE_Identity.size = 2; diff --git a/openair2/X2AP/x2ap_eNB_handler.c b/openair2/X2AP/x2ap_eNB_handler.c index 52b952a8d5..52b14f1d23 100644 --- a/openair2/X2AP/x2ap_eNB_handler.c +++ b/openair2/X2AP/x2ap_eNB_handler.c @@ -374,7 +374,11 @@ x2ap_eNB_handle_x2_setup_request(instance_t instance, /* Set proper pci */ X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_X2SetupRequest_IEs_t, ie, x2SetupRequest, X2AP_ProtocolIE_ID_id_ServedCells, true); - if (ie->value.choice.ServedCells.list.count > 0) { + + if (ie == NULL ) { + X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); + return -1; + } else if (ie->value.choice.ServedCells.list.count > 0) { x2ap_eNB_data->x2ap_eNB_instance->num_cc = ie->value.choice.ServedCells.list.count; for (int i=0; ivalue.choice.ServedCells.list.count;i++) { servedCellMember = (ServedCells__Member *)ie->value.choice.ServedCells.list.array[i]; @@ -474,7 +478,11 @@ int x2ap_eNB_handle_x2_setup_response(instance_t instance, /* Set proper pci */ X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_X2SetupResponse_IEs_t, ie, x2SetupResponse, X2AP_ProtocolIE_ID_id_ServedCells, true); - if (ie->value.choice.ServedCells.list.count > 0) { + + if (ie == NULL ) { + X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); + return -1; + } else if (ie->value.choice.ServedCells.list.count > 0) { x2ap_eNB_data->x2ap_eNB_instance->num_cc = ie->value.choice.ServedCells.list.count; for (int i=0; ivalue.choice.ServedCells.list.count;i++) { servedCellMember = (ServedCells__Member *)ie->value.choice.ServedCells.list.array[i]; @@ -585,7 +593,12 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance, X2AP_ProtocolIE_ID_id_Old_eNB_UE_X2AP_ID, true); //X2AP_HANDOVER_REQ(msg).source_rnti = ctxt_pP->rnti; //X2AP_HANDOVER_REQ(m).source_x2id = x2HandoverRequest->old_eNB_UE_X2AP_ID; - X2AP_HANDOVER_REQ(msg).old_eNB_ue_x2ap_id = ie->value.choice.UE_X2AP_ID; + if (ie == NULL ) { + X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); + return -1; + } else { + X2AP_HANDOVER_REQ(msg).old_eNB_ue_x2ap_id = ie->value.choice.UE_X2AP_ID; + } //X2AP_HANDOVER_REQ(msg).target_physCellId = measResults2->measResultNeighCells->choice. //measResultListEUTRA.list.array[ncell_index]->physCellId; @@ -600,10 +613,13 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance, X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_HandoverRequest_IEs_t, ie, x2HandoverRequest, X2AP_ProtocolIE_ID_id_UE_ContextInformation, true); + if (ie == NULL ) { + X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); + return -1; + } + X2AP_HANDOVER_REQ(msg).mme_ue_s1ap_id = ie->value.choice.UE_ContextInformation.mME_UE_S1AP_ID; - X2AP_HANDOVER_REQ(msg).target_mod_id = x2ap_eNB_data->x2ap_eNB_instance->eNB_id; - X2AP_HANDOVER_REQ(msg).security_capabilities.encryption_algorithms = BIT_STRING_to_uint16(&ie->value.choice.UE_ContextInformation.uESecurityCapabilities.encryptionAlgorithms); X2AP_HANDOVER_REQ(msg).security_capabilities.integrity_algorithms = diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index f002f94c27..98bdbeb54d 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -1542,6 +1542,12 @@ int s1ap_eNB_handle_s1_path_switch_request_ack(uint32_t assoc_id, /* mandatory */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); + if (ie == NULL) { + S1AP_ERROR("[SCTP %d] Received path switch request ack for non " + "ie context is NULL\n", assoc_id); + return -1; + } + S1AP_PATH_SWITCH_REQ_ACK(message_p).eNB_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, @@ -1556,6 +1562,13 @@ int s1ap_eNB_handle_s1_path_switch_request_ack(uint32_t assoc_id, /* mandatory */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); + + if (ie == NULL) { + S1AP_ERROR("[SCTP %d] Received path switch request ack for non " + "ie context is NULL\n", assoc_id); + return -1; + } + S1AP_PATH_SWITCH_REQ_ACK(message_p).mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; if ( ue_desc_p->mme_ue_s1ap_id != ie->value.choice.MME_UE_S1AP_ID) { @@ -1566,6 +1579,13 @@ int s1ap_eNB_handle_s1_path_switch_request_ack(uint32_t assoc_id, /* mandatory */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PathSwitchRequestAcknowledgeIEs_t, ie, pathSwitchRequestAcknowledge, S1AP_ProtocolIE_ID_id_SecurityContext, true); + + if (ie == NULL) { + S1AP_ERROR("[SCTP %d] Received path switch request ack for non " + "ie context is NULL\n", assoc_id); + return -1; + } + S1AP_PATH_SWITCH_REQ_ACK(message_p).next_hop_chain_count = ie->value.choice.SecurityContext.nextHopChainingCount; memcpy(&S1AP_PATH_SWITCH_REQ_ACK(message_p).next_security_key, @@ -1676,6 +1696,12 @@ int s1ap_eNB_handle_s1_path_switch_request_failure(uint32_t assoc_ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PathSwitchRequestFailureIEs_t, ie, pathSwitchRequestFailure, S1AP_ProtocolIE_ID_id_Cause, true); + if (ie == NULL) { + S1AP_ERROR("[SCTP %d] Received S1 path switch request failure for non existing " + "ie context is NULL\n", assoc_id); + return -1; + } + switch(ie->value.choice.Cause.present) { case S1AP_Cause_PR_NOTHING: S1AP_WARN("Received S1 Error indication cause NOTHING\n"); diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c index 255c6113d5..6652ca0447 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c @@ -1683,7 +1683,7 @@ int s1ap_eNB_path_switch_req(instance_t instance, if ((collision_p = RB_INSERT(s1ap_ue_map, &s1ap_eNB_instance_p->s1ap_ue_head, ue_context_p)) == NULL) { - S1AP_DEBUG("Found usable eNB_ue_s1ap_id: 0x%06x %d(10)\n", + S1AP_DEBUG("Found usable eNB_ue_s1ap_id: 0x%06x %u(10)\n", ue_context_p->eNB_ue_s1ap_id, ue_context_p->eNB_ue_s1ap_id); /* Break the loop as the id is not already used by another UE */