mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-24 13:42:16 +00:00
MINOR: buffer: use b_orig() to replace most references to b->data
This patch updates most users of b->data to use b_orig().
This commit is contained in:
parent
50227f9b88
commit
591d445049
@ -364,7 +364,7 @@ static inline size_t b_getblk_nc(const struct buffer *buf, const char **blk1, si
|
||||
if (l1 < max) {
|
||||
*len1 = l1;
|
||||
*len2 = max - l1;
|
||||
*blk2 = buf->data;
|
||||
*blk2 = b_orig(buf);
|
||||
return 2;
|
||||
}
|
||||
*len1 = max;
|
||||
|
@ -64,7 +64,7 @@ void buffer_dump(FILE *o, struct buffer *b, int from, int to);
|
||||
/* Normalizes a pointer after an addition */
|
||||
static inline char *buffer_wrap_add(const struct buffer *buf, char *ptr)
|
||||
{
|
||||
if (ptr - buf->size >= buf->data)
|
||||
if (ptr - buf->size >= b_orig(buf))
|
||||
ptr -= buf->size;
|
||||
return ptr;
|
||||
}
|
||||
@ -77,9 +77,9 @@ static inline char *buffer_wrap_add(const struct buffer *buf, char *ptr)
|
||||
*/
|
||||
static inline const char *buffer_pointer(const struct buffer *buf, const char *ptr)
|
||||
{
|
||||
if (ptr < buf->data)
|
||||
if (ptr < b_orig(buf))
|
||||
ptr += buf->size;
|
||||
else if (ptr - buf->size >= buf->data)
|
||||
else if (ptr - buf->size >= b_orig(buf))
|
||||
ptr -= buf->size;
|
||||
return ptr;
|
||||
}
|
||||
@ -405,7 +405,7 @@ static inline int b_isteq(const struct buffer *b, unsigned int o, size_t n, cons
|
||||
if (*p++ != *r.ptr++)
|
||||
return -1;
|
||||
if (unlikely(p == end))
|
||||
p = b->data;
|
||||
p = b_orig(b);
|
||||
}
|
||||
return ist.len;
|
||||
}
|
||||
@ -447,7 +447,7 @@ static inline int bi_istput(struct buffer *b, const struct ist ist)
|
||||
while (r.len--) {
|
||||
*p++ = *r.ptr++;
|
||||
if (unlikely(p == end))
|
||||
p = b->data;
|
||||
p = b_orig(b);
|
||||
}
|
||||
return ist.len;
|
||||
}
|
||||
@ -477,7 +477,7 @@ static inline int bo_istput(struct buffer *b, const struct ist ist)
|
||||
while (r.len--) {
|
||||
*p++ = *r.ptr++;
|
||||
if (unlikely(p == end))
|
||||
p = b->data;
|
||||
p = b_orig(b);
|
||||
}
|
||||
return ist.len;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ static inline int h1_skip_chunk_crlf(const struct buffer *buf, int start, int st
|
||||
bytes++;
|
||||
ptr++;
|
||||
if (ptr >= b_wrap(buf))
|
||||
ptr = buf->data;
|
||||
ptr = b_orig(buf);
|
||||
}
|
||||
|
||||
if (bytes > stop - start)
|
||||
@ -210,7 +210,7 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
|
||||
if (c < 0) /* not a hex digit anymore */
|
||||
break;
|
||||
if (unlikely(++ptr >= end))
|
||||
ptr = buf->data;
|
||||
ptr = b_orig(buf);
|
||||
if (unlikely(chunk & 0xF8000000)) /* integer overflow will occur if result >= 2GB */
|
||||
goto error;
|
||||
chunk = (chunk << 4) + c;
|
||||
@ -223,7 +223,7 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
|
||||
|
||||
while (HTTP_IS_SPHT(*ptr)) {
|
||||
if (++ptr >= end)
|
||||
ptr = buf->data;
|
||||
ptr = b_orig(buf);
|
||||
if (--stop == 0)
|
||||
return 0;
|
||||
}
|
||||
@ -236,7 +236,7 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
|
||||
/* we now have a CR or an LF at ptr */
|
||||
if (likely(*ptr == '\r')) {
|
||||
if (++ptr >= end)
|
||||
ptr = buf->data;
|
||||
ptr = b_orig(buf);
|
||||
if (--stop == 0)
|
||||
return 0;
|
||||
}
|
||||
@ -244,7 +244,7 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
|
||||
if (*ptr != '\n')
|
||||
goto error;
|
||||
if (++ptr >= end)
|
||||
ptr = buf->data;
|
||||
ptr = b_orig(buf);
|
||||
--stop;
|
||||
/* done */
|
||||
break;
|
||||
@ -252,13 +252,13 @@ static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int s
|
||||
else if (likely(*ptr == ';')) {
|
||||
/* chunk extension, ends at next CRLF */
|
||||
if (++ptr >= end)
|
||||
ptr = buf->data;
|
||||
ptr = b_orig(buf);
|
||||
if (--stop == 0)
|
||||
return 0;
|
||||
|
||||
while (!HTTP_IS_CRLF(*ptr)) {
|
||||
if (++ptr >= end)
|
||||
ptr = buf->data;
|
||||
ptr = b_orig(buf);
|
||||
if (--stop == 0)
|
||||
return 0;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
|
||||
|
||||
delta = len - (end - pos);
|
||||
|
||||
if (b_tail(b) + delta > b->data + b->size)
|
||||
if (b_tail(b) + delta > b_wrap(b))
|
||||
return 0; /* no space left */
|
||||
|
||||
if (b_data(b) &&
|
||||
@ -123,7 +123,7 @@ int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len)
|
||||
|
||||
delta = len + 2;
|
||||
|
||||
if (b_tail(b) + delta >= b->data + b->size)
|
||||
if (b_tail(b) + delta >= b_wrap(b))
|
||||
return 0; /* no space left */
|
||||
|
||||
if (b_data(b) &&
|
||||
|
@ -169,7 +169,7 @@ int ci_putblk(struct channel *chn, const char *blk, int len)
|
||||
max = b_contig_space(chn->buf);
|
||||
memcpy(ci_tail(chn), blk, MIN(len, max));
|
||||
if (len > max)
|
||||
memcpy(chn->buf->data, blk + max, len - max);
|
||||
memcpy(b_orig(chn->buf), blk + max, len - max);
|
||||
|
||||
chn->buf->i += len;
|
||||
chn->total += len;
|
||||
@ -386,10 +386,10 @@ int ci_getblk_nc(const struct channel *chn,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (unlikely(chn->buf->p + chn->buf->i > chn->buf->data + chn->buf->size)) {
|
||||
if (unlikely(chn->buf->p + chn->buf->i > b_wrap(chn->buf))) {
|
||||
*blk1 = chn->buf->p;
|
||||
*len1 = chn->buf->data + chn->buf->size - chn->buf->p;
|
||||
*blk2 = chn->buf->data;
|
||||
*len1 = b_wrap(chn->buf) - chn->buf->p;
|
||||
*blk2 = b_orig(chn->buf);
|
||||
*len2 = chn->buf->i - *len1;
|
||||
return 2;
|
||||
}
|
||||
|
@ -516,22 +516,22 @@ static inline __maybe_unused void h2_set_frame_size(void *frame, uint32_t len)
|
||||
static inline __maybe_unused void h2_get_buf_bytes(void *dst, size_t bytes,
|
||||
const struct buffer *b, int o)
|
||||
{
|
||||
readv_bytes(dst, bytes, b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
|
||||
readv_bytes(dst, bytes, b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
|
||||
}
|
||||
|
||||
static inline __maybe_unused uint16_t h2_get_n16(const struct buffer *b, int o)
|
||||
{
|
||||
return readv_n16(b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
|
||||
return readv_n16(b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
|
||||
}
|
||||
|
||||
static inline __maybe_unused uint32_t h2_get_n32(const struct buffer *b, int o)
|
||||
{
|
||||
return readv_n32(b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
|
||||
return readv_n32(b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
|
||||
}
|
||||
|
||||
static inline __maybe_unused uint64_t h2_get_n64(const struct buffer *b, int o)
|
||||
{
|
||||
return readv_n64(b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
|
||||
return readv_n64(b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,14 +284,10 @@ static size_t raw_sock_to_buf(struct connection *conn, struct buffer *buf, size_
|
||||
* EINTR too.
|
||||
*/
|
||||
while (count > 0) {
|
||||
/* first check if we have some room after p+i */
|
||||
try = buf->data + buf->size - (buf->p + buf->i);
|
||||
/* otherwise continue between data and p-o */
|
||||
if (try <= 0) {
|
||||
try = buf->p - (buf->data + buf->o);
|
||||
if (try <= 0)
|
||||
break;
|
||||
}
|
||||
try = b_contig_space(buf);
|
||||
if (!try)
|
||||
break;
|
||||
|
||||
if (try > count)
|
||||
try = count;
|
||||
|
||||
|
@ -5361,16 +5361,13 @@ static size_t ssl_sock_to_buf(struct connection *conn, struct buffer *buf, size_
|
||||
while (count > 0) {
|
||||
int need_out = 0;
|
||||
|
||||
/* first check if we have some room after p+i */
|
||||
try = buf->data + buf->size - (buf->p + buf->i);
|
||||
/* otherwise continue between data and p-o */
|
||||
if (try <= 0) {
|
||||
try = buf->p - (buf->data + buf->o);
|
||||
if (try <= 0)
|
||||
break;
|
||||
}
|
||||
try = b_contig_space(buf);
|
||||
if (!try)
|
||||
break;
|
||||
|
||||
if (try > count)
|
||||
try = count;
|
||||
|
||||
if (((conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_EARLY_DATA)) == CO_FL_EARLY_SSL_HS) &&
|
||||
conn->tmp_early_data != -1) {
|
||||
*b_tail(buf) = conn->tmp_early_data;
|
||||
|
12
src/stream.c
12
src/stream.c
@ -2979,9 +2979,9 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
|
||||
human_time(TICKS_TO_MS(strm->req.wex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "<NEVER>",
|
||||
strm->req.buf,
|
||||
strm->req.buf->data, (unsigned int)strm->req.buf->o,
|
||||
(int)(strm->req.buf->p - strm->req.buf->data),
|
||||
strm->txn ? strm->txn->req.next : 0, (unsigned int)strm->req.buf->i,
|
||||
b_orig(strm->req.buf), (unsigned int)co_data(&strm->req),
|
||||
(int)(strm->req.buf->p - b_orig(strm->req.buf)),
|
||||
strm->txn ? strm->txn->req.next : 0, (unsigned int)ci_data(&strm->req),
|
||||
(unsigned int)strm->req.buf->size);
|
||||
|
||||
chunk_appendf(&trash,
|
||||
@ -3008,9 +3008,9 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
|
||||
human_time(TICKS_TO_MS(strm->res.wex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "<NEVER>",
|
||||
strm->res.buf,
|
||||
strm->res.buf->data, (unsigned int)strm->res.buf->o,
|
||||
(int)(strm->res.buf->p - strm->res.buf->data),
|
||||
strm->txn ? strm->txn->rsp.next : 0, (unsigned int)strm->res.buf->i,
|
||||
b_orig(strm->res.buf), (unsigned int)co_data(&strm->res),
|
||||
(int)(strm->res.buf->p - b_orig(strm->res.buf)),
|
||||
strm->txn ? strm->txn->rsp.next : 0, (unsigned int)ci_data(&strm->res),
|
||||
(unsigned int)strm->res.buf->size);
|
||||
|
||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user