From 08ec536277a78ffd97ebfc6330966603c9bb41ef Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 15 May 2023 19:29:38 +0200 Subject: net: drop the _all suffix --- src/net.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/net.c') diff --git a/src/net.c b/src/net.c index c3a4b5e..a641d3b 100644 --- a/src/net.c +++ b/src/net.c @@ -146,7 +146,7 @@ int net_connect(const char *host, const char *port) return socket_fd; } -static ssize_t net_send(int fd, const void *buf, size_t size) +static ssize_t net_send_part(int fd, const void *buf, size_t size) { static const int flags = MSG_NOSIGNAL; @@ -159,12 +159,13 @@ static ssize_t net_send(int fd, const void *buf, size_t size) return ret; } -int net_send_all(int fd, const void *buf, size_t size) +int net_send(int fd, const void *buf, size_t size) { size_t sent_total = 0; while (sent_total < size) { - ssize_t sent_now = net_send(fd, (const char *)buf + sent_total, size - sent_total); + ssize_t sent_now = + net_send_part(fd, (const char *)buf + sent_total, size - sent_total); if (sent_now < 0) return -1; sent_total += sent_now; @@ -173,7 +174,7 @@ int net_send_all(int fd, const void *buf, size_t size) return 0; } -int net_recv_all(int fd, void *buf, size_t size) +int net_recv(int fd, void *buf, size_t size) { ssize_t read_total = 0; @@ -334,11 +335,11 @@ int net_send_buf(int fd, const struct buf *buf) int ret = 0; uint32_t size = htonl(buf->size); - ret = net_send_all(fd, &size, sizeof(size)); + ret = net_send(fd, &size, sizeof(size)); if (ret < 0) return ret; - ret = net_send_all(fd, buf->data, buf->size); + ret = net_send(fd, buf->data, buf->size); if (ret < 0) return ret; @@ -350,7 +351,7 @@ int net_recv_buf(int fd, struct buf **buf) uint32_t size = 0; int ret = 0; - ret = net_recv_all(fd, &size, sizeof(size)); + ret = net_recv(fd, &size, sizeof(size)); if (ret < 0) { log_err("Couldn't read buffer size\n"); goto fail; @@ -363,7 +364,7 @@ int net_recv_buf(int fd, struct buf **buf) goto fail; } - ret = net_recv_all(fd, data, size); + ret = net_recv(fd, data, size); if (ret < 0) { log_err("Couldn't read buffer\n"); goto free_data; -- cgit v1.2.3