MINOR: buffer: remove bo_ptr()

It was replaced by co_head() when a channel was known, otherwise b_head().
This commit is contained in:
Willy Tarreau 2018-06-07 18:16:48 +02:00
parent dda2e41881
commit 89faf5d7c3
8 changed files with 19 additions and 29 deletions

View 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;
}

View 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 */

View 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;

View 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);
}

View 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

View 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;

View 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 */

View 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;
}