[master] fb2a191 More FlexeLinting

Poul-Henning Kamp phk at FreeBSD.org
Wed Apr 26 22:39:05 CEST 2017


commit fb2a19197b4aca2bfea0f8a7b921e03d5a977efe
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Apr 26 20:37:58 2017 +0000

    More FlexeLinting

diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt
index c276b5d..3643b1b 100644
--- a/bin/varnishd/flint.lnt
+++ b/bin/varnishd/flint.lnt
@@ -137,7 +137,6 @@
 // Review all below this line ///////////////////////////////////////////////
 
 -e713	// 42 Loss of precision (___) (___ to ___)
--e574	// 48 Signed-unsigned mix with relational
 -e840	// Use of nul character in a string literal (see: vcc_if.c)
 -e663	// Suspicious array to pointer conversion
 -e778   // Constant expression evaluates to 0 in operation '___'
diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt
index d0d1157..509f2fe 100644
--- a/bin/varnishlog/flint.lnt
+++ b/bin/varnishlog/flint.lnt
@@ -7,7 +7,6 @@
 
 -e732   // Loss of sign (arg. no. 2) (int to unsigned
 -e713	// Loss of precision (assignment) (unsigned long long to long long)
--e574	// Signed-unsigned mix with relational
 
 -e788	// enum constant '___' not used within defaulted switch
 -e641	// Converting enum '___' to '___'
diff --git a/bin/varnishncsa/flint.lnt b/bin/varnishncsa/flint.lnt
index 29fa2cd..ac808d4 100644
--- a/bin/varnishncsa/flint.lnt
+++ b/bin/varnishncsa/flint.lnt
@@ -12,7 +12,6 @@
 
 -e767	// Macro redef (system queue.h vs ours )
 
--e574	// Signed-unsigned mix with relational
 -e712	// Loss of precision (assignment) (long long to
 -e747	// Significant prototype coercion (arg. no. 2) long
 -e713	// Loss of precision (assignment) (unsigned long long to long long)
diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt
index 7ae5887..b3d6bb7 100644
--- a/bin/varnishstat/flint.lnt
+++ b/bin/varnishstat/flint.lnt
@@ -12,7 +12,6 @@
 
 -e732   // Loss of sign (arg. no. 2) (int to unsigned
 -e713	// Loss of precision (assignment) (unsigned long long to long long)
--e574	// Signed-unsigned mix with relational
 
 ///////////////////////////////////////////////////////////////////////
 // Varnishstat specific
diff --git a/bin/varnishtop/flint.lnt b/bin/varnishtop/flint.lnt
index b5dc5fa..aa3e9eb 100644
--- a/bin/varnishtop/flint.lnt
+++ b/bin/varnishtop/flint.lnt
@@ -6,7 +6,6 @@
 
 -e732   // Loss of sign (arg. no. 2) (int to unsigned
 -e713	// Loss of precision (assignment) (unsigned long long to long long)
--e574	// Signed-unsigned mix with relational
 
 ///////////////////////////////////////////////////////////////////////
 // Varnishstat specific
diff --git a/flint.lnt b/flint.lnt
index 38a1678..364ede9 100644
--- a/flint.lnt
+++ b/flint.lnt
@@ -27,6 +27,7 @@
 
 ///////////////////////////////////////////////////////////////////////
 // General stylistic issues
+-e574		// Signed-unsigned mix with relational
 -e641		// Converting enum '...' to int
 -e716		// while(1) ...
 -e726		// Extraneous comma ignored
diff --git a/include/miniobj.h b/include/miniobj.h
index 8186b9b..13aa3a6 100644
--- a/include/miniobj.h
+++ b/include/miniobj.h
@@ -75,9 +75,10 @@
 
 #define REPLACE(ptr, val)						\
 	do {								\
+		const char *_vreplace = (val);				\
 		free(ptr);						\
-		if ((val) != NULL) {					\
-			ptr = strdup(val);				\
+		if (_vreplace != NULL) {				\
+			ptr = strdup(_vreplace);			\
 			AN((ptr));					\
 		} else {						\
 			ptr = NULL;					\
diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt
index b134f47..cc5a375 100644
--- a/lib/libvarnish/flint.lnt
+++ b/lib/libvarnish/flint.lnt
@@ -60,7 +60,6 @@
 
 -e732   // Loss of sign (arg. no. 2) (int to unsigned
 -e713	// Loss of precision (assignment) (unsigned long long to long long)
--e574	// Signed-unsigned mix with relational
 -e712	// Loss of precision (assignment) (long long to
 -e747	// Significant prototype coercion (arg. no. 2) long
 
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 8e803ce..207a862 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -172,7 +172,7 @@ vsl_match_IX(struct VSL_data *vsl, const vslf_list *list,
 	const struct vslf *vslf;
 
 	(void)vsl;
-	tag = VSL_TAG(c->rec.ptr);
+	tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr);
 	cdata = VSL_CDATA(c->rec.ptr);
 	len = VSL_LEN(c->rec.ptr);
 
@@ -194,7 +194,7 @@ VSL_Match(struct VSL_data *vsl, const struct VSL_cursor *c)
 	CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
 	if (c == NULL || c->rec.ptr == NULL)
 		return (0);
-	tag = VSL_TAG(c->rec.ptr);
+	tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr);
 	if (tag <= SLT__Bogus || tag >= SLT__Reserved)
 		return (0);
 	if (vsl->c_opt && !VSL_CLIENT(c->rec.ptr))
@@ -245,7 +245,7 @@ VSL_Print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
 		return (0);
 	if (fo == NULL)
 		fo = stdout;
-	tag = VSL_TAG(c->rec.ptr);
+	tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr);
 	vxid = VSL_ID(c->rec.ptr);
 	len = VSL_LEN(c->rec.ptr);
 	type = VSL_CLIENT(c->rec.ptr) ? 'c' : VSL_BACKEND(c->rec.ptr) ?
@@ -283,7 +283,7 @@ VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
 		return (0);
 	if (fo == NULL)
 		fo = stdout;
-	tag = VSL_TAG(c->rec.ptr);
+	tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr);
 	len = VSL_LEN(c->rec.ptr);
 	data = VSL_CDATA(c->rec.ptr);
 
diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c
index 57a416a..a93df10 100644
--- a/lib/libvarnishapi/vsl_dispatch.c
+++ b/lib/libvarnishapi/vsl_dispatch.c
@@ -859,7 +859,7 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx)
 			continue;
 		}
 
-		tag = VSL_TAG(ptr);
+		tag = (enum VSL_tag_e)VSL_TAG(ptr);
 		assert(tag != SLT__Batch);
 
 		switch (tag) {
@@ -1247,14 +1247,14 @@ vslq_next(struct VSLQ *vslq)
 	if (i != 1)
 		return (i);
 
-	tag = VSL_TAG(c->rec.ptr);
+	tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr);
 	if (tag == SLT__Batch) {
 		vxid = VSL_BATCHID(c->rec.ptr);
 		len = VSL_END(c->rec.ptr, VSL_BATCHLEN(c->rec.ptr)) -
 		    c->rec.ptr;
 		if (len == 0)
 			return (i);
-		tag = VSL_TAG(VSL_NEXT(c->rec.ptr));
+		tag = (enum VSL_tag_e)VSL_TAG(VSL_NEXT(c->rec.ptr));
 	} else {
 		vxid = VSL_ID(c->rec.ptr);
 		len = VSL_NEXT(c->rec.ptr) - c->rec.ptr;
diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt
index 6e346b1..6b931e0 100644
--- a/lib/libvcc/flint.lnt
+++ b/lib/libvcc/flint.lnt
@@ -37,7 +37,6 @@
 -e506	// Constant value boolean
 -e774	// Boolean within 'if' always evaluates to False
 -e713	// Loss of precision (assignment) (unsigned long long to long long)
--e574	// Signed-unsigned mix with relational
 -e539	// Did not expect positive indentation
 -e734	// Loss of precision (assignment) (31 bits to 8 bits)
 -e747	// Significant prototype coercion (arg. no. 2) long



More information about the varnish-commit mailing list