]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: simplify copy of STREAM frames to RX buffer
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 28 Feb 2022 09:00:54 +0000 (10:00 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 1 Mar 2022 09:52:31 +0000 (10:52 +0100)
qc_strm_cpy can be simplified by simply using b_putblk which already
handle wrapping of the destination buffer. The function is kept to
update the frame length and offset fields.

src/xprt_quic.c

index 084afaeffb488ccfbdd42b20d758cc255eb1a11c..a1b89c771f96830cfd730dd5656a1dab97315e73 100644 (file)
@@ -1976,22 +1976,9 @@ static size_t qc_strm_cpy(struct buffer *buf, struct quic_stream *strm_frm)
 {
        size_t ret;
 
-       ret = 0;
-       while (strm_frm->len) {
-               size_t try;
-
-               try = b_contig_space(buf);
-               if (!try)
-                       break;
-
-               if (try > strm_frm->len)
-                       try = strm_frm->len;
-               memcpy(b_tail(buf), strm_frm->data, try);
-               strm_frm->len -= try;
-               strm_frm->offset.key += try;
-               b_add(buf, try);
-               ret += try;
-       }
+       ret = b_putblk(buf, (char *)strm_frm->data, strm_frm->len);
+       strm_frm->len -= ret;
+       strm_frm->offset.key += ret;
 
        return ret;
 }