]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: remove bo_ptr()
authorWilly Tarreau <w@1wt.eu>
Thu, 7 Jun 2018 16:16:48 +0000 (18:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jul 2018 14:23:40 +0000 (16:23 +0200)
It was replaced by co_head() when a channel was known, otherwise b_head().

include/common/buffer.h
src/buffer.c
src/channel.c
src/flt_http_comp.c
src/mux_h2.c
src/raw_sock.c
src/ssl_sock.c
src/stats.c

index baa8631ffd562cc058fbec802aac001183cda426..fcb61f3c70641cb88770512b90391c0ec1d58fb6 100644 (file)
@@ -117,16 +117,6 @@ static inline char *bi_end(const struct buffer *b)
        return ret;
 }
 
-/* Returns the start of the output data in a buffer */
-static inline char *bo_ptr(const struct buffer *b)
-{
-       char *ret = b->p - b->o;
-
-       if (ret < b->data)
-               ret += b->size;
-       return ret;
-}
-
 /* Returns the end of the output data in a buffer */
 static inline char *bo_end(const struct buffer *b)
 {
@@ -417,14 +407,14 @@ static inline int bo_getblk(const struct buffer *buf, char *blk, int len, int of
        if (len + offset > buf->o)
                return 0;
 
-       firstblock = buf->data + buf->size - bo_ptr(buf);
+       firstblock = buf->data + buf->size - b_head(buf);
        if (firstblock > offset) {
                if (firstblock >= len + offset) {
-                       memcpy(blk, bo_ptr(buf) + offset, len);
+                       memcpy(blk, b_head(buf) + offset, len);
                        return len;
                }
 
-               memcpy(blk, bo_ptr(buf) + offset, firstblock - offset);
+               memcpy(blk, b_head(buf) + offset, firstblock - offset);
                memcpy(blk + firstblock - offset, buf->data, len - firstblock + offset);
                return len;
        }
@@ -452,7 +442,7 @@ static inline int bo_getblk_nc(struct buffer *buf, char **blk1, int *len1, char
                return 2;
        }
 
-       *blk1 = bo_ptr(buf);
+       *blk1 = b_head(buf);
        *len1 = buf->o;
        return 1;
 }
index 127def2cadada964818c3e853e7500afc3efbc2f..5085e729510b4110d5cf3cf0ca3f94e30324550c 100644 (file)
@@ -90,8 +90,8 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
                return 0;  /* no space left */
 
        if (buffer_not_empty(b) &&
-           bi_end(b) + delta > bo_ptr(b) &&
-           bo_ptr(b) >= bi_end(b))
+           bi_end(b) + delta > b_head(b) &&
+           b_head(b) >= bi_end(b))
                return 0;  /* no space left before wrapping data */
 
        /* first, protect the end of the buffer */
@@ -129,8 +129,8 @@ int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len)
                return 0;  /* no space left */
 
        if (buffer_not_empty(b) &&
-           bi_end(b) + delta > bo_ptr(b) &&
-           bo_ptr(b) >= bi_end(b))
+           bi_end(b) + delta > b_head(b) &&
+           b_head(b) >= bi_end(b))
                return 0;  /* no space left before wrapping data */
 
        /* first, protect the end of the buffer */
index 0ddfc6fa7e6fe84e404eae26f0834dc963cca0a6..4f2346b6a7415ba88a101daef2b216c28e711002 100644 (file)
@@ -256,7 +256,7 @@ int co_getline(const struct channel *chn, char *str, int len)
                goto out;
        }
 
-       p = bo_ptr(chn->buf);
+       p = b_head(chn->buf);
 
        if (max > chn->buf->o) {
                max = chn->buf->o;
index 20843973825760cd982899f0be6d230ef0619332..d80dc08f4346d5d1c35bc40137981bbc64630bb3 100644 (file)
@@ -721,7 +721,7 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s,
        /* Copy previous data from ib->o into ob->o */
        if (ib->o > 0) {
                left = bo_contig_data(ib);
-               memcpy(ob->p - ob->o, bo_ptr(ib), left);
+               memcpy(ob->p - ob->o, b_head(ib), left);
                if (ib->o - left) /* second part of the buffer */
                        memcpy(ob->p - ob->o + left, ib->data, ib->o - left);
        }
index b7b98aad6db04d7f500f3b77b91cd5cb75ad9867..afd33cb066112eeaf9866af82526cba1f6191d0d 100644 (file)
@@ -2969,7 +2969,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf)
         * block does not wrap and we can safely read it this way without
         * having to realign the buffer.
         */
-       ret = h1_headers_to_hdr_list(bo_ptr(buf), bo_ptr(buf) + buf->o,
+       ret = h1_headers_to_hdr_list(b_head(buf), b_head(buf) + buf->o,
                                     list, sizeof(list)/sizeof(list[0]), h1m);
        if (ret <= 0) {
                /* incomplete or invalid response, this is abnormal coming from
index ad0210105688bc02ce170e21ae9bd2ac565e2b85..0e1f971ef182ef5c91e253898ca152118ba7765f 100644 (file)
@@ -396,7 +396,7 @@ static int raw_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
                if (try < buf->o || flags & CO_SFL_MSG_MORE)
                        send_flag |= MSG_MORE;
 
-               ret = send(conn->handle.fd, bo_ptr(buf), try, send_flag);
+               ret = send(conn->handle.fd, b_head(buf), try, send_flag);
 
                if (ret > 0) {
                        buf->o -= ret;
index 3f70b1223c289b7bf3a669cc7f8b7e5d1a87a82f..60fce0d0292db30273e87c233b03cab6c167d3c6 100644 (file)
@@ -5562,7 +5562,7 @@ static int ssl_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
                                        break;
                                }
                        }
-                       ret = SSL_write_early_data(conn->xprt_ctx, bo_ptr(buf), try, &written_data);
+                       ret = SSL_write_early_data(conn->xprt_ctx, b_head(buf), try, &written_data);
                        if (ret == 1) {
                                ret = written_data;
                                conn->sent_early_data += ret;
@@ -5575,7 +5575,7 @@ static int ssl_sock_from_buf(struct connection *conn, struct buffer *buf, int fl
 
                } else
 #endif
-               ret = SSL_write(conn->xprt_ctx, bo_ptr(buf), try);
+               ret = SSL_write(conn->xprt_ctx, b_head(buf), try);
 
                if (conn->flags & CO_FL_ERROR) {
                        /* CO_FL_ERROR may be set by ssl_sock_infocbk */
index aee3a0f7ea1258e54a7cb6841e349049a167ac81..aa4aaaaaa9d991b6df621439c33e11ce4ad47626 100644 (file)
@@ -1844,7 +1844,7 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px
                scope_txt[0] = 0;
                if (appctx->ctx.stats.scope_len) {
                        strcpy(scope_txt, STAT_SCOPE_PATTERN);
-                       memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+                       memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
                        scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
                }
 
@@ -2006,7 +2006,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, st
                 * name does not match, skip it.
                 */
                if (appctx->ctx.stats.scope_len &&
-                   strnistr(px->id, strlen(px->id), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len) == NULL)
+                   strnistr(px->id, strlen(px->id), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len) == NULL)
                        return 1;
 
                if ((appctx->ctx.stats.flags & STAT_BOUND) &&
@@ -2335,7 +2335,7 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u
                      );
 
        /* scope_txt = search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
-       memcpy(scope_txt, bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+       memcpy(scope_txt, co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
        scope_txt[appctx->ctx.stats.scope_len] = '\0';
 
        chunk_appendf(&trash,
@@ -2347,7 +2347,7 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u
        scope_txt[0] = 0;
        if (appctx->ctx.stats.scope_len) {
                strcpy(scope_txt, STAT_SCOPE_PATTERN);
-               memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+               memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
                scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
        }
 
@@ -2983,7 +2983,7 @@ static int stats_send_http_redirect(struct stream_interface *si)
        scope_txt[0] = 0;
        if (appctx->ctx.stats.scope_len) {
                strcpy(scope_txt, STAT_SCOPE_PATTERN);
-               memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), bo_ptr(si_ob(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+               memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
                scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
        }