From 9aab83c509c062a6fff55fd1b835e399a28a772f Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Tue, 19 Feb 2019 17:42:27 +0100 Subject: [PATCH 1/4] Fixing a few last cppcheck errors/warnings Signed-off-by: Raphael Defosseux --- common/utils/T/tracer/gui/notify.c | 2 +- common/utils/T/tracer/multi.c | 1 + common/utils/T/tracer/textlog.c | 5 +++++ common/utils/T/tracer/utils.c | 2 +- openair1/PHY/TOOLS/lte_phy_scope_tm4.c | 3 --- openair3/S1AP/s1ap_eNB_trace.c | 2 +- openair3/TEST/EPC_TEST/generate_scenario.c | 2 +- openair3/TEST/EPC_TEST/play_scenario.c | 2 +- 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/common/utils/T/tracer/gui/notify.c b/common/utils/T/tracer/gui/notify.c index 84fb161b6e..5798a01219 100644 --- a/common/utils/T/tracer/gui/notify.c +++ b/common/utils/T/tracer/gui/notify.c @@ -46,7 +46,7 @@ void unregister_notifier(gui *_g, unsigned long notifier_id) { if (g->notifiers[i].id == notifier_id) break; if (i == g->notifiers_count) - ERR("%s:%d: notifier_id %ld not found\n", __FILE__,__LINE__,notifier_id); + ERR("%s:%d: notifier_id %lu not found\n", __FILE__,__LINE__,notifier_id); free(g->notifiers[i].notification); memmove(g->notifiers + i, g->notifiers + i + 1, diff --git a/common/utils/T/tracer/multi.c b/common/utils/T/tracer/multi.c index 6a9de838c6..a381567eb3 100644 --- a/common/utils/T/tracer/multi.c +++ b/common/utils/T/tracer/multi.c @@ -261,6 +261,7 @@ int main(int n, char **v) if (fds == NULL) { perror("calloc"); exit(1); } } i = 0; + if (fds == NULL) { perror("null fds pointer"); exit(1); } fds[i].fd = l; fds[i].events = POLLIN; i++; diff --git a/common/utils/T/tracer/textlog.c b/common/utils/T/tracer/textlog.c index a123bf9bf5..18132176a7 100644 --- a/common/utils/T/tracer/textlog.c +++ b/common/utils/T/tracer/textlog.c @@ -195,5 +195,10 @@ int main(int n, char **v) handle_event(h, e); } + if (on_off_name != NULL) + free(on_off_name); + if (on_off_action != NULL) + free(on_off_action); + return 0; } diff --git a/common/utils/T/tracer/utils.c b/common/utils/T/tracer/utils.c index 2452254cf9..39e04fb973 100644 --- a/common/utils/T/tracer/utils.c +++ b/common/utils/T/tracer/utils.c @@ -273,6 +273,6 @@ void PUTX2(OBUF *o, int i) { void PUTUL(OBUF *o, unsigned long l) { char s[128]; - sprintf(s, "%ld", l); + sprintf(s, "%lu", l); PUTS(o, s); } diff --git a/openair1/PHY/TOOLS/lte_phy_scope_tm4.c b/openair1/PHY/TOOLS/lte_phy_scope_tm4.c index 8dd41548ab..5c7322e2e9 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope_tm4.c +++ b/openair1/PHY/TOOLS/lte_phy_scope_tm4.c @@ -812,9 +812,6 @@ void phy_scope_UE(FD_lte_phy_scope_ue *form, free(bit1); free(bit_pdcch); free(llr_pdcch); - for (arx=0;arxtransmission_mode[eNB_id]==3 && phy_vars_ue->transmission_mode[eNB_id]==4){ diff --git a/openair3/S1AP/s1ap_eNB_trace.c b/openair3/S1AP/s1ap_eNB_trace.c index 03c0ea4fb2..543ea9c511 100644 --- a/openair3/S1AP/s1ap_eNB_trace.c +++ b/openair3/S1AP/s1ap_eNB_trace.c @@ -107,7 +107,7 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id, { S1AP_TraceStart_t *container; S1AP_TraceStartIEs_t *ie; - struct s1ap_eNB_ue_context_s *ue_desc_p; + struct s1ap_eNB_ue_context_s *ue_desc_p = NULL; struct s1ap_eNB_mme_data_s *mme_ref_p; DevAssert(pdu != NULL); diff --git a/openair3/TEST/EPC_TEST/generate_scenario.c b/openair3/TEST/EPC_TEST/generate_scenario.c index b8d9d9c588..b1a3297866 100644 --- a/openair3/TEST/EPC_TEST/generate_scenario.c +++ b/openair3/TEST/EPC_TEST/generate_scenario.c @@ -270,7 +270,7 @@ static void enb_config_display(void) printf( " ENB CONFIG FILE CONTENT LOADED:\n"); printf( "----------------------------------------------------------------------\n"); for (i = 0; i < g_enb_properties.number; i++) { - printf( "ENB CONFIG for instance %u:\n\n", i); + printf( "ENB CONFIG for instance %d:\n\n", i); printf( "\teNB name: \t%s\n",g_enb_properties.properties[i]->eNB_name); printf( "\teNB ID: \t%"PRIu32"\n",g_enb_properties.properties[i]->eNB_id); printf( "\tCell type: \t%s\n",g_enb_properties.properties[i]->cell_type == CELL_MACRO_ENB ? "CELL_MACRO_ENB":"CELL_HOME_ENB"); diff --git a/openair3/TEST/EPC_TEST/play_scenario.c b/openair3/TEST/EPC_TEST/play_scenario.c index 5928ab017f..a50eac95cf 100644 --- a/openair3/TEST/EPC_TEST/play_scenario.c +++ b/openair3/TEST/EPC_TEST/play_scenario.c @@ -1103,7 +1103,7 @@ et_config_parse_opt_line ( fprintf(stderr, "Please provide a valid -D/--delay-on-exit argument, %s is not a valid value\n", delay_on_exit); exit(1); } - printf("Delay on exit is %u\n", delay_on_exit); + printf("Delay on exit is %d\n", (int) delay_on_exit); } break; From f4bf32d7e779d87c4de53d78523b2c6163a8d819 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Tue, 19 Feb 2019 21:34:06 +0100 Subject: [PATCH 2/4] Forgot one file Signed-off-by: Raphael Defosseux --- common/utils/T/local_tracer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/utils/T/local_tracer.c b/common/utils/T/local_tracer.c index 4be0b35d16..7341db4576 100644 --- a/common/utils/T/local_tracer.c +++ b/common/utils/T/local_tracer.c @@ -240,7 +240,8 @@ again: if (len <= 0) goto dead; - PUT(t); + if (buf != NULL) + PUT(t); switch (t) { case 0: From a82342298e3658298561d4b2b5cc499678ff6d7f Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Wed, 20 Feb 2019 14:42:17 +0100 Subject: [PATCH 3/4] changed back some cppcheck "fixes" and updated the cppcheck suppression list Signed-off-by: Raphael Defosseux --- ci-scripts/cppcheck_suppressions.list | 9 +++++++++ common/utils/T/local_tracer.c | 3 +-- common/utils/T/tracer/multi.c | 1 - common/utils/T/tracer/textlog.c | 6 ++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ci-scripts/cppcheck_suppressions.list b/ci-scripts/cppcheck_suppressions.list index d5aea7ae9d..007d8555e2 100644 --- a/ci-scripts/cppcheck_suppressions.list +++ b/ci-scripts/cppcheck_suppressions.list @@ -67,6 +67,15 @@ syntaxError:openair1/SIMULATION/LTE_PHY/dlsim_tm4.c // omg, otg commented out in cmakelist to be cleaned up definitely? arrayIndexOutOfBounds:openair2/UTIL/OMG/omg.c uninitvar:openair2/UTIL/OTG/otg_rx_socket.c +//----------------------------------------------------------------------------- +// cppcheck is not able to understand that buf is initialized at the first +// iteration of the loop. +nullPointer:common/utils/T/local_tracer.c:243 +//----------------------------------------------------------------------------- +// once again cppcheck is not to understand that fds is initialized in the +// first iteration of the loop +nullPointer:common/utils/T/tracer/multi.c:264 +nullPointer:common/utils/T/tracer/multi.c:265 // //***************************************************************************** // diff --git a/common/utils/T/local_tracer.c b/common/utils/T/local_tracer.c index 7341db4576..4be0b35d16 100644 --- a/common/utils/T/local_tracer.c +++ b/common/utils/T/local_tracer.c @@ -240,8 +240,7 @@ again: if (len <= 0) goto dead; - if (buf != NULL) - PUT(t); + PUT(t); switch (t) { case 0: diff --git a/common/utils/T/tracer/multi.c b/common/utils/T/tracer/multi.c index a381567eb3..6a9de838c6 100644 --- a/common/utils/T/tracer/multi.c +++ b/common/utils/T/tracer/multi.c @@ -261,7 +261,6 @@ int main(int n, char **v) if (fds == NULL) { perror("calloc"); exit(1); } } i = 0; - if (fds == NULL) { perror("null fds pointer"); exit(1); } fds[i].fd = l; fds[i].events = POLLIN; i++; diff --git a/common/utils/T/tracer/textlog.c b/common/utils/T/tracer/textlog.c index 18132176a7..f83cc7efd3 100644 --- a/common/utils/T/tracer/textlog.c +++ b/common/utils/T/tracer/textlog.c @@ -195,10 +195,8 @@ int main(int n, char **v) handle_event(h, e); } - if (on_off_name != NULL) - free(on_off_name); - if (on_off_action != NULL) - free(on_off_action); + free(on_off_name); + free(on_off_action); return 0; } From eeffdfa200fe834e53f13b8692632baac6ee2dfb Mon Sep 17 00:00:00 2001 From: Raphael Defosseux Date: Wed, 20 Feb 2019 18:13:43 +0100 Subject: [PATCH 4/4] CI: adding much needed lock mechanism when creating VM. -- should prevent VM-creation crashes during test stages Signed-off-by: Raphael Defosseux --- ci-scripts/buildOnVM.sh | 19 +++++++++++++------ ci-scripts/createVM.sh | 31 +++++++++++++++++++++++++++++++ ci-scripts/runTestOnVM.sh | 9 ++++++++- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh index f9fb3b776f..ad77d39eb7 100755 --- a/ci-scripts/buildOnVM.sh +++ b/ci-scripts/buildOnVM.sh @@ -94,15 +94,22 @@ function build_on_vm { echo "############################################################" echo "Creating VM ($VM_NAME) on Ubuntu Cloud Image base" echo "############################################################" + acquire_vm_create_lock uvt-kvm create $VM_NAME release=xenial --memory $VM_MEMORY --cpu $VM_CPU --unsafe-caching --template ci-scripts/template-host.xml + echo "Waiting for VM to be started" + uvt-kvm wait $VM_NAME --insecure + + VM_IP_ADDR=`uvt-kvm ip $VM_NAME` + echo "$VM_NAME has for IP addr = $VM_IP_ADDR" + release_vm_create_lock + else + echo "Waiting for VM to be started" + uvt-kvm wait $VM_NAME --insecure + + VM_IP_ADDR=`uvt-kvm ip $VM_NAME` + echo "$VM_NAME has for IP addr = $VM_IP_ADDR" fi - echo "Waiting for VM to be started" - uvt-kvm wait $VM_NAME --insecure - - VM_IP_ADDR=`uvt-kvm ip $VM_NAME` - echo "$VM_NAME has for IP addr = $VM_IP_ADDR" - echo "############################################################" echo "Copying GIT repo into VM ($VM_NAME)" echo "############################################################" diff --git a/ci-scripts/createVM.sh b/ci-scripts/createVM.sh index 192008d867..e693b07b91 100755 --- a/ci-scripts/createVM.sh +++ b/ci-scripts/createVM.sh @@ -49,6 +49,35 @@ function create_usage { echo "" } +function acquire_vm_create_lock { + local FlockFile="/tmp/vmclone.lck" + local unlocked="0" + touch ${FlockFile} 2>/dev/null + if [[ $? -ne 0 ]] + then + echo "Cannot access lock file ${FlockFile}" + exit 2 + fi + while [ $unlocked -eq 0 ] + do + exec 5>${FlockFile} + flock -nx 5 + if [[ $? -ne 0 ]] + then + echo "Another instance of VM creation is running" + sleep 10 + else + unlocked="1" + fi + done + chmod 666 ${FlockFile} 2>/dev/null +} + +function release_vm_create_lock { + local FlockFile="/tmp/vmclone.lck" + rm -Rf ${FlockFile} +} + function create_vm { echo "############################################################" echo "OAI CI VM script" @@ -60,10 +89,12 @@ function create_vm { echo "############################################################" echo "Creating VM ($VM_NAME) on Ubuntu Cloud Image base" echo "############################################################" + acquire_vm_create_lock uvt-kvm create $VM_NAME release=xenial --memory $VM_MEMORY --cpu $VM_CPU --unsafe-caching --template ci-scripts/template-host.xml echo "Waiting for VM to be started" uvt-kvm wait $VM_NAME --insecure VM_IP_ADDR=`uvt-kvm ip $VM_NAME` echo "$VM_NAME has for IP addr = $VM_IP_ADDR" + release_vm_create_lock } diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index 9aa6606eea..b3eac341a9 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -317,11 +317,18 @@ function install_epc_on_vm { echo "############################################################" echo "Creating test EPC VM ($LOC_EPC_VM_NAME) on Ubuntu Cloud Image base" echo "############################################################" + acquire_vm_create_lock uvt-kvm create $LOC_EPC_VM_NAME release=xenial --unsafe-caching + echo "Waiting for VM to be started" + uvt-kvm wait $LOC_EPC_VM_NAME --insecure + release_vm_create_lock + else + echo "Waiting for VM to be started" + uvt-kvm wait $LOC_EPC_VM_NAME --insecure fi - uvt-kvm wait $LOC_EPC_VM_NAME --insecure local LOC_EPC_VM_IP_ADDR=`uvt-kvm ip $LOC_EPC_VM_NAME` + echo "$LOC_EPC_VM_NAME has for IP addr = $LOC_EPC_VM_IP_ADDR" scp -o StrictHostKeyChecking=no /etc/apt/apt.conf.d/01proxy ubuntu@$LOC_EPC_VM_IP_ADDR:/home/ubuntu