From a1f5a662b6ee8e6d5be96e55fbbb36f6d110567e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 1 Jan 2020 09:05:53 -0800 Subject: Fixup a few codacy complaints. --- src/core/stats.c | 4 ++-- src/platform/windows/win_udp.c | 5 ++--- src/protocol/pair1/pair.c | 5 ++--- src/supplemental/http/http_client.c | 6 ++---- src/supplemental/websocket/websocket.c | 14 +++++++------- src/transport/zerotier/zerotier.c | 4 ++-- 6 files changed, 17 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/core/stats.c b/src/core/stats.c index d526014a..f9b56858 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. +// Copyright 2020 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -418,7 +418,6 @@ nng_stat * nng_stat_find(nng_stat *stat, const char *name) { nng_stat *child; - nng_stat *result; if (stat == NULL) { return (NULL); } @@ -426,6 +425,7 @@ nng_stat_find(nng_stat *stat, const char *name) return (stat); } NNI_LIST_FOREACH(&stat->s_children, child) { + nng_stat *result; if ((result = nng_stat_find(child, name)) != NULL) { return (result); } diff --git a/src/platform/windows/win_udp.c b/src/platform/windows/win_udp.c index e3e5a369..95ff2eb8 100644 --- a/src/platform/windows/win_udp.c +++ b/src/platform/windows/win_udp.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2020 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -307,10 +307,9 @@ nni_plat_udp_sockname(nni_plat_udp *udp, nni_sockaddr *sa) { SOCKADDR_STORAGE ss; int sz; - int rv; sz = sizeof(ss); - if ((rv = getsockname(udp->s, (SOCKADDR *) &ss, &sz)) < 0) { + if (getsockname(udp->s, (SOCKADDR *) &ss, &sz) < 0) { return (nni_win_error(GetLastError())); } return (nni_win_sockaddr2nn(sa, &ss)); diff --git a/src/protocol/pair1/pair.c b/src/protocol/pair1/pair.c index 70654d6d..051bc8f3 100644 --- a/src/protocol/pair1/pair.c +++ b/src/protocol/pair1/pair.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2020 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -267,7 +267,6 @@ pair1_pipe_recv_cb(void *arg) nni_msg * msg; uint32_t hdr; nni_pipe * npipe = p->npipe; - int rv; size_t len; if (nni_aio_result(p->aio_recv) != 0) { @@ -305,7 +304,7 @@ pair1_pipe_recv_cb(void *arg) } // Store the hop count in the header. - if ((rv = nni_msg_header_append_u32(msg, hdr)) != 0) { + if (nni_msg_header_append_u32(msg, hdr) != 0) { // STAT: bump allocfail nni_msg_free(msg); nni_pipe_recv(npipe, p->aio_recv); diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c index 50300846..3c60bd46 100644 --- a/src/supplemental/http/http_client.c +++ b/src/supplemental/http/http_client.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. +// Copyright 2020 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2019 Devolutions // @@ -34,9 +34,7 @@ struct nng_http_client { static void http_dial_start(nni_http_client *c) { - nni_aio *aio; - - if ((aio = nni_list_first(&c->aios)) == NULL) { + if (nni_list_empty(&c->aios)) { return; } nng_stream_dialer_dial(c->dialer, c->aio); diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c index 55f4e9e4..c7d3622c 100644 --- a/src/supplemental/websocket/websocket.c +++ b/src/supplemental/websocket/websocket.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. +// Copyright 2020 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2019 Devolutions // @@ -1012,15 +1012,15 @@ ws_read_cb(void *arg) if (frame->hlen == 0) { frame->hlen = 2; - frame->op = frame->head[0] & 0x7f; - frame->final = (frame->head[0] & 0x80) ? 1 : 0; - frame->masked = (frame->head[1] & 0x80) ? 1 : 0; + frame->op = frame->head[0] & 0x7fu; + frame->final = (frame->head[0] & 0x80u) ? 1 : 0; + frame->masked = (frame->head[1] & 0x80u) ? 1 : 0; if (frame->masked) { frame->hlen += 4; } - if ((frame->head[1] & 0x7F) == 127) { + if ((frame->head[1] & 0x7Fu) == 127) { frame->hlen += 8; - } else if ((frame->head[1] & 0x7F) == 126) { + } else if ((frame->head[1] & 0x7Fu) == 126) { frame->hlen += 2; } @@ -1047,7 +1047,7 @@ ws_read_cb(void *arg) if (frame->buf == NULL) { // Determine expected frame size. - switch ((frame->len = (frame->head[1] & 0x7F))) { + switch ((frame->len = (frame->head[1] & 0x7Fu))) { case 127: NNI_GET64(frame->head + 2, frame->len); if (frame->len < 65536) { diff --git a/src/transport/zerotier/zerotier.c b/src/transport/zerotier/zerotier.c index 552db527..027d46c2 100644 --- a/src/transport/zerotier/zerotier.c +++ b/src/transport/zerotier/zerotier.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. +// Copyright 2020 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -1675,7 +1675,7 @@ zt_pipe_alloc( zt_node *ztn = ep->ze_ztn; int i; size_t maxfrag; - size_t maxfrags; + size_t maxfrags = 0; if ((p = NNI_ALLOC_STRUCT(p)) == NULL) { return (NNG_ENOMEM); -- cgit v1.2.3-70-g09d2