]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: make b_getblk_nc() take size_t for the block sizes
authorWilly Tarreau <w@1wt.eu>
Wed, 18 Jul 2018 09:49:27 +0000 (11:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:41 +0000 (16:23 +0200)
Till now we used to reimplement it using ints to limit external changes
but we must adjust it and the various users to switch to size_t.

include/common/buf.h
include/proto/channel.h
src/channel.c
src/hlua.c
src/mux_h2.c

index 488c4064fe9cbd9b0c220feec823ebc375aece69..b7a5df31774d514bb8e137c6512024683c7c8bfc 100644 (file)
@@ -352,7 +352,7 @@ static inline size_t b_getblk(const struct buffer *buf, char *blk, size_t len, s
  *   =0 : not enough data available. <blk*> are left undefined.
  * The buffer is left unaffected. Unused buffers are left in an undefined state.
  */
-static inline size_t b_getblk_nc(const struct buffer *buf, const char **blk1, int *len1, const char **blk2, int *len2, size_t ofs, size_t max)
+static inline size_t b_getblk_nc(const struct buffer *buf, const char **blk1, size_t *len1, const char **blk2, size_t *len2, size_t ofs, size_t max)
 {
        size_t l1;
 
index eedeaaea9d5e144ad8b6af7b69f7d524d9d5386b..026574f512512d7d9a2e229bce8a8421b18cf452 100644 (file)
@@ -48,13 +48,13 @@ unsigned long long __channel_forward(struct channel *chn, unsigned long long byt
 int ci_putblk(struct channel *chn, const char *str, int len);
 struct buffer *ci_swpbuf(struct channel *chn, struct buffer *buf);
 int ci_putchr(struct channel *chn, char c);
-int ci_getline_nc(const struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
-int ci_getblk_nc(const struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
+int ci_getline_nc(const struct channel *chn, char **blk1, size_t *len1, char **blk2, size_t *len2);
+int ci_getblk_nc(const struct channel *chn, char **blk1, size_t *len1, char **blk2, size_t *len2);
 int co_inject(struct channel *chn, const char *msg, int len);
 int co_getline(const struct channel *chn, char *str, int len);
 int co_getblk(const struct channel *chn, char *blk, int len, int offset);
-int co_getline_nc(const struct channel *chn, const char **blk1, int *len1, const char **blk2, int *len2);
-int co_getblk_nc(const struct channel *chn, const char **blk1, int *len1, const char **blk2, int *len2);
+int co_getline_nc(const struct channel *chn, const char **blk1, size_t *len1, const char **blk2, size_t *len2);
+int co_getblk_nc(const struct channel *chn, const char **blk1, size_t *len1, const char **blk2, size_t *len2);
 
 
 /* returns a pointer to the stream the channel belongs to */
index 3b0592f507a5665c3584e1c9520d02bacddfb8ce..b3382a76312eb97fba282dfdd0a670adee23a211 100644 (file)
@@ -312,7 +312,7 @@ int co_getblk(const struct channel *chn, char *blk, int len, int offset)
  * The channel status is not changed. The caller must call co_skip() to
  * update it. Unused buffers are left in an undefined state.
  */
-int co_getblk_nc(const struct channel *chn, const char **blk1, int *len1, const char **blk2, int *len2)
+int co_getblk_nc(const struct channel *chn, const char **blk1, size_t *len1, const char **blk2, size_t *len2)
 {
        if (unlikely(chn->buf->o == 0)) {
                if (chn->flags & CF_SHUTW)
@@ -333,8 +333,8 @@ int co_getblk_nc(const struct channel *chn, const char **blk1, int *len1, const
  * the '\n'. Unused buffers are left in an undefined state.
  */
 int co_getline_nc(const struct channel *chn,
-                  const char **blk1, int *len1,
-                  const char **blk2, int *len2)
+                  const char **blk1, size_t *len1,
+                  const char **blk2, size_t *len2)
 {
        int retcode;
        int l;
@@ -377,8 +377,8 @@ int co_getline_nc(const struct channel *chn,
  *   <0 : no more bytes readable because input is shut.
  */
 int ci_getblk_nc(const struct channel *chn,
-                 char **blk1, int *len1,
-                 char **blk2, int *len2)
+                 char **blk1, size_t *len1,
+                 char **blk2, size_t *len2)
 {
        if (unlikely(chn->buf->i == 0)) {
                if (chn->flags & CF_SHUTR)
@@ -409,8 +409,8 @@ int ci_getblk_nc(const struct channel *chn,
  * the '\n'. Unused buffers are left in an undefined state.
  */
 int ci_getline_nc(const struct channel *chn,
-                  char **blk1, int *len1,
-                  char **blk2, int *len2)
+                  char **blk1, size_t *len1,
+                  char **blk2, size_t *len2)
 {
        int retcode;
        int l;
index eb27ebc7ea16f484374d984ab5315fec2ba49397..7976242d5c0c53c8fd7945aa2e88db55b74e2c46 100644 (file)
@@ -1736,12 +1736,12 @@ __LJMP static int hlua_socket_receive_yield(struct lua_State *L, int status, lua
        int wanted = lua_tointeger(L, 2);
        struct hlua *hlua = hlua_gethlua(L);
        struct appctx *appctx;
-       int len;
+       size_t len;
        int nblk;
        const char *blk1;
-       int len1;
+       size_t len1;
        const char *blk2;
-       int len2;
+       size_t len2;
        int skip_at_end = 0;
        struct channel *oc;
        struct stream_interface *si;
@@ -2774,8 +2774,8 @@ static inline int _hlua_channel_dup(struct channel *chn, lua_State *L)
 {
        char *blk1;
        char *blk2;
-       int len1;
-       int len2;
+       size_t len1;
+       size_t len2;
        int ret;
        luaL_Buffer b;
 
@@ -2862,9 +2862,9 @@ __LJMP static int hlua_channel_getline_yield(lua_State *L, int status, lua_KCont
 {
        char *blk1;
        char *blk2;
-       int len1;
-       int len2;
-       int len;
+       size_t len1;
+       size_t len2;
+       size_t len;
        struct channel *chn;
        int ret;
        luaL_Buffer b;
@@ -3634,9 +3634,9 @@ __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KC
        struct stream_interface *si = appctx->appctx->owner;
        int ret;
        const char *blk1;
-       int len1;
+       size_t len1;
        const char *blk2;
-       int len2;
+       size_t len2;
 
        /* Read the maximum amount of data avalaible. */
        ret = co_getline_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
@@ -3686,12 +3686,12 @@ __LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KCont
 {
        struct hlua_appctx *appctx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
        struct stream_interface *si = appctx->appctx->owner;
-       int len = MAY_LJMP(luaL_checkinteger(L, 2));
+       size_t len = MAY_LJMP(luaL_checkinteger(L, 2));
        int ret;
        const char *blk1;
-       int len1;
+       size_t len1;
        const char *blk2;
-       int len2;
+       size_t len2;
 
        /* Read the maximum amount of data avalaible. */
        ret = co_getblk_nc(si_oc(si), &blk1, &len1, &blk2, &len2);
@@ -4097,9 +4097,9 @@ __LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_K
        struct channel *chn = si_ic(si);
        int ret;
        const char *blk1;
-       int len1;
+       size_t len1;
        const char *blk2;
-       int len2;
+       size_t len2;
 
        /* Maybe we cant send a 100-continue ? */
        if (appctx->appctx->ctx.hlua_apphttp.flags & APPLET_100C) {
@@ -4183,9 +4183,9 @@ __LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KCon
        struct channel *chn = si_ic(si);
        int ret;
        const char *blk1;
-       int len1;
+       size_t len1;
        const char *blk2;
-       int len2;
+       size_t len2;
 
        /* Maybe we cant send a 100-continue ? */
        if (appctx->appctx->ctx.hlua_apphttp.flags & APPLET_100C) {
@@ -6627,9 +6627,9 @@ static void hlua_applet_http_fct(struct appctx *ctx)
        struct proxy *px = strm->be;
        struct hlua *hlua = ctx->ctx.hlua_apphttp.hlua;
        const char *blk1;
-       int len1;
+       size_t len1;
        const char *blk2;
-       int len2;
+       size_t len2;
        int ret;
 
        /* If the stream is disconnect or closed, ldo nothing. */
index ec5554b178c3c6fc1680050bc8bc8ba06cf6f93b..e36ca8f5face9706bc0a8c4e7aed37cd62db9480 100644 (file)
@@ -3128,7 +3128,7 @@ static size_t h2s_frt_make_resp_data(struct h2s *h2s, const struct buffer *buf,
        int es_now = 0;
        int size = 0;
        const char *blk1, *blk2;
-       int len1, len2;
+       size_t len1, len2;
 
        if (h2c_mux_busy(h2c, h2s)) {
                h2s->flags |= H2_SF_BLK_MBUSY;