From aa7af7213d89d88180ab6fc8bdb9ad86220522e2 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 12 Jul 2018 10:33:12 +0200 Subject: [PATCH] MINOR: buffer: replace calls to buffer_space_wraps() with b_space_wraps() And remove the unused function. --- include/common/buffer.h | 31 ------------------------------- src/mux_h2.c | 12 ++++++------ 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/include/common/buffer.h b/include/common/buffer.h index d7687f99d..ac56ae9c0 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -217,37 +217,6 @@ static inline int buffer_empty(const struct buffer *buf) return !buffer_not_empty(buf); } -/* Return non-zero only if the buffer's free space wraps : - * [ |oooo| ] => yes - * [ |iiii| ] => yes - * [ |oooo|iiii| ] => yes - * [oooo| ] => no - * [ |oooo] => no - * [iiii| ] => no - * [ |iiii] => no - * [oooo|iiii| ] => no - * [ |oooo|iiii] => no - * [iiii| |oooo] => no - * [oo|iiii| |oo] => no - * [iiii| |oo|ii] => no - * [oooooooooo|iiiiiiiiiii] => no - * [iiiiiiiiiiiii|oooooooo] => no - * - * So the only case where the buffer does not wrap is when there's data either - * at the beginning or at the end of the buffer. Thus we have this : - * - if (p+i >= size) ==> doesn't wrap - * - if (p-data <= o) ==> doesn't wrap - * - otherwise wraps - */ -static inline int buffer_space_wraps(const struct buffer *buf) -{ - if (buf->p + buf->i >= buf->data + buf->size) - return 0; - if (buf->p <= buf->data + buf->o) - return 0; - return 1; -} - /* Returns non-zero if the buffer's INPUT is considered full, which means that * it holds at least as much INPUT data as (size - reserve). This also means * that data that are scheduled for output are considered as potential free diff --git a/src/mux_h2.c b/src/mux_h2.c index 9a1d71867..8aab234e5 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -2684,7 +2684,7 @@ static int h2_frt_decode_headers(struct h2s *h2s, struct buffer *buf, int count) goto fail; } - if (unlikely(buffer_space_wraps(buf))) { + if (unlikely(b_space_wraps(buf))) { /* it doesn't fit and the buffer is fragmented, * so let's defragment it and try again. */ @@ -2992,7 +2992,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf) outbuf.size = bo_contig_space(h2c->mbuf); outbuf.len = 0; - if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf)) + if (outbuf.size >= 9 || !b_space_wraps(h2c->mbuf)) break; realign_again: b_slow_realign(h2c->mbuf, trash.str, h2c->mbuf->o); @@ -3030,7 +3030,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf) outbuf.str[outbuf.len++] = list[0].v.ptr[2]; } else { - if (buffer_space_wraps(h2c->mbuf)) + if (b_space_wraps(h2c->mbuf)) goto realign_again; h2c->flags |= H2_CF_MUX_MFULL; @@ -3054,7 +3054,7 @@ static int h2s_frt_make_resp_headers(struct h2s *h2s, struct buffer *buf) if (!hpack_encode_header(&outbuf, list[hdr].n, list[hdr].v)) { /* output full */ - if (buffer_space_wraps(h2c->mbuf)) + if (b_space_wraps(h2c->mbuf)) goto realign_again; h2c->flags |= H2_CF_MUX_MFULL; @@ -3150,7 +3150,7 @@ static int h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf) outbuf.size = bo_contig_space(h2c->mbuf); outbuf.len = 0; - if (outbuf.size >= 9 || !buffer_space_wraps(h2c->mbuf)) + if (outbuf.size >= 9 || !b_space_wraps(h2c->mbuf)) break; realign_again: b_slow_realign(h2c->mbuf, trash.str, h2c->mbuf->o); @@ -3250,7 +3250,7 @@ static int h2s_frt_make_resp_data(struct h2s *h2s, struct buffer *buf) /* we have an opportunity for enlarging the too small * available space, let's try. */ - if (buffer_space_wraps(h2c->mbuf)) + if (b_space_wraps(h2c->mbuf)) goto realign_again; size = outbuf.size - 9; }