diff options
author | 2023-02-02 17:49:46 +0100 | |
---|---|---|
committer | 2023-02-07 10:25:01 +0100 | |
commit | 8a7e75e84a31180d51b9970d526709ec4dca2030 (patch) | |
tree | 48c1d88f0a5635e75fa9fc0eb898b861b42477e8 /ctrl/libhicnctrl | |
parent | b96d1545a8d2a173dc5911ed0bca3e04dbb02176 (diff) |
fix(hicn): fix bugs reported by sonarqube
Ref: HICN-837
Signed-off-by: Michele Papalini <micpapal@cisco.com>
Change-Id: I0d02a11361b1ba5ad50123b2dd142c961998922f
Diffstat (limited to 'ctrl/libhicnctrl')
-rw-r--r-- | ctrl/libhicnctrl/src/modules/hicn_plugin/route.c | 10 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/objects/connection.c | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c b/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c index e066862e2..4c9f8a638 100644 --- a/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c +++ b/ctrl/libhicnctrl/src/modules/hicn_plugin/route.c @@ -39,8 +39,6 @@ static vapi_error_e parse_route_create( vapi_payload_ip_route_add_del_reply *reply) { if (reply == NULL || rv != VAPI_OK) return rv; - if (reply->retval != VAPI_OK) return reply->retval; - return reply->retval; } @@ -114,6 +112,10 @@ static int _vpp_route_create(hc_sock_t *sock, hc_route_t *route) { if (hicn_ip_address_is_v4(&(face->remote_addr)) && hicn_ip_address_is_v4(&(face->local_addr))) { msg2 = vapi_alloc_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance); + if (msg2 == NULL) { + ret = -1; + goto done; + } memcpy(msg2->payload.src_addr.un.ip4, &face->local_addr.v4, sizeof(ip4_address_t)); msg2->payload.src_addr.af = ADDRESS_IP4; @@ -125,6 +127,10 @@ static int _vpp_route_create(hc_sock_t *sock, hc_route_t *route) { } else if (!hicn_ip_address_is_v4(&(route->face.remote_addr)) && !hicn_ip_address_is_v4(&(route->face.local_addr))) { msg2 = vapi_alloc_hicn_api_udp_tunnel_add_del(s->g_vapi_ctx_instance); + if (msg2 == NULL) { + ret = -1; + goto done; + } memcpy(msg2->payload.src_addr.un.ip6, &face->local_addr.v6, sizeof(ip6_address_t)); msg2->payload.src_addr.af = ADDRESS_IP6; diff --git a/ctrl/libhicnctrl/src/objects/connection.c b/ctrl/libhicnctrl/src/objects/connection.c index 0f8bafb10..ca09d9a54 100644 --- a/ctrl/libhicnctrl/src/objects/connection.c +++ b/ctrl/libhicnctrl/src/objects/connection.c @@ -189,7 +189,6 @@ int hc_connection_cmp(const hc_connection_t *c1, const hc_connection_t *c2) { if (rc != 0) return rc; rc = INT_CMP(c1->remote_port, c2->remote_port); - if (rc != 0) return rc; return rc; } |