]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ncbuf: adjust ncb_data with NCBUF_NULL
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 31 May 2022 09:44:25 +0000 (11:44 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 31 May 2022 12:31:48 +0000 (14:31 +0200)
Replace ncb_blk_is_null() by ncb_is_null() as a prelude to ncb_data().
The result is the same : the function will return 0 if the buffer is
uninitialized. However, it is clearer to directly call ncb_is_null() to
reflect this.

There is no functional change with this commit.

src/ncbuf.c

index d0ced6d217d90e90bdb46f7149125c43e23de5a8..1944cfe34fa158e549279fca5174f8b45431f9a6 100644 (file)
@@ -494,12 +494,15 @@ int ncb_is_full(const struct ncbuf *buf)
  */
 ncb_sz_t ncb_data(const struct ncbuf *buf, ncb_sz_t off)
 {
-       struct ncb_blk blk = ncb_blk_find(buf, off);
-       ncb_sz_t off_blk = ncb_blk_off(blk, off);
+       struct ncb_blk blk;
+       ncb_sz_t off_blk;
 
-       if (ncb_blk_is_null(blk))
+       if (ncb_is_null(buf))
                return 0;
 
+       blk = ncb_blk_find(buf, off);
+       off_blk = ncb_blk_off(blk, off);
+
        /* if <off> at the frontier between two and <blk> is gap, retrieve the
         * next data block.
         */