[master] 14bd7de Flexelinting
Poul-Henning Kamp
phk at FreeBSD.org
Sun May 27 10:19:20 UTC 2018
commit 14bd7de8bfcfab3bc8933697be6db6cf5552a893
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sun May 27 10:18:16 2018 +0000
Flexelinting
Use pthread_cleanup_pop(0) and an explict call to the cleanup
function to make things visible to FlexeLint.
diff --git a/bin/varnishtest/hpack.h b/bin/varnishtest/hpack.h
index 9df6785..94b7347 100644
--- a/bin/varnishtest/hpack.h
+++ b/bin/varnishtest/hpack.h
@@ -33,7 +33,7 @@ struct hpk_iter;
struct hpk_ctx * HPK_NewCtx(uint32_t tblsize);
void HPK_FreeCtx(struct hpk_ctx *ctx);
-struct hpk_iter * HPK_NewIter(struct hpk_ctx *ctx, char *buf, int size);
+struct hpk_iter * HPK_NewIter(struct hpk_ctx *ctx, void *buf, int size);
void HPK_FreeIter(struct hpk_iter *iter);
enum hpk_result HPK_DecHdr(struct hpk_iter *iter, struct hpk_hdr *header);
diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c
index 4b2f608..d2f72b9 100644
--- a/bin/varnishtest/vtc_client.c
+++ b/bin/varnishtest/vtc_client.c
@@ -237,7 +237,8 @@ client_thread(void *priv)
}
vtc_log(vl, 2, "Ending");
VSB_destroy(&vsb);
- pthread_cleanup_pop(1);
+ pthread_cleanup_pop(0);
+ vtc_logclose(vl);
return (NULL);
}
diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c
index 403db13..52c8ee9 100644
--- a/bin/varnishtest/vtc_h2_hpack.c
+++ b/bin/varnishtest/vtc_h2_hpack.c
@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,6 +35,7 @@
#include "vdef.h"
#include "vas.h"
+#include "vqueue.h"
#include "hpack.h"
#include "vtc_h2_priv.h"
diff --git a/bin/varnishtest/vtc_h2_priv.h b/bin/varnishtest/vtc_h2_priv.h
index 796e940..5c646d3 100644
--- a/bin/varnishtest/vtc_h2_priv.h
+++ b/bin/varnishtest/vtc_h2_priv.h
@@ -26,22 +26,20 @@
* SUCH DAMAGE.
*/
-#include "vqueue.h"
-
#define ITER_DONE(iter) (iter->buf == iter->end ? hpk_done : hpk_more)
struct dynhdr {
- struct hpk_hdr header;
- VTAILQ_ENTRY(dynhdr) list;
+ struct hpk_hdr header;
+ VTAILQ_ENTRY(dynhdr) list;
};
VTAILQ_HEAD(dynamic_table,dynhdr);
struct hpk_iter {
- struct hpk_ctx *ctx;
- char *orig;
- char *buf;
- char *end;
+ struct hpk_ctx *ctx;
+ uint8_t *orig;
+ uint8_t *buf;
+ uint8_t *end;
};
const struct txt * tbl_get_key(const struct hpk_ctx *ctx, uint32_t index);
diff --git a/bin/varnishtest/vtc_h2_tbl.c b/bin/varnishtest/vtc_h2_tbl.c
index c0262af..0aaa352 100644
--- a/bin/varnishtest/vtc_h2_tbl.c
+++ b/bin/varnishtest/vtc_h2_tbl.c
@@ -26,14 +26,15 @@
* SUCH DAMAGE.
*/
+#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdio.h>
-#include <stdint.h>
#include "vdef.h"
#include "vas.h"
+#include "vqueue.h"
#include "hpack.h"
#include "vtc_h2_priv.h"
@@ -77,7 +78,7 @@ struct hpk_ctx {
struct hpk_iter *
-HPK_NewIter(struct hpk_ctx *ctx, char *buf, int size)
+HPK_NewIter(struct hpk_ctx *ctx, void *buf, int size)
{
struct hpk_iter *iter = malloc(sizeof(*iter));
assert(iter);
@@ -87,7 +88,7 @@ HPK_NewIter(struct hpk_ctx *ctx, char *buf, int size)
iter->ctx = ctx;
iter->orig = buf;
iter->buf = buf;
- iter->end = buf + size;
+ iter->end = iter->buf + size;
return (iter);
}
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index edfe796..54b2a20 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -1924,7 +1924,8 @@ http_process(struct vtclog *vl, const char *spec, int sock, int *sfd,
pthread_cleanup_push(http_process_cleanup, hp);
parse_string(spec, http_cmds, hp, vl);
retval = hp->fd;
- pthread_cleanup_pop(1);
+ pthread_cleanup_pop(0);
+ http_process_cleanup(hp);
return (retval);
}
diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c
index b8857b3..fccc8e3 100644
--- a/bin/varnishtest/vtc_http2.c
+++ b/bin/varnishtest/vtc_http2.c
@@ -374,6 +374,7 @@ parse_data(struct stream *s, struct frame *f)
struct http *hp;
uint32_t size = f->size;
char *data = f->data;
+
CHECK_OBJ_NOTNULL(f, FRAME_MAGIC);
CHECK_OBJ_NOTNULL(s, STREAM_MAGIC);
CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);;
@@ -1366,7 +1367,7 @@ cmd_tx11obj(CMD_ARGS)
int scheme_done = 1;
uint32_t stid = 0, pstid;
uint32_t weight = 16;
- int exclusive = 0;
+ uint32_t exclusive = 0;
char *buf;
struct hpk_iter *iter;
struct frame f;
@@ -2257,7 +2258,7 @@ cmd_rxmsg(CMD_ARGS)
CHKFRAME(f->type, TYPE_CONTINUATION, rcv, *av);
}
- while (!end_stream && (f = rxstuff(s))) {
+ while (!end_stream && (f = rxstuff(s)) != NULL) {
rcv++;
CHKFRAME(f->type, TYPE_DATA, rcv, *av);
end_stream = f->flags & END_STREAM;
@@ -2695,25 +2696,27 @@ void
b64_settings(const struct http *hp, const char *s)
{
uint16_t i;
- uint64_t v;
+ uint64_t v, vv;
const char *buf;
int shift;
+
while (*s) {
v = 0;
for (shift = 42; shift >= 0; shift -= 6) {
if (*s >= 'A' && *s <= 'Z')
- v |= (uint64_t)(*s - 'A') << shift;
+ vv = (*s - 'A');
else if (*s >= 'a' && *s <= 'z')
- v |= (uint64_t)((*s - 'a') + 26) << shift;
+ vv = (*s - 'a') + 26;
else if (*s >= '0' && *s <= '9')
- v |= (uint64_t)((*s - '0') + 52) << shift;
+ vv = (*s - '0') + 52;
else if (*s == '-')
- v |= (uint64_t)62 << shift;
+ vv = 62;
else if (*s == '_')
- v |= (uint64_t)63 << shift;
+ vv = 63;
else
vtc_fatal(hp->vl,
"Bad \"HTTP2-Settings\" header");
+ v |= vv << shift;
s++;
}
i = v >> 32;
diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c
index add0f1f..4735472 100644
--- a/bin/varnishtest/vtc_logexp.c
+++ b/bin/varnishtest/vtc_logexp.c
@@ -153,7 +153,7 @@ struct logexp {
int tag_last;
int d_arg;
- int g_arg;
+ enum VSL_grouping_e g_arg;
char *query;
struct vsm *vsm;
@@ -171,7 +171,8 @@ logexp_delete_tests(struct logexp *le)
struct logexp_test *test;
CHECK_OBJ_NOTNULL(le, LOGEXP_MAGIC);
- while ((test = VTAILQ_FIRST(&le->tests))) {
+ while (!VTAILQ_EMPTY(&le->tests)) {
+ test = VTAILQ_FIRST(&le->tests);
CHECK_OBJ_NOTNULL(test, LOGEXP_TEST_MAGIC);
VTAILQ_REMOVE(&le->tests, test, list);
VSB_destroy(&test->str);
@@ -262,7 +263,7 @@ logexp_dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[],
CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC);
- for (i = 0; (t = pt[i]); i++) {
+ for (i = 0; (t = pt[i]) != NULL; i++) {
while (1 == VSL_Next(t->c)) {
if (!VSL_Match(vsl, t->c))
continue;
@@ -510,6 +511,7 @@ void
cmd_logexpect(CMD_ARGS)
{
struct logexp *le, *le2;
+ int i;
(void)priv;
(void)cmd;
@@ -579,10 +581,11 @@ cmd_logexpect(CMD_ARGS)
if (!strcmp(*av, "-g")) {
if (av[1] == NULL)
vtc_fatal(le->vl, "Missing -g argument");
- le->g_arg = VSLQ_Name2Grouping(av[1], strlen(av[1]));
- if (le->g_arg < 0)
+ i = VSLQ_Name2Grouping(av[1], strlen(av[1]));
+ if (i < 0)
vtc_fatal(le->vl, "Unknown grouping '%s'",
av[1]);
+ le->g_arg = (enum VSL_grouping_e)i;
av++;
continue;
}
diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c
index 33ead86..4876352 100644
--- a/bin/varnishtest/vtc_server.c
+++ b/bin/varnishtest/vtc_server.c
@@ -256,7 +256,8 @@ server_thread(void *priv)
VTCP_close(&fd);
}
vtc_log(vl, 2, "Ending");
- pthread_cleanup_pop(1);
+ pthread_cleanup_pop(0);
+ vtc_logclose(vl);
return (NULL);
}
@@ -302,7 +303,8 @@ server_dispatch_wrk(void *priv)
vtc_fatal(vl, "Shutdown failed: %s", strerror(errno));
VTCP_close(&s->fd);
vtc_log(vl, 2, "Ending");
- pthread_cleanup_pop(1);
+ pthread_cleanup_pop(0);
+ vtc_logclose(vl);
return (NULL);
}
@@ -321,9 +323,7 @@ server_dispatch_thread(void *priv)
assert(s->sock >= 0);
vl = vtc_logopen(s->name);
-#if !defined(__SUNPRO_C)
pthread_cleanup_push(vtc_logclose, vl);
-#endif
vtc_log(vl, 2, "Dispatch started on %s", s->listen);
@@ -342,9 +342,8 @@ server_dispatch_thread(void *priv)
s2->run = 1;
AZ(pthread_create(&s2->tp, NULL, server_dispatch_wrk, s2));
}
-#if !defined(__SUNPRO_C)
- pthread_cleanup_pop(1);
-#endif
+ pthread_cleanup_pop(0);
+ vtc_logclose(vl);
NEEDLESS(return(NULL));
}
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index b7304b5..ac7e17a 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -223,7 +223,7 @@ varnishlog_thread(void *priv)
c = NULL;
opt = 0;
- while (v->fds[1] > 0 || c != NULL) {
+ while (v->fds[1] > 0 || c != NULL) { //lint !e845 bug in flint
if (c == NULL) {
if (vtc_error)
break;
More information about the varnish-commit
mailing list