MINOR: buffer: reset a buffer in b_reset() and not channel_init()

We'll soon need to be able to switch buffers without touching the
channel, so let's move buffer initialization out of channel_init().
We had the same in compressoin.c.
diff --git a/include/common/buffer.h b/include/common/buffer.h
index 2d657d1..fd29575 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -387,6 +387,14 @@
 	return bo_putblk(b, chk->str, chk->len);
 }
 
+/* Resets a buffer. The size is not touched. */
+static inline void b_reset(struct buffer *buf)
+{
+	buf->o = 0;
+	buf->i = 0;
+	buf->p = buf->data;
+}
+
 #endif /* _COMMON_BUFFER_H */
 
 /*
diff --git a/include/proto/channel.h b/include/proto/channel.h
index e323d34..cf7b413 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -51,9 +51,6 @@
 /* Initialize all fields in the channel. */
 static inline void channel_init(struct channel *chn)
 {
-	chn->buf->o = 0;
-	chn->buf->i = 0;
-	chn->buf->p = chn->buf->data;
 	chn->to_forward = 0;
 	chn->last_read = now_ms;
 	chn->xfer_small = chn->xfer_large = 0;
@@ -185,10 +182,8 @@
  */
 static inline void channel_erase(struct channel *chn)
 {
-	chn->buf->o = 0;
-	chn->buf->i = 0;
 	chn->to_forward = 0;
-	chn->buf->p = chn->buf->data;
+	b_reset(chn->buf);
 }
 
 /* marks the channel as "shutdown" ASAP for reads */
diff --git a/src/compression.c b/src/compression.c
index 3d6085e..b6c4ae2 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -139,9 +139,7 @@
 	 */
 
 	out->size = global.tune.bufsize;
-	out->i = 0;
-	out->o = 0;
-	out->p = out->data;
+	b_reset(out);
 
 	if (in->o > 0) {
 		left = in->o - bo_contig_data(in);
diff --git a/src/peers.c b/src/peers.c
index b196d88..9ff1773 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1241,6 +1241,7 @@
 		goto out_fail_req_buf; /* no memory */
 
 	s->req->buf->size = global.tune.bufsize;
+	b_reset(s->req->buf);
 	channel_init(s->req);
 	s->req->prod = &s->si[0];
 	s->req->cons = &s->si[1];
@@ -1267,6 +1268,7 @@
 		goto out_fail_rep_buf; /* no memory */
 
 	s->rep->buf->size = global.tune.bufsize;
+	b_reset(s->rep->buf);
 	channel_init(s->rep);
 	s->rep->prod = &s->si[1];
 	s->rep->cons = &s->si[0];
diff --git a/src/session.c b/src/session.c
index 7723074..d57a2d5 100644
--- a/src/session.c
+++ b/src/session.c
@@ -488,6 +488,7 @@
 
 	/* initialize the request buffer */
 	s->req->buf->size = global.tune.bufsize;
+	b_reset(s->req->buf);
 	channel_init(s->req);
 	s->req->prod = &s->si[0];
 	s->req->cons = &s->si[1];
@@ -505,6 +506,7 @@
 
 	/* initialize response buffer */
 	s->rep->buf->size = global.tune.bufsize;
+	b_reset(s->rep->buf);
 	channel_init(s->rep);
 	s->rep->prod = &s->si[1];
 	s->rep->cons = &s->si[0];