Skip to content

Commit

Permalink
Fix unused and signedness in tcp_mgr.c
Browse files Browse the repository at this point in the history
  • Loading branch information
00pauln00 committed May 31, 2024
1 parent d7f353f commit a6e74c9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/tcp_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ tcp_mgr_credits_set(niova_atomic32_t *credits, uint32_t cnt)
static void *
tcp_mgr_credits_malloc(niova_atomic32_t *credits, size_t sz)
{
uint32_t new_credits = niova_atomic_dec(credits);
int32_t new_credits = niova_atomic_dec(credits);
SIMPLE_LOG_MSG(LL_TRACE, "malloc sz %lu, new cred %u", sz, new_credits);
if (new_credits < 0)
{
niova_atomic_inc(credits);
return NULL;
}


void *buf = niova_malloc_can_fail(sz);
if (!buf)
return NULL;
Expand Down Expand Up @@ -231,7 +230,7 @@ tcp_mgr_setup(struct tcp_mgr_instance *tmi, void *data,
if (tmi->tmi_nworkers == 0)
return rc;

for (int i = 0; i < tmi->tmi_nworkers; i++)
for (size_t i = 0; i < tmi->tmi_nworkers; i++)
thread_creator_wait_until_ctl_loop_reached(&tmi->tmi_workers[i]);
}

Expand Down Expand Up @@ -549,7 +548,7 @@ tcp_mgr_bulk_progress_recv(struct tcp_mgr_connection *tmc)
else if (recv_bytes < 0)
return recv_bytes;

NIOVA_ASSERT(recv_bytes <= tmc->tmc_bulk_remain);
NIOVA_ASSERT((size_t)recv_bytes <= tmc->tmc_bulk_remain);

tmc->tmc_bulk_offset += recv_bytes;
tmc->tmc_bulk_remain -= recv_bytes;
Expand Down Expand Up @@ -578,7 +577,7 @@ tcp_mgr_bulk_prepare_and_recv(struct tcp_mgr_connection *tmc, size_t bulk_size,

int bytes_avail;
ioctl(tmc->tmc_tsh.tsh_socket, FIONREAD, &bytes_avail);
if (bytes_avail >= bulk_size)
if (bytes_avail >= (ssize_t)bulk_size)
buf = niova_malloc_can_fail(buf_size);

if (!buf)
Expand Down Expand Up @@ -610,7 +609,7 @@ tcp_mgr_new_msg_handler(struct tcp_mgr_connection *tmc)
SIMPLE_FUNC_ENTRY(LL_TRACE);

struct tcp_mgr_instance *tmi = tmc->tmc_tmi;
size_t header_size = tmc->tmc_header_size;
ssize_t header_size = tmc->tmc_header_size;

NIOVA_ASSERT(tmi->tmi_recv_cb && tmi->tmi_bulk_size_cb && header_size &&
header_size <= TCP_MGR_MAX_HDR_SIZE);
Expand Down Expand Up @@ -805,6 +804,8 @@ tcp_mgr_handshake_cb(const struct epoll_handle *eph, uint32_t events)
{
SIMPLE_FUNC_ENTRY(LL_TRACE);
NIOVA_ASSERT(eph && eph->eph_arg);

(void)events;
struct tcp_mgr_connection *tmc = eph->eph_arg;
struct tcp_mgr_instance *tmi = tmc->tmc_tmi;

Expand Down Expand Up @@ -875,6 +876,8 @@ tcp_mgr_listen_cb(const struct epoll_handle *eph, uint32_t events)
SIMPLE_FUNC_ENTRY(LL_TRACE);
NIOVA_ASSERT(eph && eph->eph_arg);

(void)events;

struct tcp_mgr_instance *tmi = eph->eph_arg;

int rc = tcp_mgr_accept(tmi, eph->eph_fd);
Expand Down

0 comments on commit a6e74c9

Please sign in to comment.