MINOR: buffer: replace bi_del() and bo_del() with b_del()
Till now the callers had to know which one to call for specific use cases.
Let's fuse them now since a single one will remain after the API migration.
Given that bi_del() may only be used where o==0, just combine the two tests
by first removing output data then only input.
diff --git a/include/common/buf.h b/include/common/buf.h
index 45686a2..be196f1 100644
--- a/include/common/buf.h
+++ b/include/common/buf.h
@@ -415,6 +415,23 @@
}
}
+/* b_del() : skips <del> bytes in a buffer <b>. Covers both the output and the
+ * input parts so it's up to the caller to know where it plays and that <del>
+ * is always smaller than the amount of data in the buffer.
+ */
+static inline void b_del(struct buffer *b, size_t del)
+{
+ if (del <= b->o) {
+ b->o -= del;
+ del = 0;
+ }
+ if (del) {
+ b->p = b_peek(b, del);
+ b->i -= del;
+ del = 0;
+ }
+}
+
/* b_realign_if_empty() : realigns a buffer if it's empty */
static inline void b_realign_if_empty(struct buffer *b)
{
diff --git a/include/common/buffer.h b/include/common/buffer.h
index 52d9dcc..c9868f0 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -85,26 +85,6 @@
return b->data + b->size - b->p;
}
-/* Skips <del> bytes in a one-way buffer <b> : <p> advances by <del>, <i>
- * shrinks by <del> as well, and <o> is left untouched (supposed to be zero).
- * The caller is responsible for ensuring that <del> is always smaller than or
- * equal to b->i.
- */
-static inline void bi_del(struct buffer *b, unsigned int del)
-{
- b->i -= del;
- b->p = b_ptr(b, del);
-}
-
-/* Skips <del> bytes from the output of buffer <b> by simply shrinking <o>.
- * The caller is responsible for ensuring that <del> is always smaller than or
- * equal to b->o.
- */
-static inline void bo_del(struct buffer *b, unsigned int del)
-{
- b->o -= del;
-}
-
/* Return the buffer's length in bytes by summing the input and the output */
static inline int buffer_len(const struct buffer *buf)
{
@@ -560,7 +540,7 @@
{
int ret = b_isteq(b, 0, b->i, ist);
if (ret > 0)
- bi_del(b, ret);
+ b_del(b, ret);
return ret;
}
diff --git a/include/proto/channel.h b/include/proto/channel.h
index 9568050..fdbcc94 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -727,8 +727,7 @@
*/
static inline void co_skip(struct channel *chn, int len)
{
- chn->buf->o -= len;
-
+ b_del(chn->buf, len);
if (buffer_empty(chn->buf))
chn->buf->p = chn->buf->data;