MEDIUM: connection: make xprt->rcv_buf() use size_t for the count
Just like we have a size_t for xprt->snd_buf(), we adjust to use size_t
for rcv_buf()'s count argument and return value. It also removes the
ambiguity related to the possibility to see a negative value there.
diff --git a/include/types/connection.h b/include/types/connection.h
index f9757e5..69d7394 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -268,7 +268,7 @@
* and the other ones are used to setup and release the transport layer.
*/
struct xprt_ops {
- int (*rcv_buf)(struct connection *conn, struct buffer *buf, int count); /* recv callback */
+ size_t (*rcv_buf)(struct connection *conn, struct buffer *buf, size_t count); /* recv callback */
size_t (*snd_buf)(struct connection *conn, const struct buffer *buf, size_t count, int flags); /* send callback */
int (*rcv_pipe)(struct connection *conn, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
int (*snd_pipe)(struct connection *conn, struct pipe *pipe); /* send-to-pipe callback */
diff --git a/src/raw_sock.c b/src/raw_sock.c
index abf23bd..daf3d07 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -250,10 +250,10 @@
* errno is cleared before starting so that the caller knows that if it spots an
* error without errno, it's pending and can be retrieved via getsockopt(SO_ERROR).
*/
-static int raw_sock_to_buf(struct connection *conn, struct buffer *buf, int count)
+static size_t raw_sock_to_buf(struct connection *conn, struct buffer *buf, size_t count)
{
- int ret, done = 0;
- int try;
+ ssize_t ret;
+ size_t try, done = 0;
if (!conn_ctrl_ready(conn))
return 0;
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 8e38094..20b7cdf 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -5337,10 +5337,10 @@
* avoiding the call if inappropriate. The function does not call the
* connection's polling update function, so the caller is responsible for this.
*/
-static int ssl_sock_to_buf(struct connection *conn, struct buffer *buf, int count)
+static size_t ssl_sock_to_buf(struct connection *conn, struct buffer *buf, size_t count)
{
- int ret, done = 0;
- int try;
+ ssize_t ret;
+ size_t try, done = 0;
conn_refresh_polling_flags(conn);