Commit f6af2a81 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: fixing the cppcheck assertion non-check.

    fixed also new warnings
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 8120062a
......@@ -72,7 +72,7 @@ uninitvar:openair2/UTIL/OTG/otg_rx_socket.c
// 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
// once again cppcheck does not 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
......
......@@ -264,7 +264,7 @@ case $key in
ARCHIVES_LOC=cppcheck
LOG_PATTERN=cppcheck.xml
NB_PATTERN_FILES=1
BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list"
BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list -I common/utils -j4"
NBARGS=$[$NBARGS+256]
shift
;;
......@@ -344,7 +344,7 @@ case $key in
ARCHIVES_LOC=cppcheck
LOG_PATTERN=cppcheck.xml
NB_PATTERN_FILES=1
BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list"
BUILD_OPTIONS="--enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list -I common/utils -j4"
NBARGS=$[$NBARGS+256]
;;
enb-ethernet)
......
......@@ -35,13 +35,11 @@
void output_log_mem(void);
#define _Assert_Exit_ \
{ \
fprintf(stderr, "\nExiting execution\n"); \
display_backtrace(); \
fflush(stdout); \
fflush(stderr); \
exit(EXIT_FAILURE); \
}
#define _Assert_(cOND, aCTION, fORMAT, aRGS...) \
do { \
......
......@@ -150,7 +150,7 @@ int msc_init(const msc_env_t envP, const int max_threadsP)
pointer_p = malloc(MSC_MAX_MESSAGE_LENGTH);
AssertFatal (pointer_p, "malloc failed!\n");
rv = lfds611_stack_guaranteed_push( g_msc_memory_stack_p, pointer_p );
AssertFatal (rv, "lfds611_stack_guaranteed_push failed for item %u\n", i);
AssertFatal (rv, "lfds611_stack_guaranteed_push failed for item %d\n", i);
}
for (i = MIN_MSC_PROTOS; i < MAX_MSC_PROTOS; i++) {
......
......@@ -48,7 +48,7 @@ int init_ue_paging_info(PHY_VARS_UE *ue, long defaultPagingCycle, long nB) {
else if (Ns==4)
ue->PO = (fp->frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1)));
else
AssertFatal(1==0,"init_ue_paging_info: Ns is %d\n",Ns);
AssertFatal(1==0,"init_ue_paging_info: Ns is %u\n",Ns);
return(0);
}
......@@ -144,7 +144,7 @@ nwGtpv1uGpduMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
AssertFatal((msgExtraLen + NW_GTPV1U_EPC_MIN_HEADER_SIZE) <= tpduOffset,
"Mismatch GTPU len, msgExtraLen %u tpduOffset %u",
msgExtraLen,
tpduOffset);
(uint32_t) tpduOffset);
pMsg->msgBuf = tpdu;
pMsg->msgBufLen = tpduLength + msgExtraLen + NW_GTPV1U_EPC_MIN_HEADER_SIZE;
pMsg->msgBufOffset = tpduOffset - (msgExtraLen + NW_GTPV1U_EPC_MIN_HEADER_SIZE);
......
......@@ -105,8 +105,8 @@ extern int asn1_xer_print;
} \
if (ie == NULL ) { \
S1AP_ERROR("S1AP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL\n",__FILE__,__LINE__);\
if (mandatory) _Assert_Exit_ \
} \
if (mandatory) DevAssert(ie != NULL); \
} while(0)
/** \brief Function callback prototype.
**/
......
......@@ -272,15 +272,11 @@ int s1ap_eNB_handle_s1_setup_failure(uint32_t assoc_id,
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupFailureIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_Cause,true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
if ((ie->value.choice.Cause.present == S1AP_Cause_PR_misc) &&
(ie->value.choice.Cause.choice.misc == S1AP_CauseMisc_unspecified)) {
S1AP_WARN("Received s1 setup failure for MME... MME is not ready\n");
} else {
S1AP_ERROR("Received s1 setup failure for MME... please check your parameters\n");
}
if ((ie->value.choice.Cause.present == S1AP_Cause_PR_misc) &&
(ie->value.choice.Cause.choice.misc == S1AP_CauseMisc_unspecified)) {
S1AP_WARN("Received s1 setup failure for MME... MME is not ready\n");
} else {
return -1;
S1AP_ERROR("Received s1 setup failure for MME... please check your parameters\n");
}
mme_desc_p->state = S1AP_ENB_STATE_WAITING;
......@@ -318,68 +314,60 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id,
/* The list of served gummei can contain at most 8 elements.
* LTE related gummei is the first element in the list, i.e with an id of 0.
*/
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
S1AP_DEBUG("servedGUMMEIs.list.count %d\n", ie->value.choice.ServedGUMMEIs.list.count);
DevAssert(ie->value.choice.ServedGUMMEIs.list.count > 0);
DevAssert(ie->value.choice.ServedGUMMEIs.list.count <= S1AP_maxnoofRATs);
for (i = 0; i < ie->value.choice.ServedGUMMEIs.list.count; i++) {
S1AP_ServedGUMMEIsItem_t *gummei_item_p;
struct served_gummei_s *new_gummei_p;
int j;
gummei_item_p = ie->value.choice.ServedGUMMEIs.list.array[i];
new_gummei_p = calloc(1, sizeof(struct served_gummei_s));
STAILQ_INIT(&new_gummei_p->served_plmns);
STAILQ_INIT(&new_gummei_p->served_group_ids);
STAILQ_INIT(&new_gummei_p->mme_codes);
S1AP_DEBUG("servedPLMNs.list.count %d\n", gummei_item_p->servedPLMNs.list.count);
for (j = 0; j < gummei_item_p->servedPLMNs.list.count; j++) {
S1AP_PLMNidentity_t *plmn_identity_p;
struct plmn_identity_s *new_plmn_identity_p;
plmn_identity_p = gummei_item_p->servedPLMNs.list.array[j];
new_plmn_identity_p = calloc(1, sizeof(struct plmn_identity_s));
TBCD_TO_MCC_MNC(plmn_identity_p, new_plmn_identity_p->mcc,
new_plmn_identity_p->mnc, new_plmn_identity_p->mnc_digit_length);
STAILQ_INSERT_TAIL(&new_gummei_p->served_plmns, new_plmn_identity_p, next);
new_gummei_p->nb_served_plmns++;
}
for (j = 0; j < gummei_item_p->servedGroupIDs.list.count; j++) {
S1AP_MME_Group_ID_t *mme_group_id_p;
struct served_group_id_s *new_group_id_p;
mme_group_id_p = gummei_item_p->servedGroupIDs.list.array[j];
new_group_id_p = calloc(1, sizeof(struct served_group_id_s));
OCTET_STRING_TO_INT16(mme_group_id_p, new_group_id_p->mme_group_id);
STAILQ_INSERT_TAIL(&new_gummei_p->served_group_ids, new_group_id_p, next);
new_gummei_p->nb_group_id++;
}
S1AP_DEBUG("servedGUMMEIs.list.count %d\n", ie->value.choice.ServedGUMMEIs.list.count);
DevAssert(ie->value.choice.ServedGUMMEIs.list.count > 0);
DevAssert(ie->value.choice.ServedGUMMEIs.list.count <= S1AP_maxnoofRATs);
for (i = 0; i < ie->value.choice.ServedGUMMEIs.list.count; i++) {
S1AP_ServedGUMMEIsItem_t *gummei_item_p;
struct served_gummei_s *new_gummei_p;
int j;
gummei_item_p = ie->value.choice.ServedGUMMEIs.list.array[i];
new_gummei_p = calloc(1, sizeof(struct served_gummei_s));
STAILQ_INIT(&new_gummei_p->served_plmns);
STAILQ_INIT(&new_gummei_p->served_group_ids);
STAILQ_INIT(&new_gummei_p->mme_codes);
S1AP_DEBUG("servedPLMNs.list.count %d\n", gummei_item_p->servedPLMNs.list.count);
for (j = 0; j < gummei_item_p->servedPLMNs.list.count; j++) {
S1AP_PLMNidentity_t *plmn_identity_p;
struct plmn_identity_s *new_plmn_identity_p;
plmn_identity_p = gummei_item_p->servedPLMNs.list.array[j];
new_plmn_identity_p = calloc(1, sizeof(struct plmn_identity_s));
TBCD_TO_MCC_MNC(plmn_identity_p, new_plmn_identity_p->mcc,
new_plmn_identity_p->mnc, new_plmn_identity_p->mnc_digit_length);
STAILQ_INSERT_TAIL(&new_gummei_p->served_plmns, new_plmn_identity_p, next);
new_gummei_p->nb_served_plmns++;
}
for (j = 0; j < gummei_item_p->servedMMECs.list.count; j++) {
S1AP_MME_Code_t *mme_code_p;
struct mme_code_s *new_mme_code_p;
mme_code_p = gummei_item_p->servedMMECs.list.array[j];
new_mme_code_p = calloc(1, sizeof(struct mme_code_s));
OCTET_STRING_TO_INT8(mme_code_p, new_mme_code_p->mme_code);
STAILQ_INSERT_TAIL(&new_gummei_p->mme_codes, new_mme_code_p, next);
new_gummei_p->nb_mme_code++;
}
for (j = 0; j < gummei_item_p->servedGroupIDs.list.count; j++) {
S1AP_MME_Group_ID_t *mme_group_id_p;
struct served_group_id_s *new_group_id_p;
mme_group_id_p = gummei_item_p->servedGroupIDs.list.array[j];
new_group_id_p = calloc(1, sizeof(struct served_group_id_s));
OCTET_STRING_TO_INT16(mme_group_id_p, new_group_id_p->mme_group_id);
STAILQ_INSERT_TAIL(&new_gummei_p->served_group_ids, new_group_id_p, next);
new_gummei_p->nb_group_id++;
}
STAILQ_INSERT_TAIL(&mme_desc_p->served_gummei, new_gummei_p, next);
for (j = 0; j < gummei_item_p->servedMMECs.list.count; j++) {
S1AP_MME_Code_t *mme_code_p;
struct mme_code_s *new_mme_code_p;
mme_code_p = gummei_item_p->servedMMECs.list.array[j];
new_mme_code_p = calloc(1, sizeof(struct mme_code_s));
OCTET_STRING_TO_INT8(mme_code_p, new_mme_code_p->mme_code);
STAILQ_INSERT_TAIL(&new_gummei_p->mme_codes, new_mme_code_p, next);
new_gummei_p->nb_mme_code++;
}
} else {
return -1;
STAILQ_INSERT_TAIL(&mme_desc_p->served_gummei, new_gummei_p, next);
}
/* Set the capacity of this MME */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_RelativeMMECapacity, true);
if (ie != NULL) { /* checked by macro but cppcheck doesn't see it */
mme_desc_p->relative_mme_capacity = ie->value.choice.RelativeMMECapacity;
} else {
return -1;
}
mme_desc_p->relative_mme_capacity = ie->value.choice.RelativeMMECapacity;
/* Optionaly set the mme name */
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container,
......
......@@ -501,18 +501,12 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
container = &pdu->choice.initiatingMessage.value.choice.DownlinkNASTransport;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true);
if (ie == NULL) { /* checked by macro, but cppcheck doesn't see it */
return -1;
} else {
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
}
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);
if (ie == NULL) { /* checked by macro, but cppcheck doesn't see it */
return -1;
} else {
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
}
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance,
enb_ue_s1ap_id)) == NULL) {
MSC_LOG_RX_DISCARDED_MESSAGE(
......@@ -566,15 +560,11 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_NAS_PDU, true);
/* Forward the NAS PDU to RRC */
if (ie != NULL) { /* checked by macro, but cppcheck doesn't see it */
s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance,
ue_desc_p->ue_initial_id,
ue_desc_p->eNB_ue_s1ap_id,
ie->value.choice.NAS_PDU.buf,
ie->value.choice.NAS_PDU.size);
} else {
return -1;
}
s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance,
ue_desc_p->ue_initial_id,
ue_desc_p->eNB_ue_s1ap_id,
ie->value.choice.NAS_PDU.buf,
ie->value.choice.NAS_PDU.size);
return 0;
}
......
......@@ -353,7 +353,7 @@ void enb_config_init(const char const * lib_config_file_name_pP)
setting_enb = config_setting_get_elem(setting, i);
active_enb[i] = config_setting_get_string (setting_enb);
AssertFatal (active_enb[i] != NULL,
"Failed to parse config file %s, %uth attribute %s \n",
"Failed to parse config file %s, %dth attribute %s \n",
lib_config_file_name_pP, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
active_enb[i] = strdup(active_enb[i]);
num_enb_properties += 1;
......@@ -393,7 +393,7 @@ void enb_config_init(const char const * lib_config_file_name_pP)
)
) {
AssertError (0, parse_errors ++,
"Failed to parse eNB configuration file %s, %u th enb\n",
"Failed to parse eNB configuration file %s, %d th enb\n",
lib_config_file_name_pP, i);
continue; // FIXME this prevents segfaults below, not sure what happens after function exit
}
......@@ -441,7 +441,7 @@ void enb_config_init(const char const * lib_config_file_name_pP)
)
) {
AssertError (0, parse_errors ++,
"Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
"Failed to parse eNB configuration file %s, %d th enb %d th mme address !\n",
lib_config_file_name_pP, i, j);
continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
}
......
......@@ -473,7 +473,7 @@ void et_enb_config_init(const char const * lib_config_file_name_pP)
setting_enb = config_setting_get_elem(setting, i);
active_enb[i] = config_setting_get_string (setting_enb);
AssertFatal (active_enb[i] != NULL,
"Failed to parse config file %s, %uth attribute %s \n",
"Failed to parse config file %s, %dth attribute %s \n",
lib_config_file_name_pP, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
active_enb[i] = strdup(active_enb[i]);
num_enb_properties += 1;
......@@ -513,7 +513,7 @@ void et_enb_config_init(const char const * lib_config_file_name_pP)
)
) {
AssertError (0, parse_errors ++,
"Failed to parse eNB configuration file %s, %u th enb\n",
"Failed to parse eNB configuration file %s, %d th enb\n",
lib_config_file_name_pP, i);
continue; // FIXME this prevents segfaults below, not sure what happens after function exit
}
......@@ -561,7 +561,7 @@ void et_enb_config_init(const char const * lib_config_file_name_pP)
)
) {
AssertError (0, parse_errors ++,
"Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
"Failed to parse eNB configuration file %s, %d th enb %d th mme address !\n",
lib_config_file_name_pP, i, j);
continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
}
......
......@@ -104,7 +104,7 @@ void et_parse_s1ap(xmlDocPtr doc, const xmlNode const *s1ap_node, et_s1ap_t * co
rc = et_hex2data( &s1ap->binary_stream[s1ap->binary_stream_pos], xml_char, xmlStrlen(xml_char));
s1ap->binary_stream_pos += xmlStrlen(xml_char)/2;
//et_display_node(cur_node, 0);
AssertFatal (rc >= 0, "ERROR in converting hex string %s len %d size %d rc %d\n", xml_char, xmlStrlen(xml_char), size, rc);
AssertFatal (rc >= 0, "ERROR in converting hex string %s len %d size %u rc %d\n", xml_char, xmlStrlen(xml_char), size, rc);
go_deeper_in_tree = 0;
//}
xmlFree(xml_char);
......
......@@ -616,7 +616,7 @@ int et_scenario_set_packet_received(et_packet_t * const packet)
if (0 != packet->timer_id) {
rc = timer_remove(packet->timer_id);
AssertFatal(rc == 0, "TODO: Debug Timer on Rx packet num %d unknown", packet->packet_number);
AssertFatal(rc == 0, "TODO: Debug Timer on Rx packet num %u unknown", packet->packet_number);
g_scenario->timer_count--;
return rc;
}
......@@ -919,7 +919,7 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
break;
default:
AssertFatal(0, "Unknown chunk_type %d packet num %d", packet->sctp_hdr.chunk_type, packet->packet_number);
AssertFatal(0, "Unknown chunk_type %d packet num %u", packet->sctp_hdr.chunk_type, packet->packet_number);
;
}
packet = packet->next;
......
......@@ -122,7 +122,7 @@ void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, con
hex[2] = '\0';
end_ptr = hex;
uli = strtoul(hex, &end_ptr, 16);
AssertFatal((uli != ULONG_MAX) && (end_ptr != NULL) && (*end_ptr == '\0'), "Conversion of hexstring %s failed returned %ld errno %d", hex, uli, errno);
AssertFatal((uli != ULONG_MAX) && (end_ptr != NULL) && (*end_ptr == '\0'), "Conversion of hexstring %s failed returned %lu errno %d", hex, uli, errno);
s1ap->binary_stream[pos++] = (unsigned char)uli;
} while (pos2 < (2*5));
// update ASN1
......
......@@ -169,7 +169,7 @@ int udp_eNB_create_socket(int port, char *ip_addr, task_id_t task_id)
if ((rc = bind(sd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in))) < 0) {
close(sd);
AssertFatal(rc >= 0, "UDP: Failed to bind socket: (%s:%d) address %s port %u\n",
AssertFatal(rc >= 0, "UDP: Failed to bind socket: (%s:%d) address %s port %d\n",
strerror(errno), errno, ip_addr, port);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment