Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 7e79538

Browse files
committed
CORTX-30083:Fix Codacy issues under "net" directory
This patch fixes some of the codacy warnings in "net" dir. Signed-off-by: Vinoth.V <[email protected]>
1 parent 0cd7e68 commit 7e79538

File tree

12 files changed

+18
-39
lines changed

12 files changed

+18
-39
lines changed

net/bulk_emulation/st/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void client(struct client_params *params)
256256
if (params->xprt->px_3part_addr) {
257257
cctx.pc_port = params->base_port;
258258
cctx.pc_id = params->client_id;
259-
sprintf(ident, "Client %d:%d", cctx.pc_port, cctx.pc_id);
259+
sprintf(ident, "Client %d:%u", cctx.pc_port, cctx.pc_id);
260260
cctx.pc_rid = PART3_SERVER_ID;
261261
} else {
262262
cctx.pc_port = params->base_port + params->client_id;

net/bulk_emulation/st/ping.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ int encode_msg(struct m0_net_buffer *nb, const char *str)
136136
struct m0_bufvec_cursor incur;
137137
struct m0_bufvec_cursor cur;
138138

139+
if(nb == NULL)
140+
return -1;
141+
139142
nb->nb_length = len + 1;
140143
m0_bufvec_cursor_init(&cur, &nb->nb_buffer);
141144
bp = m0_bufvec_cursor_addr(&cur);
@@ -1189,6 +1192,7 @@ int ping_client_passive_send(struct ping_ctx *ctx,
11891192
M0_ASSERT(nb != NULL);
11901193
/* reuse encode_msg for convenience */
11911194
rc = encode_msg(nb, data);
1195+
M0_ASSERT(rc == 0);
11921196
nb->nb_qtype = M0_NET_QT_PASSIVE_BULK_SEND;
11931197
nb->nb_ep = server_ep;
11941198
if (ctx->pc_passive_bulk_timeout > 0) {

net/ip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static int m0_net_ip_lnet_parse(const char *name, struct m0_net_ip_addr *addr)
275275
portnum = tmid | (1 << 10) | ((portal - 30) << 11);
276276
if (portnum > M0_NET_IP_PORT_MAX)
277277
return M0_ERR(-EINVAL);
278-
snprintf(port, ARRAY_SIZE(port), "%d", (uint32_t)portnum);
278+
snprintf(port, ARRAY_SIZE(port), "%u", (uint32_t)portnum);
279279
addr->nia_n.nip_format = M0_NET_IP_LNET_FORMAT;
280280
inet_pton(AF_INET, node, &addr->nia_n.nip_ip_n.sn[0]);
281281
addr->nia_n.nip_fmt_pvt.la.nla_tmid = (uint16_t)tmid;

net/net.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
#include "lib/memory.h"
2929
#include "lib/misc.h"
3030
#include "lib/mutex.h"
31-
#ifndef __KERNEL__
32-
# include "lib/string.h" /* m0_streq */
33-
#endif
31+
#include "lib/string.h"
3432

3533
#define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_NET
3634
#include "lib/trace.h"

net/sock/sock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,6 +2386,7 @@ static int ep_find(struct ma *ma, const char *name, struct ep **out)
23862386
/** Returns end-point transfer machine. */
23872387
static struct ma *ep_ma(struct ep *ep)
23882388
{
2389+
M0_PRE(ep != NULL);
23892390
return ep->e_ep.nep_tm->ntm_xprt_private;
23902391
}
23912392

net/test/demo/test.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

net/test/network.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ static int net_test_buf_init(struct m0_net_buffer *buf,
187187
static void net_test_buf_fini(struct m0_net_buffer *buf,
188188
struct m0_net_domain *dom)
189189
{
190+
M0_PRE(buf != NULL);
190191
M0_PRE(buf->nb_dom == dom);
191192

192193
m0_net_buffer_deregister(buf, dom);

net/test/node_bulk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,10 @@ static void node_bulk_cb(struct m0_net_test_network_ctx *net_ctx,
850850
bool buf_send;
851851
bool buf_bulk;
852852

853+
M0_PRE(net_ctx != NULL);
853854
LOGD("node_bulk_cb: tm_addr = %s, buf_index = %u, q = %d"
854855
", ev-nbe_status = %d",
855856
net_ctx->ntc_tm->ntm_ep->nep_addr, buf_index, q, ev->nbe_status);
856-
M0_PRE(net_ctx != NULL);
857857
role_client = ctx->nbc_nh.ntnh_role == M0_NET_TEST_ROLE_CLIENT;
858858
M0_PRE(ergo(q == M0_NET_QT_MSG_RECV, !role_client));
859859
M0_PRE(ergo(q == M0_NET_QT_MSG_SEND, role_client));

net/test/st/st-ping.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
CWD=$(cd "$( dirname "$0")" && pwd)
2323

2424
source "$CWD"/st-config.sh
25-
TEST_TYPE="ping"
26-
MSG_NR=1048576
27-
MSG_SIZE=4k
28-
CONCURRENCY_CLIENT=8
29-
CONCURRENCY_SERVER=16
25+
export TEST_TYPE="ping"
26+
export MSG_NR=1048576
27+
export MSG_SIZE=4k
28+
export CONCURRENCY_CLIENT=8
29+
export CONCURRENCY_SERVER=16
3030

3131
source "$CWD"/run-1x1.sh

net/test/ut/commands.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ static void commands_node_thread2(struct net_test_cmd_node *node)
671671

672672
M0_ALLOC_PTR(cmd);
673673
M0_UT_ASSERT(cmd != NULL);
674+
M0_UT_ASSERT(nodes != NULL);
674675

675676
if (console_thread) {
676677
buf[0] = '\0';

0 commit comments

Comments
 (0)