r3677 - in branches/2.0/varnish-cache: bin/varnishd lib/libvcl

tfheen at projects.linpro.no tfheen at projects.linpro.no
Fri Feb 6 15:23:50 CET 2009


Author: tfheen
Date: 2009-02-06 15:23:50 +0100 (Fri, 06 Feb 2009)
New Revision: 3677

Modified:
   branches/2.0/varnish-cache/bin/varnishd/flint.lnt
   branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c
   branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Merge r3486: Flexelint'ing



Modified: branches/2.0/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/flint.lnt	2009-02-06 14:18:21 UTC (rev 3676)
+++ branches/2.0/varnish-cache/bin/varnishd/flint.lnt	2009-02-06 14:23:50 UTC (rev 3677)
@@ -51,6 +51,7 @@
 -emacro(736, isnan)  // isnanf
 -efile(766, ../../config.h)
 -emacro(413, offsetof)	// likely null pointer
+-emacro(527, WRONG)	// unreachable code
 
 -emacro(702, WEXITSTATUS)	// signed shift right 
 

Modified: branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c	2009-02-06 14:18:21 UTC (rev 3676)
+++ branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c	2009-02-06 14:23:50 UTC (rev 3677)
@@ -30,7 +30,7 @@
  * A Crit Bit tree based hash
  */
 
-#define PHK	1
+#undef PHK
 
 #include "config.h"
 
@@ -66,7 +66,8 @@
 static void
 hcb_build_bittbl(void)
 {
-	unsigned x, y;
+	unsigned char x;
+	unsigned y;
 
 	y = 0;
 	for (x = 0; x < 8; x++)
@@ -162,10 +163,11 @@
 static unsigned
 hcb_crit_bit(const struct objhead *oh1, const struct objhead *oh2, struct hcb_y *y)
 {
-	unsigned u, r;
+	unsigned char u, r;
 
 	for (u = 0; u < DIGEST_LEN && oh1->digest[u] == oh2->digest[u]; u++)
 		;
+	assert(u < DIGEST_LEN);
 	r = hcb_bits(oh1->digest[u], oh2->digest[u]);
 	y->ptr = u;
 	y->bitmask = 0x80 >> r;
@@ -260,7 +262,8 @@
 	assert(hcb_is_y(*p));
 	
 	y = NULL;
-	while(hcb_is_y(*p)) {
+	while(1) {
+		assert(hcb_is_y(*p));
 		y = hcb_l_y(*p);
 		if (y->ptr > DIGEST_LEN)
 			s = 0;
@@ -276,12 +279,10 @@
 		r->cmps++;
 		p = &y->leaf[s];
 	}
-abort();
-	*p = y->leaf[1 - s];
 }
 
 /**********************************************************************/
-
+#ifdef PHK
 static void
 dumptree(uintptr_t p, int indent, FILE *fd)
 {
@@ -293,9 +294,8 @@
 		return;
 	if (hcb_is_node(p)) {
 		oh = hcb_l_node(p);
-		fprintf(fd, "%*.*sN %u %u r%d <%02x%02x%02x...> <%s>\n",
-		    indent, indent, "", DIGEST_LEN, indent / 2,
-		    oh->refcnt,
+		fprintf(fd, "%*.*sN %d r%u <%02x%02x%02x...> <%s>\n",
+		    indent, indent, "", indent / 2, oh->refcnt,
 		    oh->digest[0], oh->digest[1], oh->digest[2],
 		    oh->hash);
 		return;
@@ -316,8 +316,9 @@
 	fprintf(fd, "-------------\n");
 	dumptree(root->origo, 0, fd);
 	fprintf(fd, "-------------\n");
-	fflush(fd);
+	(void)fflush(fd);
 }
+#endif
 
 
 /**********************************************************************/
@@ -333,7 +334,7 @@
 	THR_SetName("hcb_cleaner");
 	(void)priv;
 	while (1) {
-		sleep(1);
+		(void)sleep(1);
 		Lck_Lock(&hcb_mtx);
 		VTAILQ_FOREACH_SAFE(oh, &laylow, coollist, oh2) {
 			if (oh->hash != NULL) {
@@ -345,8 +346,9 @@
 				continue;
 			if (++oh->refcnt > COOL_DURATION) {
 				VTAILQ_REMOVE(&laylow, oh, coollist);
-				if (PHK)
-					fprintf(stderr, "OH %p is cold enough\n", oh);
+#ifdef PHK
+				fprintf(stderr, "OH %p is cold enough\n", oh);
+#endif
 				free(oh);
 				VSL_stats->n_objecthead--;
 			}
@@ -387,10 +389,10 @@
 		Lck_Unlock(&hcb_mtx);
 	}
 	Lck_Unlock(&oh->mtx);
-	if (PHK) {
-		fprintf(stderr, "%s %d %d <%s>\n", __func__, __LINE__, r, oh->hash);
-		dump(&hcb_root, stderr);
-	}
+#ifdef PHK
+	fprintf(stderr, "hcb_defef %d %d <%s>\n", __LINE__, r, oh->hash);
+	dump(&hcb_root, stderr);
+#endif
 	return (r);
 }
 
@@ -425,19 +427,19 @@
 	oh =  hcb_insert(&hcb_root, noh, 1);
 	if (oh == noh) {
 		VSL_stats->hcb_insert++;
-		if (PHK) {
-			fprintf(stderr, "%s %d\n", __func__, __LINE__);
-			dump(&hcb_root, stderr);
-		}
+#ifdef PHK
+		fprintf(stderr, "hcb_lookup %d\n", __LINE__);
+		dump(&hcb_root, stderr);
+#endif
 	} else {
 		free(noh->hash);
 		noh->hash = NULL;
 		noh->hashlen = 0;
 		VSL_stats->hcb_lock++;
-		if (PHK) {
-			fprintf(stderr, "%s %d\n", __func__, __LINE__);
-			dump(&hcb_root, stderr);
-		}
+#ifdef PHK
+		fprintf(stderr, "hcb_lookup %d\n", __LINE__);
+		dump(&hcb_root, stderr);
+#endif
 	}
 	Lck_Unlock(&hcb_mtx);
 	return (oh);

Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-02-06 14:18:21 UTC (rev 3676)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-02-06 14:23:50 UTC (rev 3677)
@@ -157,8 +157,8 @@
 
 	/* ../../include/vcl.h */
 
-	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3675 2009-02-06 14");
-	vsb_cat(sb, ":04:08Z tfheen $\n *\n * NB:  This file is machine gen");
+	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3676 2009-02-06 14");
+	vsb_cat(sb, ":18:21Z tfheen $\n *\n * NB:  This file is machine gen");
 	vsb_cat(sb, "erated, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixe");
 	vsb_cat(sb, "d_token.tcl instead\n */\n\nstruct sess;\n");
 	vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n");



More information about the varnish-commit mailing list