diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index dd86aaf42a..ed4378f3ea 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -395,11 +395,9 @@ void write_parsedcfg(configmodule_interface_t *cfgptr) cfgptr->status->emptyla, cfgptr->status->num_write); } - if (cfgptr != NULL) { - if (cfgptr->write_parsedcfg != NULL) { - printf("[CONFIG] calling config module write_parsedcfg function...\n"); - cfgptr->write_parsedcfg(cfgptr); - } + if (cfgptr->write_parsedcfg != NULL) { + printf("[CONFIG] calling config module write_parsedcfg function...\n"); + cfgptr->write_parsedcfg(cfgptr); } } @@ -407,8 +405,8 @@ void write_parsedcfg(configmodule_interface_t *cfgptr) /* config module could be initialized again after this call */ void end_configmodule(configmodule_interface_t *cfgptr) { - write_parsedcfg(cfgptr); if (cfgptr != NULL) { + write_parsedcfg(cfgptr); if (cfgptr->end != NULL) { printf ("[CONFIG] calling config module end function...\n"); cfgptr->end(cfgptr); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 1a93df1657..bbdbe29747 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -592,7 +592,7 @@ static void initialize_agent(ngran_node_t node_type, e2_agent_args_t oai_args) nb_id = rrc->node_id; } else if (node_type == ngran_gNB_DU) { const gNB_MAC_INST* mac = RC.nrmac[0]; - AssertFatal(mac != NULL, "MAC not initialized\n"); + AssertFatal(mac, "MAC not initialized\n"); cu_du_id = mac->f1_config.gnb_id; nb_id = mac->f1_config.setup_req->gNB_DU_id; } else if (node_type == ngran_gNB_CU || node_type == ngran_gNB_CUCP) { diff --git a/nfapi/oai_integration/aerial/fapi_vnf_p7.c b/nfapi/oai_integration/aerial/fapi_vnf_p7.c index f2046aa456..14a84371bf 100644 --- a/nfapi/oai_integration/aerial/fapi_vnf_p7.c +++ b/nfapi/oai_integration/aerial/fapi_vnf_p7.c @@ -423,7 +423,7 @@ int aerial_phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) { if (NFAPI_MODE == NFAPI_MODE_AERIAL) { nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); - AssertFatal(uci_ind != NULL, "Memory not allocated for uci_ind in phy_nr_uci_indication."); + AssertFatal(uci_ind, "Memory not allocated for uci_ind in phy_nr_uci_indication."); *uci_ind = *ind; uci_ind->uci_list = CALLOC(NFAPI_NR_UCI_IND_MAX_PDU, sizeof(nfapi_nr_uci_t)); diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index b3e34ee1b7..a70b52c08c 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -759,7 +759,7 @@ int phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) if(NFAPI_MODE == NFAPI_MODE_VNF) { nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); - AssertFatal(uci_ind != NULL, "Memory not allocated for uci_ind in phy_nr_uci_indication."); + AssertFatal(uci_ind, "Memory not allocated for uci_ind in phy_nr_uci_indication."); *uci_ind = *ind; uci_ind->uci_list = CALLOC(NFAPI_NR_UCI_IND_MAX_PDU, sizeof(nfapi_nr_uci_t)); diff --git a/openair1/PHY/CODING/nr_polar_init.c b/openair1/PHY/CODING/nr_polar_init.c index 3d6d7848da..b3e29322b3 100644 --- a/openair1/PHY/CODING/nr_polar_init.c +++ b/openair1/PHY/CODING/nr_polar_init.c @@ -110,10 +110,9 @@ t_nrPolar_params *nr_polar_params(int8_t messageType, uint16_t messageLength, ui // printf("currentPtr %p (polarParams %p)\n",currentPtr,polarParams); //Else, initialize and add node to the end of the linked list. t_nrPolar_params *newPolarInitNode = calloc(sizeof(t_nrPolar_params),1); - newPolarInitNode->busy=true; + AssertFatal(newPolarInitNode, "[nr_polar_init] New t_nrPolar_params * could not be created"); + newPolarInitNode->busy = true; pthread_mutex_unlock(&PolarListMutex); - - AssertFatal(newPolarInitNode != NULL, "[nr_polar_init] New t_nrPolar_params * could not be created"); // LOG_D(PHY,"Setting new polarParams index %d, messageType %d, messageLength %d, aggregation_prime %d\n",(messageType * messageLength * aggregation_prime),messageType,messageLength,aggregation_prime); newPolarInitNode->idx = PolarKey; diff --git a/openair1/PHY/LTE_TRANSPORT/power_control.c b/openair1/PHY/LTE_TRANSPORT/power_control.c index 5744c6b35b..d2414222b2 100644 --- a/openair1/PHY/LTE_TRANSPORT/power_control.c +++ b/openair1/PHY/LTE_TRANSPORT/power_control.c @@ -41,8 +41,8 @@ double get_pa_dB(uint8_t pa) } -double computeRhoA_eNB(uint8_t pa, - LTE_eNB_DLSCH_t *dlsch_eNB, int dl_power_off, uint8_t n_antenna_port){ +double computeRhoA_eNB(uint8_t pa, LTE_eNB_DLSCH_t *dlsch_eNB, int dl_power_off, uint8_t n_antenna_port) +{ double rho_a_dB; double sqrt_rho_a_lin; @@ -59,10 +59,10 @@ double computeRhoA_eNB(uint8_t pa, if (dlsch_eNB) { dlsch_eNB->sqrt_rho_a= (short) (sqrt_rho_a_lin*pow(2,13)); dlsch_eNB->pa = pa; - } #if DEBUG_PC - printf("eNB: p_a=%d, value=%f, sqrt_rho_a=%d\n",p_a,pa_values[ pdsch_config_dedicated->p_a],dlsch_eNB->sqrt_rho_a); + printf("eNB: p_a=%d, value=%f, sqrt_rho_a=%d\n", p_a, pa_values[pdsch_config_dedicated->p_a], dlsch_eNB->sqrt_rho_a); #endif + } return(rho_a_dB); } @@ -89,12 +89,12 @@ double computeRhoB_eNB(uint8_t pa, sqrt_rho_b_lin= pow(10,(0.05*rho_b_dB)); if (dlsch_eNB) { - dlsch_eNB->sqrt_rho_b= (short) (sqrt_rho_b_lin*pow(2,13)); + dlsch_eNB->sqrt_rho_b = (short) (sqrt_rho_b_lin * pow(2, 13)); dlsch_eNB->pb = pb; - } #ifdef DEBUG_PC - printf("eNB: n_ant=%d, p_b=%d -> rho_b/rho_a=%f -> sqrt_rho_b=%d\n",n_antenna_port,pb,ratioPB[1][pb],dlsch_eNB->sqrt_rho_b); + printf("eNB: n_ant=%d, p_b=%d -> rho_b/rho_a=%f -> sqrt_rho_b=%d\n", n_antenna_port, pb, ratioPB[1][pb], dlsch_eNB->sqrt_rho_b); #endif + } return(rho_b_dB); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index bc3046c578..2d98662813 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -42,7 +42,7 @@ static NR_gNB_ULSCH_t *find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid) for (int i = 0; i < gNB->max_nb_pusch; i++) { ulsch = &gNB->ulsch[i]; - AssertFatal(ulsch != NULL, "gNB->ulsch[%d] is null\n", i); + AssertFatal(ulsch, "gNB->ulsch[%d] is null\n", i); if (!ulsch->active) { if (first_free_index == -1) first_free_index = i; diff --git a/openair1/SIMULATION/LTE_PHY/mbmssim.c b/openair1/SIMULATION/LTE_PHY/mbmssim.c index 91037410ee..ba21bf8ec1 100644 --- a/openair1/SIMULATION/LTE_PHY/mbmssim.c +++ b/openair1/SIMULATION/LTE_PHY/mbmssim.c @@ -688,9 +688,8 @@ int main(int argc, char **argv) { else { while(fgets(buf, 63, proc_fd)) printf("%s", buf); + fclose(proc_fd); } - - fclose(proc_fd); cpu_freq_GHz = ((double)atof(buf))/1e6; #else cpu_freq_GHz = get_cpu_freq_GHz(); diff --git a/openair1/SIMULATION/RF/dac.c b/openair1/SIMULATION/RF/dac.c index d5cb985c4f..dc4c09827b 100644 --- a/openair1/SIMULATION/RF/dac.c +++ b/openair1/SIMULATION/RF/dac.c @@ -107,6 +107,7 @@ double dac_fixed_gain(double *s_re[2], *amp1p=sqrt(*amp1p); } + AssertFatal(amp1p != NULL && *amp1p != 0.0, "Precondition to avoid UB\n"); #ifdef DEBUG_DAC LOG_I(OCM,"DAC: amp %f, amp1 %f dB (%d,%d), tx_power target %f (actual %f %f),length %d,pos %d\n", @@ -122,7 +123,6 @@ double dac_fixed_gain(double *s_re[2], #endif - AssertFatal(amp1p != NULL && *amp1p != 0.0, "Precondition to avoid UB\n"); for (i=0; icommon_vars.txdata; - AssertFatal(txdata != NULL,"txdata is null\n"); + AssertFatal(txdata,"txdata is null\n"); sf_offset = subframe*frame_parms->samples_per_tti; if (subframe>0) sf_offset_tdd = sf_offset - PHY_vars_UE_g[UE_id][CC_id]->N_TA_offset; diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 753302fc73..8fc8604696 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -2033,8 +2033,8 @@ int get_channel_params(char *buf, int debug, void *vdata, telnet_printfunc_t prn } tdata->numlines++; } + return tdata->numlines; } - return tdata->numlines; } /* show */ else if (strstr(buf, "set") == buf) { char cmdbuf[TELNET_MAX_MSGLENGTH]; int sst = sscanf(tdata->tblname, "%*[^=]=%i", &chanidx); @@ -2229,11 +2229,12 @@ int get_modchannel_index(char *buf, int debug, void *vdata, telnet_printfunc_t p if (debug) LOG_I(UTIL, "%s received %s\n", __FUNCTION__, buf); webdatadef_t *tdata = (webdatadef_t *)vdata; - tdata->numlines = 0; if (strncmp(buf, "set", 3) == 0) { return get_channel_params(buf, debug, vdata, prnt); } + int numlines = 0; if (tdata != NULL) { + tdata->numlines = 0; for (int i = 0; i < max_chan; i++) { if (defined_channels[i] != NULL) { tdata->numlines++; @@ -2245,8 +2246,9 @@ int get_modchannel_index(char *buf, int debug, void *vdata, telnet_printfunc_t p else { snprintf(tdata->tblname, sizeof(tdata->tblname) - 1, "No running model in the system"); } + numlines = tdata->numlines; } - return tdata->numlines; + return numlines; } /* get_currentchannel_type */ /*------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/E1AP/e1ap.c b/openair2/E1AP/e1ap.c index 1c9ff19bff..a073ddddca 100644 --- a/openair2/E1AP/e1ap.c +++ b/openair2/E1AP/e1ap.c @@ -2030,21 +2030,21 @@ void *E1AP_CUUP_task(void *arg) case E1AP_BEARER_CONTEXT_SETUP_RESP: { const e1ap_bearer_setup_resp_t *resp = &E1AP_BEARER_CONTEXT_SETUP_RESP(msg); const e1ap_upcp_inst_t *inst = getCxtE1(myInstance); - AssertFatal(inst != NULL, "no E1 instance found for instance %ld\n", myInstance); + AssertFatal(inst, "no E1 instance found for instance %ld\n", myInstance); e1apCUUP_send_BEARER_CONTEXT_SETUP_RESPONSE(inst->cuup.assoc_id, resp); } break; case E1AP_BEARER_CONTEXT_MODIFICATION_RESP: { const e1ap_bearer_modif_resp_t *resp = &E1AP_BEARER_CONTEXT_MODIFICATION_RESP(msg); const e1ap_upcp_inst_t *inst = getCxtE1(myInstance); - AssertFatal(inst != NULL, "no E1 instance found for instance %ld\n", myInstance); + AssertFatal(inst, "no E1 instance found for instance %ld\n", myInstance); e1apCUUP_send_BEARER_CONTEXT_MODIFICATION_RESPONSE(inst->cuup.assoc_id, resp); } break; case E1AP_BEARER_CONTEXT_RELEASE_CPLT: { const e1ap_bearer_release_cplt_t *cplt = &E1AP_BEARER_CONTEXT_RELEASE_CPLT(msg); const e1ap_upcp_inst_t *inst = getCxtE1(myInstance); - AssertFatal(inst != NULL, "no E1 instance found for instance %ld\n", myInstance); + AssertFatal(inst, "no E1 instance found for instance %ld\n", myInstance); e1apCUUP_send_BEARER_CONTEXT_RELEASE_COMPLETE(inst->cuup.assoc_id, cplt); } break; diff --git a/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c b/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c index dcc6ff13c3..77dc12ba24 100644 --- a/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c +++ b/openair2/E2AP/RAN_FUNCTION/O-RAN/ran_func_kpm.c @@ -179,10 +179,10 @@ static void capture_sst_sd(test_cond_value_t* test_cond_value, uint8_t *sst, uin static bool nssai_matches(nssai_t a_nssai, uint8_t b_sst, const uint32_t *b_sd) { - AssertFatal(b_sd == NULL || *b_sd <= 0xffffff, "illegal SD %d\n", *b_sd); if (b_sd == NULL) { return a_nssai.sst == b_sst && a_nssai.sd == 0xffffff; } else { + AssertFatal(*b_sd <= 0xffffff, "illegal SD %d\n", *b_sd); return a_nssai.sst == b_sst && a_nssai.sd == *b_sd; } } diff --git a/openair2/F1AP/f1ap_ids.c b/openair2/F1AP/f1ap_ids.c index e467e074fd..64d4b0b938 100644 --- a/openair2/F1AP/f1ap_ids.c +++ b/openair2/F1AP/f1ap_ids.c @@ -53,7 +53,7 @@ bool cu_add_f1_ue_data(uint32_t ue_id, const f1_ue_data_t *data) return false; } f1_ue_data_t *idata = malloc(sizeof(*idata)); - AssertFatal(idata != NULL, "cannot allocate memory\n"); + AssertFatal(idata, "cannot allocate memory\n"); *idata = *data; hashtable_rc_t ret = hashtable_insert(cu2du_ue_mapping, key, idata); pthread_mutex_unlock(&cu2du_mutex); @@ -116,7 +116,7 @@ bool du_add_f1_ue_data(uint32_t ue_id, const f1_ue_data_t *data) return false; } f1_ue_data_t *idata = malloc(sizeof(*idata)); - AssertFatal(idata != NULL, "cannot allocate memory\n"); + AssertFatal(idata, "cannot allocate memory\n"); *idata = *data; hashtable_rc_t ret = hashtable_insert(du2cu_ue_mapping, key, idata); pthread_mutex_unlock(&du2cu_mutex); diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 4fc8b7b0a1..e86f24c04c 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -2643,13 +2643,19 @@ uint16_t get_nr_srs_offset(NR_SRS_PeriodicityAndOffset_t periodicityAndOffset) { // - "UE procedure for applying transform precoding on PUSCH" long get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, nr_dci_format_t dci_format, uint8_t configuredGrant) { - if (configuredGrant && current_UL_BWP->configuredGrantConfig && current_UL_BWP->configuredGrantConfig->transformPrecoder) + if (configuredGrant + && current_UL_BWP + && current_UL_BWP->configuredGrantConfig + && current_UL_BWP->configuredGrantConfig->transformPrecoder) return *current_UL_BWP->configuredGrantConfig->transformPrecoder; - if (dci_format == NR_UL_DCI_FORMAT_0_1 && current_UL_BWP && current_UL_BWP->pusch_Config && current_UL_BWP->pusch_Config->transformPrecoder) + if (dci_format == NR_UL_DCI_FORMAT_0_1 + && current_UL_BWP + && current_UL_BWP->pusch_Config + && current_UL_BWP->pusch_Config->transformPrecoder) return *current_UL_BWP->pusch_Config->transformPrecoder; - if (current_UL_BWP->rach_ConfigCommon && current_UL_BWP->rach_ConfigCommon->msg3_transformPrecoder) + if (current_UL_BWP && current_UL_BWP->rach_ConfigCommon && current_UL_BWP->rach_ConfigCommon->msg3_transformPrecoder) return NR_PUSCH_Config__transformPrecoder_enabled; return NR_PUSCH_Config__transformPrecoder_disabled; @@ -2657,8 +2663,8 @@ long get_transformPrecoding(const NR_UE_UL_BWP_t *current_UL_BWP, nr_dci_format_ uint8_t get_pusch_nb_antenna_ports(NR_PUSCH_Config_t *pusch_Config, NR_SRS_Config_t *srs_config, - dci_field_t srs_resource_indicator) { - + dci_field_t srs_resource_indicator) +{ uint8_t n_antenna_port = 1; if (get_softmodem_params()->phy_test == 1) { // temporary hack to allow UL-MIMO in phy-test mode without SRS @@ -2674,7 +2680,7 @@ uint8_t get_pusch_nb_antenna_ports(NR_PUSCH_Config_t *pusch_Config, // shall be configured with the same value for all these SRS resources. if (srs_resource_set->usage == NR_SRS_ResourceSet__usage_codebook) { NR_SRS_Resource_t *srs_resource = srs_config->srs_ResourceToAddModList->list.array[sri]; - AssertFatal(srs_resource != NULL, "SRS resource indicated by DCI does not exist\n"); + AssertFatal(srs_resource, "SRS resource indicated by DCI does not exist\n"); n_antenna_port = 1 << srs_resource->nrofSRS_Ports; break; } @@ -2806,8 +2812,8 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, dci_field_t srs_resource_indicator, nr_srs_feedback_t *srs_feedback, const uint8_t *nrOfLayers, - uint32_t *val) { - + uint32_t *val) +{ // It is only applicable to codebook based transmission. This field occupies 0 bits for non-codebook based // transmission. It also occupies 0 bits for codebook based transmission using a single antenna port. uint8_t nbits = 0; @@ -2816,8 +2822,9 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, } uint8_t pusch_antenna_ports = get_pusch_nb_antenna_ports(pusch_Config, srs_config, srs_resource_indicator); - if ((pusch_Config && pusch_Config->txConfig != NULL && *pusch_Config->txConfig == NR_PUSCH_Config__txConfig_nonCodebook) || - pusch_antenna_ports == 1) { + if (!pusch_Config + || (pusch_Config->txConfig != NULL && *pusch_Config->txConfig == NR_PUSCH_Config__txConfig_nonCodebook) + || pusch_antenna_ports == 1) { return nbits; } @@ -3041,7 +3048,6 @@ uint8_t compute_precoding_information(NR_PUSCH_Config_t *pusch_Config, } } - return nbits; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 526a406d9c..e89e68f317 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -74,6 +74,7 @@ void init_RA(NR_UE_MAC_INST_t *mac, fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; prach_resources->RA_PREAMBLE_BACKOFF = 0; + AssertFatal(nr_rach_ConfigCommon, "Cannot handle scenario without nr_rach_ConfigCommon\n"); NR_SubcarrierSpacing_t prach_scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing; int n_prbs = get_N_RA_RB(prach_scs, mac->current_UL_BWP->scs); int start_prb = rach_ConfigGeneric->msg1_FrequencyStart + mac->current_UL_BWP->BWPStart; @@ -100,12 +101,10 @@ void init_RA(NR_UE_MAC_INST_t *mac, } else { LOG_E(NR_MAC, "Config not handled\n"); } - } else if (nr_rach_ConfigCommon){ + } else { LOG_I(NR_MAC, "Initialization of 4-step contention-based random access procedure\n"); prach_resources->RA_TYPE = RA_4STEP; ra->cfra = 0; - } else { - LOG_E(NR_MAC, "Config not handled\n"); } switch (rach_ConfigGeneric->powerRampingStep){ // in dB diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 4c84d88680..1cca125300 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -652,7 +652,7 @@ static void nr_generate_Msg3_retransmission(module_id_t module_idP, // generation of DCI 0_0 to schedule msg3 retransmission NR_SearchSpace_t *ss = ra->ra_ss; NR_ControlResourceSet_t *coreset = ra->coreset; - AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg3 retransmission\n"); + AssertFatal(coreset, "Coreset cannot be null for RA-Msg3 retransmission\n"); const int coresetid = coreset->controlResourceSetId; nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][coresetid]; @@ -1251,7 +1251,7 @@ static void nr_generate_Msg2(module_id_t module_idP, } NR_ControlResourceSet_t *coreset = ra->coreset; - AssertFatal(coreset != NULL, "Coreset cannot be null for RA-Msg2\n"); + AssertFatal(coreset, "Coreset cannot be null for RA-Msg2\n"); const int coresetid = coreset->controlResourceSetId; // Calculate number of symbols int time_domain_assignment = get_dl_tda(nr_mac, scc, slotP); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 20e8a6d624..e617184edd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -1071,9 +1071,8 @@ void nr_schedule_ue_spec(module_id_t module_id, if (nr_get_code_rate_dl(sched_pdsch->mcs, current_BWP->mcsTableIdx) != R) { pdsch_pdu->mcsTable[0] = 0; } - AssertFatal(harq!=NULL,"harq is null\n"); - AssertFatal(harq->rounddl_bler.harq_round_max,"%d",harq->round); - pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round%4]; + AssertFatal(harq->round < gNB_mac->dl_bler.harq_round_max,"%d", harq->round); + pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round % 4]; pdsch_pdu->TBSize[0] = TBS; pdsch_pdu->dataScramblingId = *scc->physCellId; pdsch_pdu->nrOfLayers = nrOfLayers; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index ada64a4189..fa3e8f9e15 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -954,10 +954,10 @@ static uint8_t get_max_tpmi(const NR_PUSCH_Config_t *pusch_Config, { uint8_t max_tpmi = 0; - if ((pusch_Config && pusch_Config->txConfig != NULL && *pusch_Config->txConfig == NR_PUSCH_Config__txConfig_nonCodebook) || - num_ue_srs_ports == 1) { + if (!pusch_Config + || (pusch_Config->txConfig != NULL && *pusch_Config->txConfig == NR_PUSCH_Config__txConfig_nonCodebook) + || num_ue_srs_ports == 1) return max_tpmi; - } long max_rank = *pusch_Config->maxRank; long *ul_FullPowerTransmission = pusch_Config->ext1 ? pusch_Config->ext1->ul_FullPowerTransmission_r16 : NULL; @@ -1963,7 +1963,7 @@ static bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_ const NR_SIB1_t *sib1 = nr_mac->common_channels[0].sib1 ? nr_mac->common_channels[0].sib1->message.choice.c1->choice.systemInformationBlockType1 : NULL; NR_ServingCellConfigCommonSIB_t *scc_sib1 = sib1 ? sib1->servingCellConfigCommon : NULL; - AssertFatal(scc!=NULL || scc_sib1!=NULL,"We need one serving cell config common\n"); + AssertFatal(scc || scc_sib1, "We need one serving cell config common\n"); // no UEs if (nr_mac->UE_info.list[0] == NULL) diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c index f0d5b7ce18..2f1a05370e 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c @@ -260,7 +260,7 @@ static int handle_ue_context_drbs_release(int rnti, newGtpuDeleteOneTunnel(f1inst, rnti, drb->rb_id); asn_sequence_del(&cellGroupConfig->rlc_BearerToAddModList->list, idx, 1); long *plcid = malloc(sizeof(*plcid)); - AssertFatal(plcid != NULL, "out of memory\n"); + AssertFatal(plcid, "out of memory\n"); *plcid = lcid; int ret = ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToReleaseList->list, plcid); DevAssert(ret == 0); @@ -392,7 +392,7 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req) NR_SCHED_LOCK(&mac->sched_lock); NR_UE_info_t *UE = find_nr_UE(&RC.nrmac[0]->UE_info, req->gNB_DU_ue_id); - AssertFatal(UE != NULL, "did not find UE with RNTI %04x, but UE Context Setup Failed not implemented\n", req->gNB_DU_ue_id); + AssertFatal(UE, "did not find UE with RNTI %04x, but UE Context Setup Failed not implemented\n", req->gNB_DU_ue_id); NR_CellGroupConfig_t *new_CellGroup = clone_CellGroupConfig(UE->CellGroup); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c index bcf7c26ae6..d3320c9ac2 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_direct.c @@ -45,17 +45,17 @@ static void f1_setup_request_direct(const f1ap_setup_req_t *req) if (req->cell[n].sys_info) { f1ap_gnb_du_system_info_t *orig_sys_info = req->cell[n].sys_info; f1ap_gnb_du_system_info_t *copy_sys_info = calloc(1, sizeof(*copy_sys_info)); - AssertFatal(copy_sys_info != NULL, "out of memory\n"); + AssertFatal(copy_sys_info, "out of memory\n"); f1ap_msg->cell[n].sys_info = copy_sys_info; copy_sys_info->mib = calloc(orig_sys_info->mib_length, sizeof(uint8_t)); - AssertFatal(copy_sys_info->mib != NULL, "out of memory\n"); + AssertFatal(copy_sys_info->mib, "out of memory\n"); memcpy(copy_sys_info->mib, orig_sys_info->mib, orig_sys_info->mib_length); copy_sys_info->mib_length = orig_sys_info->mib_length; if (orig_sys_info->sib1_length > 0) { copy_sys_info->sib1 = calloc(orig_sys_info->sib1_length, sizeof(uint8_t)); - AssertFatal(copy_sys_info->sib1 != NULL, "out of memory\n"); + AssertFatal(copy_sys_info->sib1, "out of memory\n"); memcpy(copy_sys_info->sib1, orig_sys_info->sib1, orig_sys_info->sib1_length); copy_sys_info->sib1_length = orig_sys_info->sib1_length; } diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c index fea829f61e..6229d40bbf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_ul_f1ap.c @@ -77,17 +77,17 @@ static void f1_setup_request_f1ap(const f1ap_setup_req_t *req) if (req->cell[n].sys_info) { f1ap_gnb_du_system_info_t *orig_sys_info = req->cell[n].sys_info; f1ap_gnb_du_system_info_t *copy_sys_info = calloc(1, sizeof(*copy_sys_info)); - AssertFatal(copy_sys_info != NULL, "out of memory\n"); + AssertFatal(copy_sys_info, "out of memory\n"); f1ap_setup->cell[n].sys_info = copy_sys_info; copy_sys_info->mib = calloc(orig_sys_info->mib_length, sizeof(uint8_t)); - AssertFatal(copy_sys_info->mib != NULL, "out of memory\n"); + AssertFatal(copy_sys_info->mib, "out of memory\n"); memcpy(copy_sys_info->mib, orig_sys_info->mib, orig_sys_info->mib_length); copy_sys_info->mib_length = orig_sys_info->mib_length; if (orig_sys_info->sib1_length > 0) { copy_sys_info->sib1 = calloc(orig_sys_info->sib1_length, sizeof(uint8_t)); - AssertFatal(copy_sys_info->sib1 != NULL, "out of memory\n"); + AssertFatal(copy_sys_info->sib1, "out of memory\n"); memcpy(copy_sys_info->sib1, orig_sys_info->sib1, orig_sys_info->sib1_length); copy_sys_info->sib1_length = orig_sys_info->sib1_length; } diff --git a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c index e18c8eddfb..cc10a9d7c3 100644 --- a/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c +++ b/openair2/LAYER2/nr_pdcp/cucp_cuup_handler.c @@ -116,7 +116,7 @@ static int drb_gtpu_create(instance_t instance, static instance_t get_n3_gtp_instance(void) { const e1ap_upcp_inst_t *inst = getCxtE1(0); - AssertFatal(inst != NULL, "need to have E1 instance\n"); + AssertFatal(inst, "need to have E1 instance\n"); return inst->gtpInstN3; } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia2.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia2.c index 45133dc2f4..497ed154d5 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia2.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_integrity_nia2.c @@ -36,7 +36,7 @@ void *nr_pdcp_integrity_nia2_init(uint8_t integrity_key[16]) // No. The overhead is x8 times more. Don't change before measuring // return integrity_key; cbc_cmac_ctx_t* ctx = calloc(1, sizeof(cbc_cmac_ctx_t)); - AssertFatal(ctx != NULL, "Memory exhausted"); + AssertFatal(ctx, "Memory exhausted"); *ctx = init_aes_128_cbc_cmac(integrity_key); return ctx; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index b12142a881..55d245dd38 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -962,7 +962,7 @@ void nr_rlc_activate_srb0(int ue_id, void (*send_initial_ul_rrc_message)(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data)) { struct srb0_data *srb0_data = calloc(1, sizeof(struct srb0_data)); - AssertFatal(srb0_data != NULL, "out of memory\n"); + AssertFatal(srb0_data, "out of memory\n"); srb0_data->ue_id = ue_id; srb0_data->data = data; diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 92b8bd49aa..10b09a4dd2 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1148,10 +1148,11 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info) static uint32_t nr_ue_dl_processing(nr_downlink_indication_t *dl_info) { uint32_t ret_mask = 0x0; + DevAssert(dl_info != NULL); NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); // DL indication after reception of DCI or DL PDU - if (dl_info && dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) { + if (dl_info->dci_ind && dl_info->dci_ind->number_of_dcis) { LOG_T(MAC, "[L2][IF MODULE][DL INDICATION][DCI_IND]\n"); for (int i = 0; i < dl_info->dci_ind->number_of_dcis; i++) { LOG_T(MAC, ">>>NR_IF_Module i=%d, dl_info->dci_ind->number_of_dcis=%d\n", i, dl_info->dci_ind->number_of_dcis); diff --git a/openair2/RRC/NR/nr_rrc_config.c b/openair2/RRC/NR/nr_rrc_config.c index b9920dd085..f631563044 100644 --- a/openair2/RRC/NR/nr_rrc_config.c +++ b/openair2/RRC/NR/nr_rrc_config.c @@ -2580,7 +2580,7 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, struct NR_ServingCellConfig__downlinkBWP_ToAddModList *DL_BWP_list = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList; - struct NR_UplinkConfig__uplinkBWP_ToAddModList *UL_BWP_list = uplinkConfig->uplinkBWP_ToAddModList; + struct NR_UplinkConfig__uplinkBWP_ToAddModList *UL_BWP_list = uplinkConfig ? uplinkConfig->uplinkBWP_ToAddModList : NULL; if (DL_BWP_list) { for (int i = 0; i < DL_BWP_list->list.count; i++) { NR_BWP_Downlink_t *bwp = DL_BWP_list->list.array[i]; @@ -2675,7 +2675,8 @@ NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigC const int dl_antenna_ports = pdschap->N1 * pdschap->N2 * pdschap->XP; const int do_csirs = configuration->do_CSIRS; - AssertFatal(servingcellconfigcommon != NULL, "servingcellconfigcommon is null\n"); + AssertFatal(servingcellconfigcommon, "servingcellconfigcommon is null\n"); + AssertFatal(servingcellconfigdedicated, "servingcellconfigdedicated is null\n"); if (uecap == NULL) LOG_E(RRC, "No UE Capabilities available when programming default CellGroup in NSA\n"); @@ -2803,7 +2804,7 @@ NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigC // Downlink BWPs int n_dl_bwp = 1; - if (servingcellconfigdedicated && servingcellconfigdedicated->downlinkBWP_ToAddModList) { + if (servingcellconfigdedicated->downlinkBWP_ToAddModList) { n_dl_bwp = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count; } if (n_dl_bwp > 0) { @@ -2833,8 +2834,7 @@ NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigC // Uplink BWPs int n_ul_bwp = 1; - if (servingcellconfigdedicated && servingcellconfigdedicated->uplinkConfig - && servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) { + if (servingcellconfigdedicated->uplinkConfig && servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) { n_ul_bwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; } if (n_ul_bwp > 0) { diff --git a/openair2/RRC/NR/rrc_gNB_du.c b/openair2/RRC/NR/rrc_gNB_du.c index cb2de0bf4c..b83a3f268e 100644 --- a/openair2/RRC/NR/rrc_gNB_du.c +++ b/openair2/RRC/NR/rrc_gNB_du.c @@ -146,14 +146,14 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *req, sctp_assoc_t assoc_id) // we accept the DU nr_rrc_du_container_t *du = calloc(1, sizeof(*du)); - AssertFatal(du != NULL, "out of memory\n"); + AssertFatal(du, "out of memory\n"); du->assoc_id = assoc_id; /* ITTI will free the setup request message via free(). So the memory * "inside" of the message will remain, but the "outside" container no, so * allocate memory and copy it in */ du->setup_req = calloc(1,sizeof(*du->setup_req)); - AssertFatal(du->setup_req != NULL, "out of memory\n"); + AssertFatal(du->setup_req, "out of memory\n"); *du->setup_req = *req; if (mib != NULL && sib1 != NULL) { du->mib = mib->message.choice.mib;