Commit 875bdaf2 authored by frtabu's avatar frtabu

cppcheck fixes (2)

parent 227a0640
This diff is collapsed.
......@@ -574,7 +574,7 @@ static int _at_response_encode_cnum(char* buffer, const at_response_t* data)
}
offset += sprintf(buffer+offset, "+CNUM: ,%s,%u\r\n",
cnum->number, cnum->type);
cnum->number, (unsigned int)cnum->type);
}
LOG_FUNC_RETURN (offset);
......@@ -939,7 +939,7 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data)
/* Display the list of defined PDN contexts */
for (i = 0; i < cgdcont->n_pdns; i++) {
offset += sprintf(buffer+offset, "+CGDCONT: %u", cgdcont->cid[i]);
offset += sprintf(buffer+offset, "+CGDCONT: %u", (unsigned int)cgdcont->cid[i]);
if (cgdcont->PDP_type[i] == NET_PDN_TYPE_IPV4) {
offset += sprintf(buffer+offset, ",IP");
......@@ -952,7 +952,7 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data)
offset += sprintf(buffer+offset, ",%s", cgdcont->APN[i]);
/* No data/header compression */
offset += sprintf(buffer+offset, ",%u,%u\r\n",
AT_CGDCONT_D_COMP_OFF, AT_CGDCONT_H_COMP_OFF);
(unsigned int)(AT_CGDCONT_D_COMP_OFF), (unsigned int)(AT_CGDCONT_H_COMP_OFF));
}
} else if (data->type == AT_COMMAND_TST) {
const at_cgdcont_tst_t * cgdcont = &(data->response.cgdcont.tst);
......@@ -963,19 +963,19 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data)
/* IPv4 PDN type */
offset += sprintf(buffer+offset, "+CGDCONT: ");
offset += sprintf(buffer+offset, "(1-%u),IP,,,(%u-%u),(%u-%u)",
offset += sprintf(buffer+offset, "(1-%d),IP,,,(%d-%d),(%d-%d)",
cgdcont->n_cid,
AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX,
AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX);
/* IPv6 PDN type */
offset += sprintf(buffer+offset, "\r\n+CGDCONT: ");
offset += sprintf(buffer+offset, "(1-%u),IPV6,,,(%u-%u),(%u-%u)",
offset += sprintf(buffer+offset, "(1-%d),IPV6,,,(%d-%d),(%d-%d)",
cgdcont->n_cid,
AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX,
AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX);
/* IPv4v6 PDN type */
offset += sprintf(buffer+offset, "\r\n+CGDCONT: ");
offset += sprintf(buffer+offset, "(1-%u),IPV4V6,,,(%u-%u),(%u-%u)",
offset += sprintf(buffer+offset, "(1-%d),IPV4V6,,,(%d-%d),(%d-%d)",
cgdcont->n_cid,
AT_CGDCONT_D_COMP_MIN, AT_CGDCONT_D_COMP_MAX,
AT_CGDCONT_H_COMP_MIN, AT_CGDCONT_H_COMP_MAX);
......@@ -1018,7 +1018,7 @@ static int _at_response_encode_cgact(char* buffer, const at_response_t* data)
/* Display the list of defined PDN status */
for (i = 0; i < cgact->n_pdns; i++) {
offset += sprintf(buffer+offset, "+CGACT: %u,%u\r\n",
cgact->cid[i], cgact->state[i]);
(unsigned int)cgact->cid[i], (unsigned int)cgact->state[i]);
}
} else if (data->type == AT_COMMAND_TST) {
if (at_response_format_v1) {
......@@ -1063,33 +1063,36 @@ static int _at_response_encode_cgpaddr(char* buffer, const at_response_t* data)
/* Display the list of IP addresses assigned to each defined PDN
* connections */
for (i = 0; i < cgpaddr->n_pdns; i++) {
offset += sprintf(buffer+offset, "+CGPADDR: %u", cgpaddr->cid[i]);
offset += sprintf(buffer+offset, "+CGPADDR: %u", (unsigned int)cgpaddr->cid[i]);
if (cgpaddr->PDP_addr_1[i] != NULL) {
/* IPv4 address */
offset += sprintf(buffer+offset, ",%hhu.%hhu.%hhu.%hhu",
cgpaddr->PDP_addr_1[i][0],
cgpaddr->PDP_addr_1[i][1],
cgpaddr->PDP_addr_1[i][2],
cgpaddr->PDP_addr_1[i][3]);
(unsigned int)cgpaddr->PDP_addr_1[i][0],
(unsigned int)cgpaddr->PDP_addr_1[i][1],
(unsigned int)cgpaddr->PDP_addr_1[i][2],
(unsigned int)cgpaddr->PDP_addr_1[i][3]);
}
if (cgpaddr->PDP_addr_2[i] != NULL) {
/* IPv6 Link-local address prefixe */
offset += sprintf(buffer+offset,
",%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu",
0xfe, 0x80, 0, 0, 0, 0, 0, 0);
(unsigned int)0xfe, (unsigned int)0x80,
(unsigned int)0, (unsigned int)0,
(unsigned int)0, (unsigned int)0,
(unsigned int)0, (unsigned int)0);
/* IPv6 Link-local address */
offset += sprintf(buffer+offset,
".%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu.%hhu",
cgpaddr->PDP_addr_2[i][0],
cgpaddr->PDP_addr_2[i][1],
cgpaddr->PDP_addr_2[i][2],
cgpaddr->PDP_addr_2[i][3],
cgpaddr->PDP_addr_2[i][4],
cgpaddr->PDP_addr_2[i][5],
cgpaddr->PDP_addr_2[i][6],
cgpaddr->PDP_addr_2[i][7]);
(unsigned int)cgpaddr->PDP_addr_2[i][0],
(unsigned int)cgpaddr->PDP_addr_2[i][1],
(unsigned int)cgpaddr->PDP_addr_2[i][2],
(unsigned int)cgpaddr->PDP_addr_2[i][3],
(unsigned int)cgpaddr->PDP_addr_2[i][4],
(unsigned int)cgpaddr->PDP_addr_2[i][5],
(unsigned int)cgpaddr->PDP_addr_2[i][6],
(unsigned int)cgpaddr->PDP_addr_2[i][7]);
}
offset += sprintf(buffer+offset, "\r\n");
......@@ -1101,10 +1104,10 @@ static int _at_response_encode_cgpaddr(char* buffer, const at_response_t* data)
offset += sprintf(buffer, "\r\n");
}
offset += sprintf(buffer+offset, "+CGPADDR: %u", cgpaddr->cid[0]);
offset += sprintf(buffer+offset, "+CGPADDR: %u", (unsigned int)cgpaddr->cid[0]);
for (i = 1; i < cgpaddr->n_pdns; i++) {
offset += sprintf(buffer+offset, ",%u", cgpaddr->cid[i]);
offset += sprintf(buffer+offset, ",%u", (unsigned int)cgpaddr->cid[i]);
}
offset += sprintf(buffer+offset, "\r\n");
......@@ -1179,7 +1182,7 @@ static int _at_response_encode_cgev(char* buffer, const at_response_t* data)
if (data->type == AT_COMMAND_GET) {
const at_cgev_resp_t * cgev = &(data->response.cgev);
offset += sprintf(buffer+offset, "+CGEV: %s %u\r\n",
_at_response_event_str[cgev->code], cgev->cid);
_at_response_event_str[cgev->code], (unsigned int)cgev->cid);
}
LOG_FUNC_RETURN (offset);
......
......@@ -181,7 +181,7 @@ int esm_proc_pdn_connectivity(nas_user_t *user, int cid, int is_to_define,
LOG_TRACE(INFO,"ESM-PROC - Define new %s PDN connection to APN %s (cid=%d)",
(pdn_type == ESM_PDN_TYPE_IPV4)? "IPv4" :
(pdn_type == ESM_PDN_TYPE_IPV6)? "IPv6" : "IPv4v6",
apn->value, cid);
(apn!=NULL)?apn->value:0, cid);
if (is_emergency && esm_data->emergency) {
/* The UE shall not request additional PDN connection for
......
......@@ -90,6 +90,7 @@ extern int asn1_xer_print;
# define S1AP_DEBUG(x, args...) do { fprintf(stdout, "[S1AP][D]"x, ##args); } while(0)
#endif
#define S1AP_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID, mandatory) \
do {\
IE_TYPE **ptr; \
......@@ -102,9 +103,11 @@ extern int asn1_xer_print;
break; \
} \
} \
if (mandatory) DevAssert(ie != NULL); \
if (ie == NULL ) { \
S1AP_ERROR("S1AP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL\n",__FILE__,__LINE__);\
if (mandatory) _Assert_Exit_ \
} \
} while(0)
/** \brief Function callback prototype.
**/
typedef int (*s1ap_message_decoded_callback)(
......
This diff is collapsed.
......@@ -177,7 +177,7 @@ int s1ap_eNB_handle_nas_first_req(
if ((collision_p = RB_INSERT(s1ap_ue_map, &instance_p->s1ap_ue_head, ue_desc_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_desc_p->eNB_ue_s1ap_id,
ue_desc_p->eNB_ue_s1ap_id);
/* Break the loop as the id is not already used by another UE */
......@@ -501,11 +501,18 @@ 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;
}
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;
}
if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance,
enb_ue_s1ap_id)) == NULL) {
MSC_LOG_RX_DISCARDED_MESSAGE(
......@@ -555,14 +562,19 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
MSC_AS_TIME_FMT" downlinkNASTransport eNB_ue_s1ap_id %u mme_ue_s1ap_id %u",
assoc_id,
mme_ue_s1ap_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;
}
return 0;
}
......
......@@ -57,11 +57,11 @@ int s1ap_eNB_handle_overload_start(uint32_t assoc_id,
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_OverloadStartIEs_t, ie, container,
S1AP_ProtocolIE_ID_id_OverloadResponse, true);
if (ie != NULL) {
DevCheck(ie->value.choice.OverloadResponse.present ==
S1AP_OverloadResponse_PR_overloadAction,
S1AP_OverloadResponse_PR_overloadAction, 0, 0);
}
/* Non UE-associated signalling -> stream 0 */
DevCheck(stream == 0, stream, 0, 0);
......
......@@ -119,8 +119,9 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id,
mme_ref_p = s1ap_eNB_get_MME(NULL, assoc_id, 0);
DevAssert(mme_ref_p != NULL);
if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance,
ie->value.choice.ENB_UE_S1AP_ID)) == NULL) {
ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance,
ie->value.choice.ENB_UE_S1AP_ID);
if (ue_desc_p == NULL) {
/* Could not find context associated with this eNB_ue_s1ap_id -> generate
* trace failure indication.
*/
......@@ -130,7 +131,7 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id,
memset(&cause, 0, sizeof(S1AP_Cause_t));
cause.present = S1AP_Cause_PR_radioNetwork;
cause.choice.radioNetwork = S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id;
s1ap_eNB_generate_trace_failure(ue_desc_p, &trace_id, &cause);
s1ap_eNB_generate_trace_failure(NULL, &trace_id, &cause);
}
return 0;
......
......@@ -603,7 +603,7 @@ sctp_handle_new_association_req(
sd, sctp_nb_cnx, assoc_id);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void sctp_send_data(
instance_t instance,
task_id_t task_id,
......@@ -667,7 +667,7 @@ static int sctp_close_association(
close(sctp_cnx->sd);
STAILQ_REMOVE(&sctp_cnx_list, sctp_cnx, sctp_cnx_list_elm_s, entries);
SCTP_DEBUG("Removed assoc_id %u (closed socket %u)\n",
sctp_cnx->assoc_id, sctp_cnx->sd);
sctp_cnx->assoc_id, (unsigned int)sctp_cnx->sd);
}
return 0;
......@@ -741,12 +741,14 @@ static int sctp_create_new_listener(
if (server_type) {
if ((sd = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) {
SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno);
free(addr);
return -1;
}
}
else {
if ((sd = socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP)) < 0) {
SCTP_ERROR("socket: %s:%d\n", strerror(errno), errno);
free(addr);
return -1;
}
}
......@@ -756,6 +758,7 @@ static int sctp_create_new_listener(
if (setsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, &event,
sizeof(struct sctp_event_subscribe)) < 0) {
SCTP_ERROR("setsockopt: %s:%d\n", strerror(errno), errno);
free(addr);
return -1;
}
......
......@@ -340,8 +340,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
ret=sysctl(rname, namelen, NULL, 0, newval, newlen);
if (ret) {
fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno));
} else{
printf("[ETHERNET] Kernel network receive buffer max size is set to %u\n",newval[0]);
} else {
printf("[ETHERNET] Kernel network receive buffer max size is set to %u\n",(unsigned int)newval[0]);
}
break;
case KERNEL_SND_BUF_MAX_SIZE:
......@@ -349,8 +349,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
ret=sysctl(wname, namelen, NULL, 0, newval, newlen);
if (ret) {
fprintf(stderr,"[ETHERNET] Error using sysctl():%s\n",strerror(errno));
} else{
printf("[ETHERNET] Kernel network send buffer max size is set to %u\n",newval[0]);
} else {
printf("[ETHERNET] Kernel network send buffer max size is set to %u\n",(unsigned int)newval[0]);
}
break;
......
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