diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-11-21 08:14:37 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-11-21 11:08:56 +0000 |
commit | da86fe5ae31e2a6da6c5f6a2af853c3b8ec603c5 (patch) | |
tree | a46a849c97909d8032cbccd26ebcde37a2753a21 | |
parent | ffc20938580adbdc3f280b8b6b5ae01a48f5f664 (diff) |
Fix various compiler warnings in hnb-gw code
Since we finally started to use -Wall, the related warnings became
visible.
Change-Id: I516700eab2aa7c3412dd62775c4960aed9d4b682
-rw-r--r-- | src/context_map.c | 2 | ||||
-rw-r--r-- | src/hnbgw.c | 13 | ||||
-rw-r--r-- | src/hnbgw_cn.c | 30 | ||||
-rw-r--r-- | src/hnbgw_hnbap.c | 12 | ||||
-rw-r--r-- | src/hnbgw_ranap.c | 52 | ||||
-rw-r--r-- | src/hnbgw_rua.c | 4 | ||||
-rw-r--r-- | src/hnbgw_vty.c | 8 | ||||
-rw-r--r-- | src/iu_client.c | 4 | ||||
-rw-r--r-- | src/ranap_common_cn.c | 14 |
9 files changed, 62 insertions, 77 deletions
diff --git a/src/context_map.c b/src/context_map.c index 0960cb9..b90f555 100644 --- a/src/context_map.c +++ b/src/context_map.c @@ -169,4 +169,6 @@ int context_map_init(struct hnb_gw *gw) context_map_tmr.cb = context_map_tmr_cb; context_map_tmr.data = gw; osmo_timer_schedule(&context_map_tmr, EXPIRY_TIMER_SECS, 0); + + return 0; } diff --git a/src/hnbgw.c b/src/hnbgw.c index 97905b3..5c0570e 100644 --- a/src/hnbgw.c +++ b/src/hnbgw.c @@ -44,9 +44,12 @@ #include <osmocom/vty/telnet_interface.h> #include <osmocom/vty/logging.h> +#include <osmocom/vty/command.h> #include <osmocom/netif/stream.h> +#include <osmocom/ranap/ranap_common.h> + #include <osmocom/sigtran/protocol/m3ua.h> #include <osmocom/sigtran/sccp_sap.h> @@ -69,8 +72,6 @@ void *talloc_asn1_ctx; static struct hnb_gw *g_hnb_gw; -static int listen_fd_cb(struct osmo_fd *fd, unsigned int what); - static struct hnb_gw *hnb_gw_create(void *ctx) { struct hnb_gw *gw = talloc_zero(ctx, struct hnb_gw); @@ -175,13 +176,13 @@ void ue_context_free(struct ue_context *ue) } static int hnb_close_cb(struct osmo_stream_srv *conn) { + return 0; } static int hnb_read_cb(struct osmo_stream_srv *conn) { struct hnb_context *hnb = osmo_stream_srv_get_data(conn); struct msgb *msg = msgb_alloc(IUH_MSGB_SIZE, "Iuh rx"); - int flags = 0; int rc; if (!msg) @@ -222,12 +223,12 @@ static int hnb_read_cb(struct osmo_stream_srv *conn) case IUH_PPI_SABP: case IUH_PPI_RNA: case IUH_PPI_PUA: - LOGP(DMAIN, LOGL_ERROR, "Unimplemented SCTP PPID=%u received\n", + LOGP(DMAIN, LOGL_ERROR, "Unimplemented SCTP PPID=%lu received\n", msgb_sctp_ppid(msg)); rc = 0; break; default: - LOGP(DMAIN, LOGL_ERROR, "Unknown SCTP PPID=%u received\n", + LOGP(DMAIN, LOGL_ERROR, "Unknown SCTP PPID=%lu received\n", msgb_sctp_ppid(msg)); rc = 0; break; @@ -421,8 +422,6 @@ static void handle_options(int argc, char **argv) int main(int argc, char **argv) { - struct osmo_sccp_user *sccp_user; - struct osmo_sccp_link *sua_link; struct osmo_stream_srv_link *srv; int rc; diff --git a/src/hnbgw_cn.c b/src/hnbgw_cn.c index 3238f00..a48b651 100644 --- a/src/hnbgw_cn.c +++ b/src/hnbgw_cn.c @@ -38,13 +38,12 @@ * Outbound RANAP RESET to CN ***********************************************************************/ -int hnbgw_cnlink_change_state(struct hnbgw_cnlink *cnlink, enum hnbgw_cnlink_state state); +void hnbgw_cnlink_change_state(struct hnbgw_cnlink *cnlink, enum hnbgw_cnlink_state state); static int transmit_rst(struct hnb_gw *gw, RANAP_CN_DomainIndicator_t domain, struct osmo_sccp_addr *remote_addr) { struct msgb *msg; - struct msgb *msgprim; RANAP_Cause_t cause = { .present = RANAP_Cause_PR_transmissionNetwork, .choice. transmissionNetwork = RANAP_CauseTransmissionNetwork_signalling_transport_resource_failure, @@ -71,7 +70,7 @@ static void cnlink_trafc_cb(void *data) } /* change the state of a CN Link */ -int hnbgw_cnlink_change_state(struct hnbgw_cnlink *cnlink, enum hnbgw_cnlink_state state) +void hnbgw_cnlink_change_state(struct hnbgw_cnlink *cnlink, enum hnbgw_cnlink_state state) { switch (state) { case CNLINK_S_NULL: @@ -127,9 +126,11 @@ static int cn_ranap_rx_paging_cmd(struct hnbgw_cnlink *cnlink, struct hnb_gw *gw = cnlink->gw; struct hnb_context *hnb; RANAP_PagingIEs_t ies; - int rc = 0; + int rc; rc = ranap_decode_pagingies(&ies, &imsg->value); + if (rc < 0) + return rc; /* FIXME: determine which HNBs to send this Paging command, * rather than broadcasting to all HNBs */ @@ -145,8 +146,6 @@ static int cn_ranap_rx_initiating_msg(struct hnbgw_cnlink *cnlink, RANAP_InitiatingMessage_t *imsg, const uint8_t *data, unsigned int len) { - int rc; - switch (imsg->procedureCode) { case RANAP_ProcedureCode_id_Reset: return cn_ranap_rx_reset_cmd(cnlink, imsg); @@ -161,11 +160,11 @@ static int cn_ranap_rx_initiating_msg(struct hnbgw_cnlink *cnlink, case RANAP_ProcedureCode_id_DirectInformationTransfer: case RANAP_ProcedureCode_id_UplinkInformationExchange: LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "Procedure %u from CN, ignoring\n", imsg->procedureCode); + "Procedure %ld from CN, ignoring\n", imsg->procedureCode); break; default: LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " - "Procedure %u from CN, ignoring\n", imsg->procedureCode); + "Procedure %ld from CN, ignoring\n", imsg->procedureCode); break; } return 0; @@ -174,8 +173,6 @@ static int cn_ranap_rx_initiating_msg(struct hnbgw_cnlink *cnlink, static int cn_ranap_rx_successful_msg(struct hnbgw_cnlink *cnlink, RANAP_SuccessfulOutcome_t *omsg) { - int rc; - switch (omsg->procedureCode) { case RANAP_ProcedureCode_id_Reset: /* Reset acknowledge */ return cn_ranap_rx_reset_ack(cnlink, omsg); @@ -184,11 +181,11 @@ static int cn_ranap_rx_successful_msg(struct hnbgw_cnlink *cnlink, case RANAP_ProcedureCode_id_DirectInformationTransfer: case RANAP_ProcedureCode_id_UplinkInformationExchange: LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "Procedure %u from CN, ignoring\n", omsg->procedureCode); + "Procedure %ld from CN, ignoring\n", omsg->procedureCode); break; default: LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " - "Procedure %u from CN, ignoring\n", omsg->procedureCode); + "Procedure %ld from CN, ignoring\n", omsg->procedureCode); break; } return 0; @@ -210,7 +207,7 @@ static int _cn_ranap_rx(struct hnbgw_cnlink *cnlink, RANAP_RANAP_PDU_t *pdu, break; case RANAP_RANAP_PDU_PR_unsuccessfulOutcome: LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "unsuccessful outcome procedure %u from CN, ignoring\n", + "unsuccessful outcome procedure %ld from CN, ignoring\n", pdu->choice.unsuccessfulOutcome.procedureCode); break; default: @@ -218,6 +215,8 @@ static int _cn_ranap_rx(struct hnbgw_cnlink *cnlink, RANAP_RANAP_PDU_t *pdu, "presence %u from CN, ignoring\n", pdu->present); break; } + + return rc; } static int handle_cn_ranap(struct hnbgw_cnlink *cnlink, const uint8_t *data, @@ -357,7 +356,7 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *ctx) struct osmo_sccp_user *scu = ctx; struct hnbgw_cnlink *cnlink; struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph; - int rc; + int rc = 0; LOGP(DMAIN, LOGL_DEBUG, "sccp_sap_up(%s)\n", osmo_scu_prim_name(oph)); @@ -398,7 +397,7 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *ctx) msgb_free(oph->msg); - return 0; + return rc; } static bool addr_has_pc_and_ssn(const struct osmo_sccp_addr *addr) @@ -453,7 +452,6 @@ int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port struct hnbgw_cnlink *cnlink; struct osmo_ss7_instance *ss7; uint32_t local_pc; - int rc; OSMO_ASSERT(!gw->sccp.client); OSMO_ASSERT(!gw->sccp.cnlink); diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c index 0473482..7c1e239 100644 --- a/src/hnbgw_hnbap.c +++ b/src/hnbgw_hnbap.c @@ -355,8 +355,8 @@ static int hnbgw_rx_hnb_deregister(struct hnb_context *ctx, ANY_t *in) if (rc < 0) return rc; - DEBUGP(DHNBAP, "HNB-DE-REGISTER cause=%ld\n", - ies.cause); + DEBUGP(DHNBAP, "HNB-DE-REGISTER cause=%s\n", + hnbap_cause_str(&ies.cause)); hnbap_free_hnbde_registeries(&ies); hnb_context_release(ctx); @@ -457,7 +457,7 @@ static int hnbgw_rx_ue_deregister(struct hnb_context *ctx, ANY_t *in) ctxid = asn1bitstr_to_u24(&ies.context_ID); - DEBUGP(DHNBAP, "UE-DE-REGISTER context=%ld cause=%s\n", + DEBUGP(DHNBAP, "UE-DE-REGISTER context=%u cause=%s\n", ctxid, hnbap_cause_str(&ies.cause)); ue = ue_context_by_id(ctx->gw, ctxid); @@ -486,7 +486,7 @@ static int hnbgw_rx_err_ind(struct hnb_context *hnb, ANY_t *in) static int hnbgw_rx_initiating_msg(struct hnb_context *hnb, InitiatingMessage_t *imsg) { - int rc; + int rc = 0; switch (imsg->procedureCode) { case ProcedureCode_id_HNBRegister: /* 8.2 */ @@ -517,6 +517,8 @@ static int hnbgw_rx_initiating_msg(struct hnb_context *hnb, InitiatingMessage_t imsg->procedureCode); break; } + + return rc; } static int hnbgw_rx_successful_outcome_msg(struct hnb_context *hnb, SuccessfulOutcome_t *msg) @@ -581,5 +583,5 @@ int hnbgw_hnbap_rx(struct hnb_context *hnb, struct msgb *msg) int hnbgw_hnbap_init(void) { - + return 0; } diff --git a/src/hnbgw_ranap.c b/src/hnbgw_ranap.c index 7fd6d0a..6822752 100644 --- a/src/hnbgw_ranap.c +++ b/src/hnbgw_ranap.c @@ -77,7 +77,7 @@ static int ranap_rx_init_reset(struct hnb_context *hnb, ANY_t *in) static int ranap_rx_error_ind(struct hnb_context *hnb, ANY_t *in) { RANAP_ErrorIndicationIEs_t ies; - int rc, is_ps = 0; + int rc; rc = ranap_decode_errorindicationies(&ies, in); if (rc < 0) @@ -92,35 +92,9 @@ static int ranap_rx_error_ind(struct hnb_context *hnb, ANY_t *in) return 0; } -static int ranap_rx_dt(struct hnb_context *hnb, ANY_t *in) -{ - RANAP_DirectTransferIEs_t ies; - int sapi = 0; - int rc; - - rc = ranap_decode_directtransferies(&ies, in); - if (rc < 0) - return rc; - - if (ies.presenceMask & DIRECTTRANSFERIES_RANAP_SAPI_PRESENT) - sapi = ies.sapi; - - if (ies.presenceMask & DIRECTTRANSFERIES_RANAP_LAI_PRESENT) { - /* FIXME: Update LAI associated with UE */ - } - - if (ies.presenceMask & DIRECTTRANSFERIES_RANAP_RAC_PRESENT) { - /* FIXME: Update RAC associated with UE */ - } - - DEBUGP(DRANAP, "DirectTransfer: %s\n", - osmo_hexdump(ies.nas_pdu.buf, ies.nas_pdu.size)); - /* FIXME: hand NAS PDU into MSC */ -} - static int ranap_rx_initiating_msg(struct hnb_context *hnb, RANAP_InitiatingMessage_t *imsg) { - int rc; + int rc = 0; /* according tot the spec, we can primarily receive Overload, * Reset, Reset ACK, Error Indication, reset Resource, Reset @@ -144,19 +118,19 @@ static int ranap_rx_initiating_msg(struct hnb_context *hnb, RANAP_InitiatingMess case RANAP_ProcedureCode_id_DirectInformationTransfer: case RANAP_ProcedureCode_id_UplinkInformationExchange: LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "Procedure %u from HNB, ignoring\n", imsg->procedureCode); + "Procedure %lu from HNB, ignoring\n", imsg->procedureCode); break; default: LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " - "Procedure %u from HNB, ignoring\n", imsg->procedureCode); + "Procedure %lu from HNB, ignoring\n", imsg->procedureCode); break; } + + return rc; } static int ranap_rx_successful_msg(struct hnb_context *hnb, RANAP_SuccessfulOutcome_t *imsg) { - int rc; - /* according tot the spec, we can primarily receive Overload, * Reset, Reset ACK, Error Indication, reset Resource, Reset * Resurce Acknowledge as connecitonless RANAP. There are some @@ -172,20 +146,22 @@ static int ranap_rx_successful_msg(struct hnb_context *hnb, RANAP_SuccessfulOutc case RANAP_ProcedureCode_id_DirectInformationTransfer: case RANAP_ProcedureCode_id_UplinkInformationExchange: LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "Procedure %u from HNB, ignoring\n", imsg->procedureCode); + "Procedure %lu from HNB, ignoring\n", imsg->procedureCode); break; default: LOGP(DRANAP, LOGL_NOTICE, "Received suspicious RANAP " - "Procedure %u from HNB, ignoring\n", imsg->procedureCode); + "Procedure %lu from HNB, ignoring\n", imsg->procedureCode); break; } + + return 0; } static int _hnbgw_ranap_rx(struct hnb_context *hnb, RANAP_RANAP_PDU_t *pdu) { - int rc; + int rc = 0; switch (pdu->present) { case RANAP_RANAP_PDU_PR_initiatingMessage: @@ -196,7 +172,7 @@ static int _hnbgw_ranap_rx(struct hnb_context *hnb, RANAP_RANAP_PDU_t *pdu) break; case RANAP_RANAP_PDU_PR_unsuccessfulOutcome: LOGP(DRANAP, LOGL_NOTICE, "Received unsupported RANAP " - "unsuccessful outcome procedure %u from HNB, ignoring\n", + "unsuccessful outcome procedure %lu from HNB, ignoring\n", pdu->choice.unsuccessfulOutcome.procedureCode); break; default: @@ -204,6 +180,8 @@ static int _hnbgw_ranap_rx(struct hnb_context *hnb, RANAP_RANAP_PDU_t *pdu) "presence %u from HNB, ignoring\n", pdu->present); break; } + + return rc; } @@ -228,5 +206,5 @@ int hnbgw_ranap_rx(struct msgb *msg, uint8_t *data, size_t len) int hnbgw_ranap_init(void) { - + return 0; } diff --git a/src/hnbgw_rua.c b/src/hnbgw_rua.c index 95979f5..305b8cc 100644 --- a/src/hnbgw_rua.c +++ b/src/hnbgw_rua.c @@ -24,6 +24,7 @@ #include <osmocom/netif/stream.h> #include <osmocom/sigtran/sccp_sap.h> +#include <osmocom/sigtran/sccp_helpers.h> #include <unistd.h> #include <errno.h> @@ -418,7 +419,6 @@ static int rua_rx_init_dt(struct msgb *msg, ANY_t *in) static int rua_rx_init_udt(struct msgb *msg, ANY_t *in) { RUA_ConnectionlessTransferIEs_t ies; - RUA_CN_DomainIndicator_t domain; int rc; rc = rua_decode_connectionlesstransferies(&ies, in); @@ -483,7 +483,7 @@ static int rua_rx_initiating_msg(struct msgb *msg, RUA_InitiatingMessage_t *imsg rc = 0; break; default: - LOGP(DRUA, LOGL_NOTICE, "Unknown RUA Procedure %u\n", + LOGP(DRUA, LOGL_NOTICE, "Unknown RUA Procedure %lu\n", imsg->procedureCode); rc = -1; } diff --git a/src/hnbgw_vty.c b/src/hnbgw_vty.c index f504dd5..3d16970 100644 --- a/src/hnbgw_vty.c +++ b/src/hnbgw_vty.c @@ -18,6 +18,8 @@ * */ +#include <string.h> + #include <osmocom/vty/command.h> #include <osmocom/iuh/vty.h> @@ -233,9 +235,6 @@ static int config_write_hnbgw_iuh(struct vty *vty) static int config_write_hnbgw_iucs(struct vty *vty) { - const char *addr; - uint16_t port; - if (!g_hnb_gw->config.iucs_remote_addr_name) return CMD_SUCCESS; @@ -248,9 +247,6 @@ static int config_write_hnbgw_iucs(struct vty *vty) static int config_write_hnbgw_iups(struct vty *vty) { - const char *addr; - uint16_t port; - if (!g_hnb_gw->config.iups_remote_addr_name) return CMD_SUCCESS; diff --git a/src/iu_client.c b/src/iu_client.c index 17d955d..3ee900c 100644 --- a/src/iu_client.c +++ b/src/iu_client.c @@ -25,12 +25,16 @@ #include <string.h> #include <stdbool.h> +#include <asn1c/asn1helpers.h> + #include <osmocom/ranap/iu_client.h> #include <osmocom/core/logging.h> #include <osmocom/crypt/auth.h> #include <osmocom/gprs/gprs_msgb.h> #include <osmocom/sigtran/sccp_sap.h> +#include <osmocom/sigtran/sccp_helpers.h> +#include <osmocom/ranap/ranap_common_cn.h> #include <osmocom/ranap/ranap_ies_defs.h> #include <osmocom/ranap/ranap_msg_factory.h> diff --git a/src/ranap_common_cn.c b/src/ranap_common_cn.c index d02eb37..d2c875e 100644 --- a/src/ranap_common_cn.c +++ b/src/ranap_common_cn.c @@ -319,7 +319,7 @@ int ranap_cn_rx_co(ranap_handle_cb cb, void *ctx, uint8_t *data, size_t len) static int cn_ranap_rx_initiating_msg_cl(void *ctx, RANAP_InitiatingMessage_t *imsg, ranap_message *message) { - int rc; + int rc = 0; message->procedureCode = imsg->procedureCode; message->criticality = imsg->criticality; @@ -360,6 +360,8 @@ static int cn_ranap_rx_initiating_msg_cl(void *ctx, RANAP_InitiatingMessage_t *i get_value_string(ranap_procedure_code_vals, imsg->procedureCode)); break; } + + return rc; } static void cn_ranap_free_initiating_msg_cl(ranap_message *message) @@ -403,7 +405,7 @@ static void cn_ranap_free_initiating_msg_cl(ranap_message *message) static int cn_ranap_rx_successful_msg_cl(void *ctx, RANAP_SuccessfulOutcome_t *imsg, ranap_message *message) { - int rc; + int rc = 0; message->procedureCode = imsg->procedureCode; message->criticality = imsg->criticality; @@ -433,6 +435,8 @@ static int cn_ranap_rx_successful_msg_cl(void *ctx, RANAP_SuccessfulOutcome_t *i get_value_string(ranap_procedure_code_vals, imsg->procedureCode)); break; } + + return rc; } static void cn_ranap_free_successful_msg_cl(ranap_message *message) @@ -463,7 +467,7 @@ static void cn_ranap_free_successful_msg_cl(ranap_message *message) static int _cn_ranap_rx_cl(void *ctx, RANAP_RANAP_PDU_t *pdu, ranap_message *message) { - int rc; + int rc = 0; /* Extend _cn_ranap_free_cl as well when extending this function */ @@ -488,6 +492,8 @@ static int _cn_ranap_rx_cl(void *ctx, RANAP_RANAP_PDU_t *pdu, ranap_message *mes get_value_string(ranap_presence_vals, pdu->present)); break; } + + return rc; } static void _cn_ranap_free_cl(ranap_message *message) @@ -505,7 +511,7 @@ static void _cn_ranap_free_cl(ranap_message *message) break; default: LOGP(DRANAP, LOGL_NOTICE, "Suspicious RANAP " - "presence %s (CL) from RNC, ignoring\n", message->direction); + "presence %d (CL) from RNC, ignoring\n", message->direction); break; } } |