[master] 6054d0c Flexelinting
Poul-Henning Kamp
phk at FreeBSD.org
Mon Nov 13 08:53:05 UTC 2017
commit 6054d0ccb0af036a371440fd625a938bf22dd324
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Nov 13 08:46:23 2017 +0000
Flexelinting
diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt
index b6b36df..1dc2716 100644
--- a/bin/varnishtest/flint.lnt
+++ b/bin/varnishtest/flint.lnt
@@ -5,6 +5,9 @@
-function(__assert(1), vtc_dump(2))
-function(__assert(1), vtc_hexdump(2))
+-emacro({779}, ENC) // String constant in comparison operator '!='
+-emacro({506}, CHKFRAME) // Constant value Boolean
+
-esym(850, av)
-esym(534, snprintf) // Only for varnishtest, and not really nice
diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c
index 52f1f1c..f986d2f 100644
--- a/bin/varnishtest/vtc_h2_hpack.c
+++ b/bin/varnishtest/vtc_h2_hpack.c
@@ -65,7 +65,7 @@ huff_decode(char *str, int nm, struct hpk_iter *iter, int ilen)
if (pl < tbl->msk) {
if (ilen == 0) {
if (pl == 0 || (MASK(pack, pl) ==
- (unsigned)((1 << pl) - 1))) {
+ (unsigned)((1U << pl) - 1U))) {
assert(tbl == &byte0);
return (l);
}
@@ -135,7 +135,7 @@ huff_encode(struct hpk_iter *iter, const char *str, int len)
if (pl) {
assert(pl < 8);
if (iter->buf == iter->end)
- return (1);
+ return (hpk_done);
pl += 8;
pack |= (uint64_t)0xff << (64 - pl);
*iter->buf = (char)(pack >> 56);
@@ -169,7 +169,7 @@ num_decode(uint32_t *result, struct hpk_iter *iter, uint8_t prefix)
*result = 0;
*result = *iter->buf & (0xff >> (8-prefix));
- if (*result < (1 << prefix) - 1) {
+ if (*result < (1U << prefix) - 1U) {
iter->buf++;
return (ITER_DONE(iter));
}
@@ -196,9 +196,9 @@ num_encode(struct hpk_iter *iter, uint8_t prefix, uint32_t num)
assert(prefix <= 8);
assert(iter->buf < iter->end);
- uint8_t pmax = (1 << prefix) - 1;
+ uint8_t pmax = (1U << prefix) - 1U;
- *iter->buf &= 0xff << prefix;
+ *iter->buf &= 0xffU << prefix;
if (num <= pmax) {
*iter->buf++ |= num;
return (ITER_DONE(iter));
diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c
index e75120f..a779c5a 100644
--- a/bin/varnishtest/vtc_http2.c
+++ b/bin/varnishtest/vtc_http2.c
@@ -124,14 +124,14 @@ clean_headers(struct hpk_hdr *h)
}
}
-#define ONLY_CLIENT(hp, av) \
+#define ONLY_H2_CLIENT(hp, av) \
do { \
if (hp->sfd != NULL) \
vtc_fatal(hp->vl, \
"\"%s\" only possible in client", av[0]); \
} while (0)
-#define ONLY_SERVER(hp, av) \
+#define ONLY_H2_SERVER(hp, av) \
do { \
if (hp->sfd == NULL) \
vtc_fatal(hp->vl, \
@@ -252,10 +252,7 @@ readFrameHeader(struct frame *f, const char *buf)
f->flags = (unsigned char)buf[4];
- f->stid = (0xff & (unsigned char)buf[5]) << 24;
- f->stid += (0xff & (unsigned char)buf[6]) << 16;
- f->stid += (0xff & (unsigned char)buf[7]) << 8;
- f->stid += (0xff & (unsigned char)buf[8]);
+ f->stid = vbe32dec(buf+5);
}
static void
@@ -271,10 +268,7 @@ writeFrameHeader(char *buf, const struct frame *f)
buf[4] = f->flags;
- buf[5] = (f->stid >> 24) & 0xff;
- buf[6] = (f->stid >> 16) & 0xff;
- buf[7] = (f->stid >> 8) & 0xff;
- buf[8] = (f->stid ) & 0xff;
+ vbe32enc(buf + 5, f->stid);
}
#define INIT_FRAME(f, ty, sz, id, fl) \
@@ -411,12 +405,7 @@ parse_data(struct stream *s, struct frame *f)
return;
}
- if (s->body) {
- s->body = realloc(s->body, s->bodylen + size + 1L);
- } else {
- AZ(s->bodylen);
- s->body = malloc(size + 1L);
- }
+ s->body = realloc(s->body, s->bodylen + size + 1L);
AN(s->body);
memcpy(s->body + s->bodylen, data, size);
s->bodylen += size;
@@ -791,7 +780,7 @@ receive_frame(void *priv)
else
hdrs = s->resp;
}
- hdrs[0].t = 0;
+ hdrs[0].t = hpk_unset;
AZ(vsb);
vsb = VSB_new_auto();
/*FALLTHROUGH*/
@@ -1395,19 +1384,19 @@ cmd_tx11obj(CMD_ARGS)
AN(buf);
if (!strcmp(cmd_str, "txreq")) {
- ONLY_CLIENT(s->hp, av);
+ ONLY_H2_CLIENT(s->hp, av);
f.type = TYPE_HEADERS;
f.flags |= END_STREAM;
method_done = 0;
path_done = 0;
scheme_done = 0;
} else if (!strcmp(cmd_str, "txresp")) {
- ONLY_SERVER(s->hp, av);
+ ONLY_H2_SERVER(s->hp, av);
f.type = TYPE_HEADERS;
f.flags |= END_STREAM;
status_done = 0;
} else if (!strcmp(cmd_str, "txpush")) {
- ONLY_SERVER(s->hp, av);
+ ONLY_H2_SERVER(s->hp, av);
f.type = TYPE_PUSH_PROMISE;
method_done = 0;
path_done = 0;
@@ -2248,9 +2237,9 @@ cmd_rxmsg(CMD_ARGS)
CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC);
if (!strcmp(av[0], "rxreq"))
- ONLY_SERVER(s->hp, av);
+ ONLY_H2_SERVER(s->hp, av);
else
- ONLY_CLIENT(s->hp, av);
+ ONLY_H2_CLIENT(s->hp, av);
f = rxstuff(s);
if (!f)
@@ -2392,7 +2381,8 @@ cmd_rxframe(CMD_ARGS)
(void)vl;
(void)av;
CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC);
- rxstuff(s);
+ if (rxstuff(s) == NULL)
+ vtc_fatal(s->hp->vl, "No frame received");
}
static void
More information about the varnish-commit
mailing list