diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 5ba6db854737ba2f1bb6d777c0e36bed19f76f9a..bd5f835a51ab941ec7c3e71d6fd0d63f7a616571 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -54,7 +54,9 @@ int parse_stringlist(paramdef_t *cfgoptions, char *val) { free(tmpval); - AssertFatal(MAX_LIST_SIZE > numelt, ""); + AssertFatal(MAX_LIST_SIZE > numelt, + "This piece of code use fixed size arry of constant #define MAX_LIST_SIZE %d\n", + MAX_LIST_SIZE ); config_check_valptr(cfgoptions, sizeof(char*), numelt); cfgoptions->numelt=numelt; diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 3fedf3f0f9a311390fdebd4a386b4d2bc23e435b..0e3ffc1309c422fc88f16e911e53f39c5f4538f8 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -339,16 +339,23 @@ void end_configmodule(void) { pthread_mutex_lock(&cfgptr->memBlocks_mutex); printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs); - int n=0; for(int i=0; i<cfgptr->numptrs ; i++) { if (cfgptr->oneBlock[i].ptrs != NULL && cfgptr->oneBlock[i].ptrsAllocated== true && cfgptr->oneBlock[i].toFree) { free(cfgptr->oneBlock[i].ptrs); memset(&cfgptr->oneBlock[i], 0, sizeof(cfgptr->oneBlock[i])); } } - + cfgptr->numptrs=0; pthread_mutex_unlock(&cfgptr->memBlocks_mutex); + if ( cfgptr->cfgmode ) + free(cfgptr->cfgmode); + + if ( cfgptr->argv_info ) + free( cfgptr->argv_info ); + + free(cfgptr); + cfgptr=NULL; } } diff --git a/common/config/config_userapi.c b/common/config/config_userapi.c index cebc59a95d656e932dcb072e705feee43f43745c..9725c15845f856d4ba5181ca9de43399062a7144 100644 --- a/common/config/config_userapi.c +++ b/common/config/config_userapi.c @@ -54,7 +54,9 @@ configmodule_interface_t *config_get_if(void) { static int managed_ptr_sz(void* ptr) { configmodule_interface_t * cfg=config_get_if(); - AssertFatal(cfg->numptrs < CONFIG_MAX_ALLOCATEDPTRS,""); + AssertFatal(cfg->numptrs < CONFIG_MAX_ALLOCATEDPTRS, + "This code use fixed size array as #define CONFIG_MAX_ALLOCATEDPTRS %d\n", + CONFIG_MAX_ALLOCATEDPTRS); int i; pthread_mutex_lock(&cfg->memBlocks_mutex); int numptrs=cfg->numptrs; @@ -70,19 +72,17 @@ static int managed_ptr_sz(void* ptr) { void *config_allocate_new(int sz, bool autoFree) { void *ptr = calloc(sz,1); - if (ptr != NULL) { - configmodule_interface_t * cfg=config_get_if(); - // add the memory piece in the managed memory pieces list - pthread_mutex_lock(&cfg->memBlocks_mutex); - int newBlockIdx=cfg->numptrs++; - oneBlock_t* tmp=&cfg->oneBlock[newBlockIdx]; - tmp->ptrs = (char *)ptr; - tmp->ptrsAllocated = true; - tmp->sz=sz; - tmp->toFree=autoFree; - pthread_mutex_unlock(&cfg->memBlocks_mutex); - } else - AssertFatal(false, "calloc fails\n"); + AssertFatal(ptr, "calloc fails\n"); + configmodule_interface_t * cfg=config_get_if(); + // add the memory piece in the managed memory pieces list + pthread_mutex_lock(&cfg->memBlocks_mutex); + int newBlockIdx=cfg->numptrs++; + oneBlock_t* tmp=&cfg->oneBlock[newBlockIdx]; + tmp->ptrs = (char *)ptr; + tmp->ptrsAllocated = true; + tmp->sz=sz; + tmp->toFree=autoFree; + pthread_mutex_unlock(&cfg->memBlocks_mutex); return ptr; } @@ -124,7 +124,9 @@ void config_check_valptr(paramdef_t *cfgoptions, int elt_sz, int nb_elt) { // difficult datamodel cfgoptions->strptr = config_allocate_new(sizeof(*cfgoptions->strptr), toFree); } else if ( cfgoptions->type == TYPE_STRINGLIST) { - AssertFatal(nb_elt<MAX_LIST_SIZE, ""); + AssertFatal(nb_elt<MAX_LIST_SIZE, + "This piece of code use fixed size arry of constant #define MAX_LIST_SIZE %d\n", + MAX_LIST_SIZE ); cfgoptions->strlistptr= config_allocate_new(sizeof(char*)*MAX_LIST_SIZE, toFree); for (int i=0; i<MAX_LIST_SIZE; i++) cfgoptions->strlistptr[i]= config_allocate_new(DEFAULT_EXTRA_SZ, toFree); diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index 52faaaeb468b34693104c23262120807bc223cba..59e958470e653f4250ad59c898ef379d4fa363f7 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -57,7 +57,9 @@ int read_strlist(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpath numelt=config_setting_length(setting); config_check_valptr(cfgoptions, sizeof(char *), numelt); st=0; - AssertFatal(MAX_LIST_SIZE > numelt, ""); + AssertFatal(MAX_LIST_SIZE > numelt, + "This piece of code use fixed size arry of constant #define MAX_LIST_SIZE %d\n", + MAX_LIST_SIZE ); for (int i=0; i< numelt ; i++) { str=config_setting_get_string_elem(setting,i); diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index e10e28873723d0e2c565543b9f5cedb3108fc8a9..9e8e17a3a4a7203231c7830a84367578afce6f09 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -381,8 +381,8 @@ void log_getconfig(log_t *g_log) } int register_log_component(char *name, - char *fext, - int compidx) + char *fext, + int compidx) { int computed_compidx=compidx; diff --git a/common/utils/load_module_shlib.c b/common/utils/load_module_shlib.c index 1c9aa8cab9ab27c0faa1e0073f32ae80f981901e..15b42577e6a9f164ea6f350f98e7270571a71f38 100644 --- a/common/utils/load_module_shlib.c +++ b/common/utils/load_module_shlib.c @@ -281,5 +281,9 @@ void loader_reset() shlib->numfunc = 0; shlib->len_funcarray = 0; } + if(loader_data.shlibpath){ + free(loader_data.shlibpath); + loader_data.shlibpath=NULL; + } free(loader_data.shlibs); } diff --git a/common/utils/load_module_shlib.h b/common/utils/load_module_shlib.h index 7c54403f4df5db2e33631dff9e8709c271f4c856..e804edbfe7ab36731d6bec8bef1316c6c3ea415d 100644 --- a/common/utils/load_module_shlib.h +++ b/common/utils/load_module_shlib.h @@ -51,11 +51,11 @@ typedef struct { }loader_shlibdesc_t; typedef struct { - char *mainexec_buildversion; - char *shlibpath; - uint32_t maxshlibs; - uint32_t numshlibs; - loader_shlibdesc_t *shlibs; + char *mainexec_buildversion; + char *shlibpath; + uint32_t maxshlibs; + uint32_t numshlibs; + loader_shlibdesc_t *shlibs; }loader_data_t; /* function type of functions which may be implemented by a module */ diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 21dadc1291467eb3a94c1a452fb32372b8340005..72a4774f0566817b2b274dc9a734b8b1d7036f7c 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -659,10 +659,6 @@ int main(int argc, char **argv) if (ouput_vcd) vcd_signal_dumper_close(); end_configmodule(); - if (load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY) == 0) { - exit_fun("[NR_DLSCHSIM] Error, configuration module init 2 failed\n"); - } - logInit(); loader_reset(); logTerm(); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 9948df1effa3b3c8f9a6f177ece74e9498a95de2..b272561a2d10e72bb4ef61c8a8e09f99928886d3 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -238,8 +238,7 @@ void mac_top_init_gNB(ngran_node_t node_type) RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0); } if (!IS_SOFTMODEM_NOSTATS_BIT) - - threadCreate(&RC.nrmac[i]->stats_thread, nrmac_stats_thread, (void*)RC.nrmac[i], "MAC_STATS", -1, sched_get_priority_min(SCHED_OAI)+1 ); + threadCreate(&RC.nrmac[i]->stats_thread, nrmac_stats_thread, (void*)RC.nrmac[i], "MAC_STATS", -1, sched_get_priority_min(SCHED_OAI)+1 ); mac_rrc_init(RC.nrmac[i], node_type); }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++)