Commit d763ce00 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Tell FlexeLint to check printf-like arguments and fix what it found.

Prompted to by:	DocWilco
parent 9cb9ba6f
......@@ -2,6 +2,9 @@
-ffc // No automatic custody
-printf(2, VSB_printf)
///////////////////////////////////////////////////////////////////////
// Weirdness relating to varnish includes etc.
......
......@@ -77,7 +77,7 @@ struct ban {
unsigned magic;
#define BAN_MAGIC 0x700b08ea
VTAILQ_ENTRY(ban) list;
unsigned refcount;
int refcount;
unsigned flags;
#define BAN_F_GONE (1 << 0)
#define BAN_F_REQ (1 << 2)
......@@ -841,7 +841,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
break;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (cache_param->diag_bitmap & 0x80000)
VSL(SLT_Debug, 0, "test: %p %d %d",
VSL(SLT_Debug, 0, "test: %p %u %u",
oc, oc->flags & OC_F_LURK, pass);
if ((oc->flags & OC_F_LURK) == pass)
break;
......@@ -892,7 +892,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
}
Lck_Unlock(&oh->mtx);
if (cache_param->diag_bitmap & 0x80000)
VSL(SLT_Debug, 0, "lurker done: %p %d %d",
VSL(SLT_Debug, 0, "lurker done: %p %u %u",
oc, oc->flags & OC_F_LURK, pass);
(void)HSH_Deref(sp->wrk, NULL, &o);
VTIM_sleep(cache_param->ban_lurker_sleep);
......
......@@ -92,7 +92,7 @@ cli_cb_after(const struct cli *cli)
ASSERT_CLI();
Lck_Unlock(&cli_mtx);
VSL(SLT_CLI, 0, "Wr %03u %u %s",
VSL(SLT_CLI, 0, "Wr %03u %zd %s",
cli->result, VSB_len(cli->sb), VSB_data(cli->sb));
}
......
......@@ -565,7 +565,7 @@ FetchBody(struct worker *w, struct object *obj)
w->busyobj->fetch_obj = NULL;
WSLB(w, SLT_Fetch_Body, "%u(%s) cls %d mklen %u",
WSLB(w, SLT_Fetch_Body, "%u(%s) cls %d mklen %d",
w->busyobj->body_status, body_status(w->busyobj->body_status),
cls, mklen);
......@@ -591,7 +591,7 @@ FetchBody(struct worker *w, struct object *obj)
if (cls == 0 && w->busyobj->should_close)
cls = 1;
WSLB(w, SLT_Length, "%u", obj->len);
WSLB(w, SLT_Length, "%zd", obj->len);
{
/* Sanity check fetch methods accounting */
......
......@@ -520,7 +520,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
if (q - p > htc->maxhdr) {
VSC_C_main->losthdr++;
WSL(w, SLT_LostHeader, vsl_id, "%.*s",
q - p > 20 ? 20 : q - p, p);
(int)(q - p > 20 ? 20 : q - p), p);
return (413);
}
......@@ -546,7 +546,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
} else {
VSC_C_main->losthdr++;
WSL(w, SLT_LostHeader, vsl_id, "%.*s",
q - p > 20 ? 20 : q - p, p);
(int)(q - p > 20 ? 20 : q - p), p);
return (413);
}
}
......
......@@ -114,7 +114,7 @@ Lck__Trylock(struct lock *lck, const char *p, const char *f, int l)
assert(r == 0 || r == EBUSY);
if (cache_param->diag_bitmap & 0x8)
VSL(SLT_Debug, 0,
"MTX_TRYLOCK(%s,%s,%d,%s) = %d", p, f, l, ilck->w);
"MTX_TRYLOCK(%s,%s,%d,%s) = %d", p, f, l, ilck->w, r);
if (r == 0) {
AZ(ilck->held);
ilck->held = 1;
......
......@@ -234,7 +234,7 @@ pan_sess(const struct sess *sp)
VSB_printf(pan_vsp, "sp = %p {\n", sp);
VSB_printf(pan_vsp,
" fd = %d, id = %d, xid = %u,\n",
" fd = %d, id = %u, xid = %u,\n",
sp->fd, sp->vsl_id & VSL_IDENTMASK, sp->xid);
VSB_printf(pan_vsp, " client = %s %s,\n",
sp->addr ? sp->addr : "?.?.?.?",
......
......@@ -64,7 +64,7 @@ VRY_Create(const struct sess *sp, const struct http *hp)
{
char *v, *p, *q, *h, *e;
struct vsb *sb, *sbh;
int l;
unsigned l;
/* No Vary: header, no worries */
if (!http_GetHdr(hp, H_Vary, &v))
......@@ -109,7 +109,7 @@ VRY_Create(const struct sess *sp, const struct http *hp)
e = h;
l = 0xffff;
}
VSB_printf(sb, "%c%c", (unsigned)l >> 8, l & 0xff);
VSB_printf(sb, "%c%c", (int)(l >> 8), (int)(l & 0xff));
/* Append to vary matching string */
VSB_bcat(sb, VSB_data(sbh), VSB_len(sbh));
if (e != h)
......
......@@ -74,7 +74,7 @@ VRT_count(const struct sess *sp, unsigned u)
return;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
if (cache_param->vcl_trace)
WSP(sp, SLT_VCL_trace, "%u %d.%d", u,
WSP(sp, SLT_VCL_trace, "%u %u.%u", u,
sp->vcl->ref[u].line, sp->vcl->ref[u].pos);
}
......@@ -83,7 +83,8 @@ VRT_count(const struct sess *sp, unsigned u)
void
VRT_acl_log(const struct sess *sp, const char *msg)
{
WSP(sp, SLT_VCL_acl, msg);
WSP(sp, SLT_VCL_acl, "%s", msg);
}
/*--------------------------------------------------------------------*/
......@@ -416,7 +417,7 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...)
SMS_Finish(sp->wrk->obj);
http_Unset(sp->wrk->obj->http, H_Content_Length);
http_PrintfHeader(sp->wrk, sp->vsl_id, sp->wrk->obj->http,
"Content-Length: %d", sp->wrk->obj->len);
"Content-Length: %zd", sp->wrk->obj->len);
}
/*--------------------------------------------------------------------*/
......
......@@ -55,7 +55,7 @@ vrt_do_string(struct worker *w, int fd, const struct http *hp, int fld,
AN(hp);
b = VRT_String(hp->ws, NULL, p, ap);
if (b == NULL || *b == '\0') {
WSL(w, SLT_LostHeader, fd, err);
WSL(w, SLT_LostHeader, fd, "%s", err);
} else {
http_SetH(hp, fld, b);
}
......
......@@ -165,7 +165,7 @@ WRW_Flush(struct worker *w)
if (i <= 0) {
wrw->werr++;
WSL(w, SLT_Debug, *wrw->wfd,
"Write error, retval = %d, len = %d, errno = %s",
"Write error, retval = %zd, len = %zd, errno = %s",
i, wrw->liov, strerror(errno));
}
}
......
-d__flexelint_v9__=1
-printf(3, VSL)
-printf(4, http_PrintfHeader)
-printf(4, WSL)
-printf(3, WSLB)
-printf(2, VSB_printf)
-esym(755, vct_*)
-esym(759, vev_*)
-esym(765, vev_*)
......
......@@ -308,7 +308,7 @@ void vcc_ErrToken(const struct vcc *tl, const struct token *t);
void vcc_ErrWhere(struct vcc *, const struct token *);
void vcc_ErrWhere2(struct vcc *, const struct token *, const struct token *);
void vcc__Expect(struct vcc *tl, unsigned tok, int line);
void vcc__Expect(struct vcc *tl, unsigned tok, unsigned line);
int vcc_Teq(const struct token *t1, const struct token *t2);
int vcc_IdIs(const struct token *t, const char *p);
void vcc_ExpectCid(struct vcc *tl);
......
......@@ -104,7 +104,7 @@ vcc_icoord(struct vsb *vsb, const struct token *t, int tail)
} else
pos++;
}
VSB_printf(vsb, "('%s' Line %d Pos %d)", t->src->name, lin, pos + 1);
VSB_printf(vsb, "('%s' Line %u Pos %u)", t->src->name, lin, pos + 1);
}
/*--------------------------------------------------------------------*/
......@@ -261,7 +261,7 @@ vcc_NextToken(struct vcc *tl)
}
void
vcc__Expect(struct vcc *tl, unsigned tok, int line)
vcc__Expect(struct vcc *tl, unsigned tok, unsigned line)
{
if (tl->t->tok == tok)
return;
......
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