[4.1] 524b9dc More cleanup
Federico G. Schwindt
fgsch at lodoss.net
Mon Jun 12 04:49:20 CEST 2017
commit 524b9dcb659dd33d51f09496d119a46530f5c170
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Sun Apr 16 14:38:06 2017 +0100
More cleanup
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index fbb5470..905fb24 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -487,7 +487,7 @@ addf_int32(int32_t *i)
}
static void
-addf_time(char type, const char *fmt, const char *str)
+addf_time(char type, const char *fmt)
{
struct format *f;
@@ -499,10 +499,6 @@ addf_time(char type, const char *fmt, const char *str)
f->time_fmt = strdup(fmt);
AN(f->time_fmt);
}
- if (str != NULL) {
- f->string = strdup(str);
- AN(f->string);
- }
VTAILQ_INSERT_TAIL(&CTX.format, f, list);
}
@@ -526,8 +522,7 @@ addf_vcl_log(const char *key, const char *str)
AN(key);
ALLOC_OBJ(w, WATCH_MAGIC);
AN(w);
- w->key = strdup(key);
- AN(w->key);
+ assert(asprintf(&w->key, "%s:", key) > 0);
w->keylen = strlen(w->key);
VTAILQ_INSERT_TAIL(&CTX.watch_vcl_log, w, list);
@@ -727,7 +722,7 @@ parse_format(const char *format)
addf_fragment(&CTX.frag[F_b], "-");
break;
case 'D': /* Float request time */
- addf_time(*p, NULL, NULL);
+ addf_time(*p, NULL);
break;
case 'h': /* Client host name / IP Address */
addf_fragment(&CTX.frag[F_h], "-");
@@ -757,10 +752,10 @@ parse_format(const char *format)
addf_fragment(&CTX.frag[F_s], "-");
break;
case 't': /* strftime */
- addf_time(*p, TIME_FMT, NULL);
+ addf_time(*p, TIME_FMT);
break;
case 'T': /* Int request time */
- addf_time(*p, NULL, NULL);
+ addf_time(*p, NULL);
break;
case 'u': /* Remote user from auth */
addf_auth("-");
@@ -790,7 +785,7 @@ parse_format(const char *format)
addf_hdr(&CTX.watch_resphdr, buf, "-");
break;
case 't':
- addf_time(*q, buf, NULL);
+ addf_time(*q, buf);
break;
case 'x':
parse_x_format(buf);
@@ -903,11 +898,12 @@ static void
process_hdr(const struct watch_head *head, const char *b, const char *e)
{
struct watch *w;
+ const char *p;
VTAILQ_FOREACH(w, head, list) {
- if (e - b < w->keylen || strncasecmp(b, w->key, w->keylen))
+ if (!isprefix(w->key, w->keylen, b, e, &p))
continue;
- frag_line(1, b + w->keylen, e, &w->frag);
+ frag_line(1, p, e, &w->frag);
}
}
@@ -942,6 +938,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
const char *b, *e, *p;
struct watch *w;
int i, skip, be_mark;
+
(void)vsl;
(void)priv;
@@ -1087,15 +1084,10 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
case SLT_VCL_Log:
VTAILQ_FOREACH(w, &CTX.watch_vcl_log, list) {
CHECK_OBJ_NOTNULL(w, WATCH_MAGIC);
- if (e - b <= w->keylen ||
+ if (e - b < w->keylen ||
strncmp(b, w->key, w->keylen))
continue;
p = b + w->keylen;
- if (*p != ':')
- continue;
- p++;
- if (p > e)
- continue;
frag_line(0, p, e, &w->frag);
}
break;
More information about the varnish-commit
mailing list