Flexelinting

parent d95bf1d6
...@@ -15,3 +15,8 @@ ...@@ -15,3 +15,8 @@
// must always be included to ensure sanity // must always be included to ensure sanity
-efile(766, config.h) -efile(766, config.h)
// assert constructors not referenced
-esym(528, assert_*)
-emacro(747, WS_TASK_ALLOC_OBJ)
\ No newline at end of file
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
static void __attribute__((constructor)) static void __attribute__((constructor))
assert_zlib(void) assert_zlib(void)
{ {
assert(Z_DEFAULT_COMPRESSION == -1); assert(Z_DEFAULT_COMPRESSION == -1); //lint !e506 const bool
} }
// https://github.com/varnishcache/varnish-cache/pull/3815 // https://github.com/varnishcache/varnish-cache/pull/3815
...@@ -60,8 +60,8 @@ assert_zlib(void) ...@@ -60,8 +60,8 @@ assert_zlib(void)
static char default_level = Z_DEFAULT_COMPRESSION; static char default_level = Z_DEFAULT_COMPRESSION;
static const void *zipflow_request_priv = &zipflow_request_priv; static const void * const zipflow_request_priv = &zipflow_request_priv;
static const void *zipflow_top_priv = &zipflow_top_priv; static const void * const zipflow_top_priv = &zipflow_top_priv;
struct zipflow_top; struct zipflow_top;
struct zipflow_request { struct zipflow_request {
...@@ -111,7 +111,19 @@ get_zipflow_top(VRT_CTX) ...@@ -111,7 +111,19 @@ get_zipflow_top(VRT_CTX)
return (zft); return (zft);
} }
static struct vdp vdp_zipflow; static int vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv,
struct objcore *oc);
static int vdp_zipflow_fini(struct vdp_ctx *vdc, void **priv);
static int vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act,
void **priv, const void *ptr, ssize_t len);
static const struct vdp vdp_zipflow[1] = {{
.name = "zipflow",
.init = vdp_zipflow_init,
.bytes = vdp_zipflow_bytes,
.fini = vdp_zipflow_fini,
.priv1 = NULL
}};
static struct zipflow_request * static struct zipflow_request *
new_zipflow_request(VRT_CTX, struct zipflow_top *zft) new_zipflow_request(VRT_CTX, struct zipflow_top *zft)
...@@ -220,7 +232,7 @@ vmod_set_level(VRT_CTX, VCL_INT level) ...@@ -220,7 +232,7 @@ vmod_set_level(VRT_CTX, VCL_INT level)
} }
if (ctx->method == VCL_MET_INIT) { if (ctx->method == VCL_MET_INIT) {
default_level = level; default_level = (typeof(default_level))level;
return; return;
} }
AZ(ctx->method & VCL_MET_TASK_H); AZ(ctx->method & VCL_MET_TASK_H);
...@@ -239,6 +251,7 @@ vmod_meta(VRT_CTX, struct VARGS(meta) *args) ...@@ -239,6 +251,7 @@ vmod_meta(VRT_CTX, struct VARGS(meta) *args)
unsigned long u; unsigned long u;
char *e; char *e;
(void)args;
if (zfr == NULL) if (zfr == NULL)
return; return;
...@@ -251,8 +264,11 @@ vmod_meta(VRT_CTX, struct VARGS(meta) *args) ...@@ -251,8 +264,11 @@ vmod_meta(VRT_CTX, struct VARGS(meta) *args)
if (u == ULONG_MAX || (e != NULL && *e != '\0')) { if (u == ULONG_MAX || (e != NULL && *e != '\0')) {
VRT_fail(ctx, ".meta() error converting mode at %s: " VRT_fail(ctx, ".meta() error converting mode at %s: "
"%d (%s)", e, errno, VAS_errtxt(errno)); "%d (%s)", e, errno, VAS_errtxt(errno));
} else }
zfr->mode = u; else {
assert(u < UINT_MAX);
zfr->mode = (unsigned)u;
}
} }
if (args->valid_atime) if (args->valid_atime)
zfr->atime = args->atime; zfr->atime = args->atime;
...@@ -264,7 +280,7 @@ static const char * ...@@ -264,7 +280,7 @@ static const char *
get_url(VRT_CTX) get_url(VRT_CTX)
{ {
const char *url; const char *url;
VCL_HTTP http; VCL_HTTP http = NULL;
if (ctx->http_bereq != NULL) if (ctx->http_bereq != NULL)
http = ctx->http_bereq; http = ctx->http_bereq;
...@@ -283,9 +299,9 @@ get_url(VRT_CTX) ...@@ -283,9 +299,9 @@ get_url(VRT_CTX)
static const char * static const char *
default_name(VRT_CTX) default_name(VRT_CTX)
{ {
const char *url = get_url(ctx); const char *p, *url = get_url(ctx);
size_t l; ssize_t l;
char *p; char *q;
url = strrchr(url, '/'); url = strrchr(url, '/');
AN(url); AN(url);
...@@ -300,15 +316,16 @@ default_name(VRT_CTX) ...@@ -300,15 +316,16 @@ default_name(VRT_CTX)
assert(p > url); assert(p > url);
l = p - url; l = p - url;
p = WS_Copy(ctx->ws, url, 1 + l); l++;
if (p == NULL) q = WS_Copy(ctx->ws, url, (int)l);
if (q == NULL)
return ("unnamed_file"); return ("unnamed_file");
p[l] = '\0'; q[l] = '\0';
return (p); return (q);
} }
static VCL_TIME static VCL_TIME
lm(VRT_CTX) get_lm(VRT_CTX)
{ {
const char *p; const char *p;
VCL_TIME lm; VCL_TIME lm;
...@@ -331,7 +348,6 @@ lm(VRT_CTX) ...@@ -331,7 +348,6 @@ lm(VRT_CTX)
static void static void
fill_meta(VRT_CTX, struct zipflow_request *zfr) fill_meta(VRT_CTX, struct zipflow_request *zfr)
{ {
const char *r;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(zfr, ZIPFLOW_REQUEST_MAGIC); CHECK_OBJ_NOTNULL(zfr, ZIPFLOW_REQUEST_MAGIC);
...@@ -342,7 +358,7 @@ fill_meta(VRT_CTX, struct zipflow_request *zfr) ...@@ -342,7 +358,7 @@ fill_meta(VRT_CTX, struct zipflow_request *zfr)
if (zfr->atime < 0) if (zfr->atime < 0)
zfr->atime = ctx->now; zfr->atime = ctx->now;
if (zfr->mtime < 0) if (zfr->mtime < 0)
zfr->mtime = lm(ctx); zfr->mtime = get_lm(ctx);
VSLb(ctx->vsl, SLT_Debug, "%s %o %f %f", zfr->name, zfr->mode, VSLb(ctx->vsl, SLT_Debug, "%s %o %f %f", zfr->name, zfr->mode,
zfr->atime, zfr->mtime); zfr->atime, zfr->mtime);
} }
...@@ -354,11 +370,11 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) ...@@ -354,11 +370,11 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
switch(e) { switch(e) {
case VCL_EVENT_LOAD: case VCL_EVENT_LOAD:
if (VRT_AddFilter(ctx, NULL, &vdp_zipflow) != NULL) if (VRT_AddFilter(ctx, NULL, vdp_zipflow) != NULL)
return (1); return (1);
break; break;
case VCL_EVENT_DISCARD: case VCL_EVENT_DISCARD:
VRT_RemoveFilter(ctx, NULL, &vdp_zipflow); VRT_RemoveFilter(ctx, NULL, vdp_zipflow);
break; break;
case VCL_EVENT_WARM: case VCL_EVENT_WARM:
case VCL_EVENT_COLD: case VCL_EVENT_COLD:
...@@ -382,7 +398,7 @@ vdp_zipflow_put(void *priv, void const *ptr, size_t len) ...@@ -382,7 +398,7 @@ vdp_zipflow_put(void *priv, void const *ptr, size_t len)
if (ptr == NULL || len == 0) if (ptr == NULL || len == 0)
return (0); return (0);
return (VDP_bytes(priv, VDP_FLUSH, ptr, len)); return (VDP_bytes(priv, VDP_FLUSH, ptr, (ssize_t)len));
} }
static void static void
...@@ -402,6 +418,8 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) ...@@ -402,6 +418,8 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
struct zipflow_top *zft; struct zipflow_top *zft;
struct req *req; struct req *req;
(void)oc;
if (zfr == NULL) if (zfr == NULL)
return (1); return (1);
...@@ -444,6 +462,7 @@ vdp_zipflow_fini(struct vdp_ctx *vdc, void **priv) ...@@ -444,6 +462,7 @@ vdp_zipflow_fini(struct vdp_ctx *vdc, void **priv)
struct zipflow_top *zft; struct zipflow_top *zft;
int r; int r;
(void)vdc;
AN(priv); AN(priv);
zfr = *priv; zfr = *priv;
*priv = NULL; *priv = NULL;
...@@ -475,7 +494,8 @@ vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv, ...@@ -475,7 +494,8 @@ vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv,
(void) zip_close(zft->zip); (void) zip_close(zft->zip);
return (1); return (1);
} }
r = zip_data(zft->zip, ptr, len, act == VDP_END); assert(len >= 0);
r = zip_data(zft->zip, ptr, (size_t)len, act == VDP_END ? 1 : 0);
if (r) { if (r) {
VSLb(vdc->vsl, SLT_Error, "zip_data returned %d", r); VSLb(vdc->vsl, SLT_Error, "zip_data returned %d", r);
return (-1); return (-1);
...@@ -489,12 +509,5 @@ vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv, ...@@ -489,12 +509,5 @@ vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv,
if (r) if (r)
VSLb(vdc->vsl, SLT_Error, "zip_close returned %d", r); VSLb(vdc->vsl, SLT_Error, "zip_close returned %d", r);
memset(zfr, 0, sizeof *zfr); memset(zfr, 0, sizeof *zfr);
return (VDP_bytes(vdc, VDP_END, NULL, 0)); return (VDP_bytes(vdc, VDP_END, NULL, (size_t)0));
} }
static struct vdp vdp_zipflow = {
.name = "zipflow",
.init = vdp_zipflow_init,
.bytes = vdp_zipflow_bytes,
.fini = vdp_zipflow_fini
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment