From 085500807c3a66e4d6e0a6a2d6516b2a4a13e69c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 30 Nov 2015 12:19:50 +0100 Subject: [PATCH] gtphub: fix some style complaints from cppcheck Sponsored-by: On-Waves ehi --- openbsc/include/openbsc/gtphub.h | 2 -- openbsc/src/gprs/gtphub.c | 13 +++---------- openbsc/src/gprs/gtphub_main.c | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/openbsc/include/openbsc/gtphub.h b/openbsc/include/openbsc/gtphub.h index 005c3f85b..c72a0cfbd 100644 --- a/openbsc/include/openbsc/gtphub.h +++ b/openbsc/include/openbsc/gtphub.h @@ -477,8 +477,6 @@ void gtphub_gc(struct gtphub *hub, time_t now); /* Return the string of the first address for this peer. */ const char *gtphub_peer_str(struct gtphub_peer *peer); -/* Same with a different static buffer. We often want to print two peers. */ -const char *gtphub_peer_str2(struct gtphub_peer *peer); /* Return a human readable description of tun in a static buffer. */ const char *gtphub_tunnel_str(struct gtphub_tunnel *tun); diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c index 809c55522..190db2233 100644 --- a/openbsc/src/gprs/gtphub.c +++ b/openbsc/src/gprs/gtphub.c @@ -414,9 +414,9 @@ static int imsi_to_str(uint8_t *imsi, const char **imsi_str) { static char str[17]; int i; - char c; for (i = 0; i < 8; i++) { + char c; c = imsi_digit_to_char(imsi[i]); if (c == '?') return -1; @@ -1095,12 +1095,6 @@ const char *gtphub_peer_str(struct gtphub_peer *peer) return gtphub_peer_strb(peer, buf, sizeof(buf)); } -const char *gtphub_peer_str2(struct gtphub_peer *peer) -{ - static char buf[256]; - return gtphub_peer_strb(peer, buf, sizeof(buf)); -} - const char *gtphub_port_str(struct gtphub_peer_port *port) { static char buf[256]; @@ -1412,7 +1406,6 @@ static int gtphub_handle_create_pdp_ctx(struct gtphub *hub, struct gtphub_peer_port *from_ctrl, struct gtphub_peer_port *to_ctrl) { - int rc; int plane_idx; /* TODO enforce a Request only from SGSN, a Response only from GGSN? */ @@ -1462,6 +1455,7 @@ static int gtphub_handle_create_pdp_ctx(struct gtphub *hub, unsigned int side_idx = p->side_idx; for (plane_idx = 0; plane_idx < 2; plane_idx++) { + int rc; struct gsn_addr addr_from_ie; uint32_t tei_from_ie; int ie_idx; @@ -2169,8 +2163,6 @@ static int gtphub_make_proxy(struct gtphub *hub, int gtphub_start(struct gtphub *hub, struct gtphub_cfg *cfg, uint8_t restart_counter) { - int rc; - gtphub_init(hub); hub->restart_counter = restart_counter; @@ -2188,6 +2180,7 @@ int gtphub_start(struct gtphub *hub, struct gtphub_cfg *cfg, int side_idx; int plane_idx; for_each_side_and_plane(side_idx, plane_idx) { + int rc; rc = gtphub_bind_start(&hub->to_gsns[side_idx][plane_idx], &cfg->to_gsns[side_idx][plane_idx], (side_idx == GTPH_SIDE_SGSN) diff --git a/openbsc/src/gprs/gtphub_main.c b/openbsc/src/gprs/gtphub_main.c index a330b9d39..0a7d383be 100644 --- a/openbsc/src/gprs/gtphub_main.c +++ b/openbsc/src/gprs/gtphub_main.c @@ -82,9 +82,9 @@ static const struct log_info gtphub_log_info = { void log_cfg(struct gtphub_cfg *cfg) { - struct gtphub_cfg_addr *a; int side_idx, plane_idx; for_each_side_and_plane(side_idx, plane_idx) { + struct gtphub_cfg_addr *a; a = &cfg->to_gsns[side_idx][plane_idx].bind; LOGP(DGTPHUB, LOGL_NOTICE, "to-%ss bind, %s: %s port %d\n", @@ -96,7 +96,7 @@ void log_cfg(struct gtphub_cfg *cfg) static void signal_handler(int signal) { - fprintf(stdout, "signal %u received\n", signal); + fprintf(stdout, "signal %d received\n", signal); switch (signal) { case SIGINT: