r3943 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Mar 17 10:34:23 CET 2009


Author: phk
Date: 2009-03-17 10:34:23 +0100 (Tue, 17 Mar 2009)
New Revision: 3943

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_ban.c
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
calm Flexelint down



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-03-16 15:48:16 UTC (rev 3942)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-03-17 09:34:23 UTC (rev 3943)
@@ -463,7 +463,7 @@
 void BAN_Reload(double t0, unsigned flags, const char *ban);
 struct ban *BAN_TailRef(void);
 void BAN_Compile(void);
-struct ban *BAN_RefBan(double t0, struct ban *tail);
+struct ban *BAN_RefBan(double t0, const struct ban *tail);
 void BAN_Deref(struct ban **ban);
 
 /* cache_center.c [CNT] */

Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c	2009-03-16 15:48:16 UTC (rev 3942)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c	2009-03-17 09:34:23 UTC (rev 3943)
@@ -510,7 +510,7 @@
  */
 
 struct ban *
-BAN_RefBan(double t0, struct ban *tail)
+BAN_RefBan(double t0, const struct ban *tail)
 {
 	struct ban *b;
 
@@ -556,6 +556,7 @@
 	VSL_stats->n_purge_add++;
 
 	b2 = BAN_New();
+	AN(b2);
 	b2->test = strdup(ban);
 	AN(b2->test);
 	b2->t0 = t0;
@@ -739,6 +740,7 @@
 	CLI_AddFuncs(PUBLIC_CLI, ban_cmds);
 
 	ban_magic = BAN_New();
+	AN(ban_magic);
 	ban_magic->flags |= BAN_F_GONE;
 	BAN_Insert(ban_magic);
 	fprintf(stderr, "BAN_MAGIC %u\n", ban_magic->refcount);

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-03-16 15:48:16 UTC (rev 3942)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-03-17 09:34:23 UTC (rev 3943)
@@ -161,7 +161,7 @@
  */
 
 static void
-smp_def_sign(struct smp_sc *sc, struct smp_signctx *ctx, uint64_t off, const char *id)
+smp_def_sign(const struct smp_sc *sc, struct smp_signctx *ctx, uint64_t off, const char *id)
 {
 
 	AZ(off & 7);			/* Alignment */
@@ -201,11 +201,11 @@
 		if (memcmp(sign, SIGN_END(ctx), sizeof sign))
 			r = 4;
 	} 
-if (r) {
-	fprintf(stderr, "CHK(%p %p %s) = %d\n",
-	    ctx, ctx->ss, ctx->ss->ident, r);
-	smp_dump_sign(ctx);
-}
+	if (r) {
+		fprintf(stderr, "CHK(%p %p %s) = %d\n",
+		    ctx, ctx->ss, ctx->ss->ident, r);
+		smp_dump_sign(ctx);
+	}
 	return (r);
 }
 
@@ -213,7 +213,7 @@
  * Append data to a signature
  */
 static void
-smp_append_sign(struct smp_signctx *ctx, void *ptr, uint32_t len)
+smp_append_sign(struct smp_signctx *ctx, const void *ptr, uint32_t len)
 {
 	struct SHA256Context cx;
 	unsigned char sign[SHA256_LEN];
@@ -254,13 +254,13 @@
 static void
 smp_sync_sign(const struct smp_signctx *ctx)
 {
+	int i;
 
-	(void)ctx;
-
-#if 0
-	i = msync(sc->ptr + adr,
-	    sizeof(struct smp_sign) + len + SHA256_LEN, MS_SYNC);
-fprintf(stderr, "SyncSign(%jx, %jx) = %d %s\n", adr, len, i, strerror(errno));
+#if 1
+	i = msync(ctx->ss, ctx->ss->length + SHA256_LEN, MS_SYNC);
+	if (i)
+fprintf(stderr, "SyncSign(%p %s) = %d %s\n",
+    ctx->ss, ctx->id, i, strerror(errno));
 #endif
 }
 
@@ -269,7 +269,7 @@
  */
 
 static void
-smp_new_sign(struct smp_sc *sc, struct smp_signctx *ctx, uint64_t off, const char *id)
+smp_new_sign(const struct smp_sc *sc, struct smp_signctx *ctx, uint64_t off, const char *id)
 {
 	smp_def_sign(sc, ctx, off, id);
 	smp_reset_sign(ctx);
@@ -467,7 +467,7 @@
  */
 
 static void
-smp_save_seg(struct smp_sc *sc, struct smp_signctx *ctx)
+smp_save_seg(const struct smp_sc *sc, struct smp_signctx *ctx)
 {
 	struct smp_segptr *ss;
 	struct smp_seg *sg;
@@ -475,6 +475,7 @@
 
 	smp_reset_sign(ctx);
 	ss = SIGN_DATA(ctx);
+	length = 0;
 	VTAILQ_FOREACH(sg, &sc->segments, list) {
 		assert(sg->offset < sc->mediasize);
 		assert(sg->offset + sg->length <= sc->mediasize);
@@ -699,7 +700,7 @@
  */
 
 static void
-smp_load_seg(struct sess *sp, struct smp_sc *sc, struct smp_seg *sg)
+smp_load_seg(struct sess *sp, const struct smp_sc *sc, struct smp_seg *sg)
 {
 	void *ptr;
 	uint64_t length;
@@ -1002,6 +1003,7 @@
 {
 	struct smp_sc *sc;
 	struct smp_seg *sg;
+	const char z[4] = { 0, 0, 0, 0};
 
 fprintf(stderr, "Trim(%p %zu)\n", ss, size);
 	CAST_OBJ_NOTNULL(sc, ss->priv, SMP_SC_MAGIC);
@@ -1012,7 +1014,7 @@
 	size += 1;
 
 	if (ss->ptr + ss->space == sg->next_addr + sc->ptr) {
-		memcpy(sc->ptr + sg->next_addr, "\0\0\0\0", 4);
+		memcpy(sc->ptr + sg->next_addr, z, 4);
 		sg->next_addr -= ss->space - size;
 		ss->space = size;
 		memcpy(sc->ptr + sg->next_addr, "HERE", 4);



More information about the varnish-commit mailing list