]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: make xprt->rcv_buf() use size_t for the count
authorWilly Tarreau <w@1wt.eu>
Wed, 18 Jul 2018 09:22:03 +0000 (11:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:41 +0000 (16:23 +0200)
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.

include/types/connection.h
src/raw_sock.c
src/ssl_sock.c

index f9757e547303e5086110c9d7df03e29d493fa181..69d73948ac070223182811e2f948da53963486d1 100644 (file)
@@ -268,7 +268,7 @@ enum {
  * 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 */
index abf23bd3f8511ada22d1f26e10bb34c034a09c9f..daf3d0701c5196f16803fec5b02cfeea6f230177 100644 (file)
@@ -250,10 +250,10 @@ int raw_sock_from_pipe(struct connection *conn, struct pipe *pipe)
  * 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;
index 8e38094ebeacb9c58931014815a6a958db411712..20b7cdfca0acaab05927e5697ca6b3d903ac898a 100644 (file)
@@ -5337,10 +5337,10 @@ reneg_ok:
  * 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);