[master] cb1b5899b Silence an annoying flexelint message

Poul-Henning Kamp phk at FreeBSD.org
Tue Mar 12 09:48:07 UTC 2019


commit cb1b5899b13f0240631f54794dd7c26660245cb0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Mar 12 09:21:29 2019 +0000

    Silence an annoying flexelint message

diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index cbdda42c0..efd560db6 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -52,21 +52,21 @@ static const char H2_prism[24] = {
 };
 
 static size_t
-h2_enc_settings(const struct h2_settings *h2s, uint8_t *buf, size_t n)
+h2_enc_settings(const struct h2_settings *h2s, uint8_t *buf, ssize_t n)
 {
-	size_t len = 0;
+	uint8_t *p = buf;
 
 #define H2_SETTING(U,l,v,d,...)				\
 	if (h2s->l != d) {				\
-		len += 6;				\
-		assert(len <= n);			\
-		vbe16enc(buf, v);			\
-		buf += 2;				\
-		vbe32enc(buf, h2s->l);			\
-		buf += 4;				\
+		n -= 6;					\
+		assert(n >= 0);				\
+		vbe16enc(p, v);				\
+		p += 2;					\
+		vbe32enc(p, h2s->l);			\
+		p += 4;					\
 	}
 #include "tbl/h2_settings.h"
-	return (len);
+	return (p - buf);
 }
 
 static const struct h2_settings H2_proto_settings = {


More information about the varnish-commit mailing list