From 6df3f10a7c55a793aa173f8dda770283ba96297e Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 23 Jul 2008 17:37:44 +0000 Subject: [PATCH] More Flexelint nitpickery git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3004 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_vrt.c | 4 ++++ varnish-cache/bin/varnishd/flint.lnt | 6 ++++++ varnish-cache/bin/varnishd/mgt_child.c | 1 + varnish-cache/lib/libvarnish/cli_common.c | 1 + varnish-cache/lib/libvcl/vcc_acl.c | 14 ++++++++------ varnish-cache/lib/libvcl/vcc_compile.h | 1 - varnish-cache/lib/libvcl/vcc_token.c | 10 ++-------- varnish-cache/lib/libvcl/vcc_xref.c | 10 +++++----- 8 files changed, 27 insertions(+), 20 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 6c08a1ad..2bc01609 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -118,6 +118,7 @@ VRT_GetHdr(const struct sess *sp, enum gethdr_e where, const char *n) /*--------------------------------------------------------------------*/ +/*lint -e{818} ap,hp could be const */ static char * vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap) { @@ -419,6 +420,7 @@ VRT_l_req_backend(struct sess *sp, struct director *be) sp->director = be; } +/*lint -e{818} sp could be const */ struct director * VRT_r_req_backend(struct sess *sp) { @@ -450,6 +452,7 @@ VRT_l_req_grace(struct sess *sp, double a) sp->grace = a; } +/*lint -e{818} sp could be const */ double VRT_r_req_grace(struct sess *sp) { @@ -626,6 +629,7 @@ VRT_Rollback(struct sess *sp) /*--------------------------------------------------------------------*/ +/*lint -e{818} sp could be const */ void VRT_panic(struct sess *sp, const char *str, ...) { diff --git a/varnish-cache/bin/varnishd/flint.lnt b/varnish-cache/bin/varnishd/flint.lnt index 3b9d95e5..480c7a9d 100644 --- a/varnish-cache/bin/varnishd/flint.lnt +++ b/varnish-cache/bin/varnishd/flint.lnt @@ -10,6 +10,8 @@ -efile(766, ../../config.h) -emacro(413, offsetof) // likely null pointer +-emacro(702, WEXITSTATUS) // signed shift right + // -header(../../config.h) @@ -38,6 +40,10 @@ -emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small) -emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean +-esym(765, vcc_ProcAction) // could be made static +-esym(759, vcc_ProcAction) // could be moved to module +-esym(714, vcc_ProcAction) // not ref. + -esym(534, sprintf) // Ignoring return value of function -esym(534, asprintf) // Ignoring return value of function -esym(534, printf) // Ignoring return value of function diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index fede7fda..849db1fa 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -544,6 +544,7 @@ mgt_run(int dflag, const char *T_arg) /*--------------------------------------------------------------------*/ +/*lint -e{818} priv could be const */ void mcf_server_startstop(struct cli *cli, const char * const *av, void *priv) { diff --git a/varnish-cache/lib/libvarnish/cli_common.c b/varnish-cache/lib/libvarnish/cli_common.c index def3da89..a4fc9f94 100644 --- a/varnish-cache/lib/libvarnish/cli_common.c +++ b/varnish-cache/lib/libvarnish/cli_common.c @@ -68,6 +68,7 @@ cli_out(struct cli *cli, const char *fmt, ...) va_end(ap); } +/*lint -e{818} cli could be const */ void cli_quote(struct cli *cli, const char *s) { diff --git a/varnish-cache/lib/libvcl/vcc_acl.c b/varnish-cache/lib/libvcl/vcc_acl.c index 85f1f9ba..20d2acfd 100644 --- a/varnish-cache/lib/libvcl/vcc_acl.c +++ b/varnish-cache/lib/libvcl/vcc_acl.c @@ -155,7 +155,7 @@ vcc_acl_emit_entry(struct tokenlist *tl, const struct acl_e *ae, int l, const un AN(ae2); *ae2 = *ae; - ae2->data[0] = fam; + ae2->data[0] = fam & 0xff; ae2->mask += 8; /* family matching */ memcpy(ae2->data + 1, u, l); @@ -171,7 +171,7 @@ vcc_acl_try_getaddrinfo(struct tokenlist *tl, struct acl_e *ae) struct sockaddr_in *sin4; struct sockaddr_in6 *sin6; unsigned char *u, i4, i6; - int error, l; + int error; memset(&hint, 0, sizeof hint); hint.ai_family = PF_UNSPEC; @@ -204,21 +204,23 @@ vcc_acl_try_getaddrinfo(struct tokenlist *tl, struct acl_e *ae) switch(res->ai_family) { case PF_INET: sin4 = (void*)res->ai_addr; + assert(sizeof(sin4->sin_family) == 1); + assert(sizeof(sin4->sin_addr) == 4); u = (void*)&sin4->sin_addr; - l = 4; if (ae->t_mask == NULL) ae->mask = 32; i4++; - vcc_acl_emit_entry(tl, ae, l, u, res->ai_family); + vcc_acl_emit_entry(tl, ae, 4, u, res->ai_family); break; case PF_INET6: sin6 = (void*)res->ai_addr; + assert(sizeof(sin4->sin_family) == 1); + assert(sizeof(sin4->sin_addr) == 16); u = (void*)&sin6->sin6_addr; - l = 16; if (ae->t_mask == NULL) ae->mask = 128; i6++; - vcc_acl_emit_entry(tl, ae, l, u, res->ai_family); + vcc_acl_emit_entry(tl, ae, 16, u, res->ai_family); break; default: vsb_printf(tl->sb, diff --git a/varnish-cache/lib/libvcl/vcc_compile.h b/varnish-cache/lib/libvcl/vcc_compile.h index 696bea06..4b80f0cd 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.h +++ b/varnish-cache/lib/libvcl/vcc_compile.h @@ -208,7 +208,6 @@ void vcc_ErrWhere(struct tokenlist *tl, const struct token *t); void vcc__Expect(struct tokenlist *tl, unsigned tok, int line); int vcc_Teq(const struct token *t1, const struct token *t2); int vcc_IdIs(const struct token *t, const char *p); -int vcc_isCid(const struct token *t); void vcc_ExpectCid(struct tokenlist *tl); void vcc_Lexer(struct tokenlist *tl, struct source *sp); void vcc_NextToken(struct tokenlist *tl); diff --git a/varnish-cache/lib/libvcl/vcc_token.c b/varnish-cache/lib/libvcl/vcc_token.c index c6f4000e..5e20e965 100644 --- a/varnish-cache/lib/libvcl/vcc_token.c +++ b/varnish-cache/lib/libvcl/vcc_token.c @@ -191,7 +191,7 @@ vcc_IdIs(const struct token *t, const char *p) * Check that we have a C-identifier */ -int +static int vcc_isCid(const struct token *t) { const char *q; @@ -266,7 +266,7 @@ vcc_decstr(struct tokenlist *tl) vcc_ErrWhere(tl, tl->t); return(1); } - u = vcc_xdig(p[1]) * 16 + vcc_xdig(p[2]); + u = (vcc_xdig(p[1]) * 16 + vcc_xdig(p[2])) & 0xff; if (!isgraph(u)) { vcc_AddToken(tl, CSTR, p, p + 3); vsb_printf(tl->sb, @@ -301,12 +301,6 @@ vcc_AddToken(struct tokenlist *tl, unsigned tok, const char *b, const char *e) else VTAILQ_INSERT_TAIL(&tl->tokens, t, list); tl->t = t; - if (0) { - fprintf(stderr, "[%s %.*s] ", - vcl_tnames[tok], PF(t)); - if (tok == EOI) - fprintf(stderr, "\n"); - } } /*-------------------------------------------------------------------- diff --git a/varnish-cache/lib/libvcl/vcc_xref.c b/varnish-cache/lib/libvcl/vcc_xref.c index 21c324a3..8ce7e875 100644 --- a/varnish-cache/lib/libvcl/vcc_xref.c +++ b/varnish-cache/lib/libvcl/vcc_xref.c @@ -242,7 +242,7 @@ void vcc_ProcAction(struct proc *p, unsigned returns, struct token *t) { - p->returns |= (1 << returns); + p->returns |= (1U << returns); /* Record the first instance of this return */ if (p->return_tok[returns] == NULL) p->return_tok[returns] = t; @@ -266,16 +266,15 @@ vcc_CheckActionRecurse(struct tokenlist *tl, struct proc *p, unsigned returns) } u = p->returns & ~returns; if (u) { -/*lint -e525 */ +/*lint -save -e525 -e539 */ #define VCL_RET_MAC(a, b, c, d) \ if (u & VCL_RET_##b) { \ vsb_printf(tl->sb, "Invalid return \"%s\"\n", #a); \ vcc_ErrWhere(tl, p->return_tok[d]); \ } -/*lint -e525 */ #include "vcl_returns.h" -/*lint +e525 */ #undef VCL_RET_MAC +/*lint -restore */ vsb_printf(tl->sb, "\n...in function \"%.*s\"\n", PF(p->name)); vcc_ErrWhere(tl, p->name); return (1); @@ -314,11 +313,12 @@ vcc_CheckAction(struct tokenlist *tl) if (m->returns & c) \ vsb_printf(tl->sb, " \"%s\"", #a); #define VCL_RET_MAC_E(a, b, c, d) VCL_RET_MAC(a, b, c, d) -/*lint -e525 */ +/*lint -save -e525 -e539 */ #include "vcl_returns.h" /*lint +e525 */ #undef VCL_RET_MAC #undef VCL_RET_MAC_E +/*lint -restore */ vsb_printf(tl->sb, "\n"); return (1); } -- 2.39.5