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

A bit of spit and polish inspired by DocWilcos varnishtest patch.

parent c14ced83
-efile(451, "../../include/vsc_all.h")
-e835 // A zero has been given as ___ argument to operator '___' (<<)
-e712 // 14 Info 712 Loss of precision (___) (___ to ___)
-e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___
......@@ -17,3 +18,4 @@
-e788 // enum constant '___' not used within defaulted switch
-e641 // Converting enum '___' to '___'
-esym(785,VSL_tags); // Sparse array
#!/bin/sh
if [ "x$1" = "x-ok" -a -f _.fl ] ; then
echo "Saved as reference"
mv _.fl _.fl.old
exit 0
fi
flexelint \
-I/usr/include \
../flint.lnt \
flint.lnt \
-I. \
-I../../include \
-I../.. \
../flint.lnt \
flint.lnt \
-I/usr/local/include \
-DVARNISH_STATE_DIR=\"foo\" \
*.c \
../../lib/libvarnishapi/*.c
../../lib/libvarnishapi/*.c \
2>&1 | tee _.fl
if [ -f _.fl.old ] ; then
diff -u _.fl.old _.fl
fi
if [ "x$1" = "x-ok" ] ; then
echo "Saved as reference"
mv _.fl _.fl.old
fi
......@@ -46,7 +46,6 @@
#include "libvarnish.h"
#include "vsl.h"
#include "vre.h"
#include "varnishapi.h"
static int b_flag, c_flag;
......@@ -60,7 +59,7 @@ static uint64_t bitmap[65536];
#define F_INVCL (1 << 0)
static void
h_order_finish(int fd, struct VSM_data *vd)
h_order_finish(int fd, const struct VSM_data *vd)
{
AZ(VSB_finish(ob[fd]));
......@@ -72,7 +71,7 @@ h_order_finish(int fd, struct VSM_data *vd)
}
static void
clean_order(struct VSM_data *vd)
clean_order(const struct VSM_data *vd)
{
unsigned u;
......@@ -321,7 +320,8 @@ main(int argc, char * const *argv)
w_arg = optarg;
break;
case 'm':
m_flag = 1; /* fall through */
m_flag = 1;
/* FALLTHROUGH */
default:
if (VSL_Arg(vd, c, optarg) > 0)
break;
......
......@@ -109,7 +109,7 @@ int VSM_ReOpen(struct VSM_data *vd, int diag);
* -1 failure to reopen.
*/
unsigned VSM_Seq(struct VSM_data *vd);
unsigned VSM_Seq(const struct VSM_data *vd);
/*
* Return the allocation sequence number
*/
......@@ -260,6 +260,7 @@ void VSL_NonBlocking(const struct VSM_data *vd, int nb);
int VSL_Dispatch(struct VSM_data *vd, VSL_handler_f *func, void *priv);
int VSL_NextLog(const struct VSM_data *lh, uint32_t **pp, uint64_t *bitmap);
int VSL_Matched(const struct VSM_data *vd, uint64_t bitmap);
int VSL_Name2Tag(const char *name, int l);
extern const char *VSL_tags[256];
#endif
......@@ -330,7 +330,7 @@ VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv)
CHECK_OBJ_NOTNULL(sha, VSM_CHUNK_MAGIC);
if (strcmp(sha->class, VSC_CLASS))
continue;
/*lint -save -e525 -e539 */
#define VSC_F(a,b,c,d,e)
#define VSC_DONE(a,b,c)
#define VSC_DO(U,l,t) \
......@@ -343,6 +343,7 @@ VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv)
#undef VSC_F
#undef VSC_DO
#undef VSC_DONE
/*lint -restore */
break;
}
return (i);
......
......@@ -206,7 +206,7 @@ vsl_nextlog(struct vsl *vsl, uint32_t **pp)
}
int
VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *mb)
VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *bits)
{
struct vsl *vsl;
uint32_t *p;
......@@ -268,7 +268,7 @@ VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *mb)
if (i != VRE_ERROR_NOMATCH)
continue;
}
if (mb != NULL) {
if (bits != NULL) {
struct vsl_re_match *vrm;
int j = 0;
VTAILQ_FOREACH(vrm, &vsl->matchers, next) {
......@@ -276,7 +276,7 @@ VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *mb)
i = VRE_exec(vrm->re, VSL_DATA(p),
VSL_LEN(p), 0, 0, NULL, 0);
if (i >= 0)
*mb |= 1 << j;
*bits |= (uintmax_t)1 << j;
}
j++;
}
......
......@@ -41,7 +41,6 @@
#include <unistd.h>
#include "vas.h"
#include "vin.h"
#include "vre.h"
#include "vbm.h"
#include "miniobj.h"
......@@ -50,6 +49,34 @@
#include "vsm_api.h"
#include "vsl_api.h"
/*--------------------------------------------------------------------
* Look up a tag
* 0..255 tag number
* -1 no tag matches
* -2 multiple tags match
*/
int
VSL_Name2Tag(const char *name, int l)
{
int i, n;
if (l == -1)
l = strlen(name);
n = -1;
for (i = 0; i < 256; i++) {
if (VSL_tags[i] != NULL &&
!strncasecmp(name, VSL_tags[i], l)) {
if (n == -1)
n = i;
else
n = -2;
}
}
return (n);
}
/*--------------------------------------------------------------------*/
static int
......@@ -99,8 +126,8 @@ vsl_IX_arg(const struct VSM_data *vd, const char *opt, int arg)
static int
vsl_ix_arg(const struct VSM_data *vd, const char *opt, int arg)
{
int i, j, l;
const char *b, *e, *p, *q;
int i, l;
const char *b, *e;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
/* If first option is 'i', set all bits for supression */
......@@ -120,24 +147,17 @@ vsl_ix_arg(const struct VSM_data *vd, const char *opt, int arg)
e++;
while (isspace(b[l - 1]))
l--;
for (i = 0; i < 256; i++) {
if (VSL_tags[i] == NULL)
continue;
p = VSL_tags[i];
q = b;
for (j = 0; j < l; j++)
if (tolower(*q++) != tolower(*p++))
break;
if (j != l || *p != '\0')
continue;
i = VSL_Name2Tag(b, l);
if (i >= 0) {
if (arg == 'x')
vbit_set(vd->vsl->vbm_supress, i);
else
vbit_clr(vd->vsl->vbm_supress, i);
break;
}
if (i == 256) {
} else if (i == -2) {
fprintf(stderr,
"\"%*.*s\" matches multiple tags\n", l, l, b);
return (-1);
} else {
fprintf(stderr,
"Could not match \"%*.*s\" to any tag\n", l, l, b);
return (-1);
......@@ -148,19 +168,6 @@ vsl_ix_arg(const struct VSM_data *vd, const char *opt, int arg)
/*--------------------------------------------------------------------*/
static int
name2tag(const char *n)
{
int i;
for (i = 0; i < 256; i++) {
if (VSL_tags[i] == NULL)
continue;
if (!strcasecmp(n, VSL_tags[i]))
return (i);
}
return (-1);
}
static int
vsl_m_arg(const struct VSM_data *vd, const char *opt)
......@@ -171,8 +178,6 @@ vsl_m_arg(const struct VSM_data *vd, const char *opt)
int erroroffset;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
ALLOC_OBJ(m, VSL_RE_MATCH_MAGIC);
AN(m);
if (!strchr(opt, ':')) {
fprintf(stderr, "No : found in -o option %s\n", opt);
......@@ -185,10 +190,13 @@ vsl_m_arg(const struct VSM_data *vd, const char *opt)
*regex = '\0';
regex++;
m->tag = name2tag(o);
if (m->tag == -1) {
ALLOC_OBJ(m, VSL_RE_MATCH_MAGIC);
AN(m);
m->tag = VSL_Name2Tag(o, -1);
if (m->tag < 0) {
fprintf(stderr, "Illegal tag %s specified\n", o);
free(o);
FREE_OBJ(m);
return (-1);
}
/* Get tag, regex */
......@@ -196,6 +204,7 @@ vsl_m_arg(const struct VSM_data *vd, const char *opt)
if (m->re == NULL) {
fprintf(stderr, "Illegal regex: %s\n", error);
free(o);
FREE_OBJ(m);
return (-1);
}
vd->vsl->num_matchers++;
......
......@@ -224,7 +224,7 @@ VSM_Open(struct VSM_data *vd, int diag)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AZ(vd->VSM_head);
if (!vd->n_opt)
VSM_n_Arg(vd, "");
(void)VSM_n_Arg(vd, "");
return (vsm_open(vd, diag));
}
......@@ -331,7 +331,7 @@ VSM_iter0(struct VSM_data *vd)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vd->alloc_seq = vd->VSM_head->alloc_seq;
while (vd->alloc_seq == 0) {
usleep(50000);
(void)usleep(50000);
vd->alloc_seq = vd->VSM_head->alloc_seq;
}
CHECK_OBJ_NOTNULL(&vd->VSM_head->head, VSM_CHUNK_MAGIC);
......@@ -358,7 +358,7 @@ VSM_itern(const struct VSM_data *vd, struct VSM_chunk **pp)
/*--------------------------------------------------------------------*/
unsigned
VSM_Seq(struct VSM_data *vd)
VSM_Seq(const struct VSM_data *vd)
{
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
......
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