[4.1] cfa2211 Polish flexelint stuff for vmods

Poul-Henning Kamp phk at FreeBSD.org
Fri Sep 4 15:54:50 CEST 2015


commit cfa22119fa24894976911a99e75c67d9ebaa6eac
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jul 10 06:44:29 2015 +0000

    Polish flexelint stuff for vmods

diff --git a/bin/flint.lnt b/bin/flint.lnt
index 1da0545..ce30d3a 100644
--- a/bin/flint.lnt
+++ b/bin/flint.lnt
@@ -4,27 +4,6 @@
 
 -printf(2, VSB_printf)
 
-
-///////////////////////////////////////////////////////////////////////
-// Weirdness relating to varnish includes etc.
-
--header(../../config.h)
-+libh ../../config.h
--efile(451, ../../config.h)	// No include guard
-
--efile(451, "tbl/*.h")		// No include guard
-
-///////////////////////////////////////////////////////////////////////
-// assert() support, common to libvarnish and libvarnishapi
--sem(VAS_Fail, r_no)
--emacro(506, assert)    // constant value boolean
--emacro(827, assert)    // loop not reachable
--emacro(774, assert)    // booelan always true
--emacro(731, assert)    // booelan arg to eq/non-eq
--emacro(731, xxxassert)	// arg to eq/non-eq
--emacro(527, WRONG)     // unreachable code
-
-
 ///////////////////////////////////////////////////////////////////////
 // miniobj
 
@@ -40,22 +19,6 @@
 -emacro(755, VWMB)		// glob macro not ref
 
 ///////////////////////////////////////////////////////////////////////
-// VSB
-
--esym(759, VSB_*)	// header decl could be moved
--esym(765, VSB_*)	// exten could be made static
--esym(714, VSB_*)	// symb not ref
--sem(VSB_new, @p == (1p ? 1p : malloc(1)))
--sem(VSB_delete, custodial(1))
-
--esym(534, VSB_cat)	// Ignore retval
--esym(534, VSB_bcat)
--esym(534, VSB_putc)
--esym(534, VSB_printf)
--esym(534, VSB_vprintf)
--esym(534, VSB_putc)
-
-///////////////////////////////////////////////////////////////////////
 // System library/POSIX related
 ///////////////////////////////////////////////////////////////////////
 
@@ -65,19 +28,6 @@
 // Fix strchr() semtics, it can only return NULL if arg2 != 0
 -sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
 
--esym(534, printf)	// Ignore retval
--esym(534, fprintf)
--esym(534, sprintf)
-
--esym(534, memset)
--esym(534, memcpy)
--esym(534, memmove)
-
--esym(534, strcat)
--esym(534, strcpy)
--esym(534, strlcpy)
--esym(534, strncpy)
-
 +typename(844)
 -etype(844, struct pthread *)
 -sem(pthread_create, custodial(4))
diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt
index 5181c9e..70ec5b6 100644
--- a/bin/varnishd/flint.lnt
+++ b/bin/varnishd/flint.lnt
@@ -118,7 +118,6 @@
 
 -e455	// thread lock
 -e458	// unprotected read
--e763	// Redundant declaration for symbol '...' previously declared
 -e728	// Symbol ... not explicitly initialized
 -e716	// while(1) ... 
 -e785	// Too few initializers for aggregate 
@@ -149,7 +148,6 @@
 // cache_vcl.c
 -esym(528, vcl_call_method)	// Not referenced
 -esym(528, vcl_handlingname)	// Not referenced
--e641	// Converting enum 'cli_status_e' to int
 
 -e441	//  for clause irregularity: loop variable '___' not found in 2nd for expression
 
diff --git a/flint.lnt b/flint.lnt
index 5366617..9530745 100644
--- a/flint.lnt
+++ b/flint.lnt
@@ -2,8 +2,66 @@
  * Toplevel control file for FlexeLint
  */
 
+///////////////////////////////////////////////////////////////////////
+// build/config related
+
 -efile(451, "tbl/*.h")				// No include guard
--esym(785,VSL_tags)				// Sparse array
+
+-efile(451, ../../config.h)			// No include guard
+-header(../../config.h)
++libh(../../config.h)
+
+///////////////////////////////////////////////////////////////////////
+// General stylistic issues
+-e726		// Extraneous comma ignored
+-e641		// Converting enum '...' to int
+-e763		// // Redundant declaration for symbol '...' previously declared
+
+///////////////////////////////////////////////////////////////////////
+// Ignored return values in system libraries
+
+-esym(534, printf)
+-esym(534, fprintf)
+-esym(534, sprintf)
+
+-esym(534, memset)
+-esym(534, memcpy)
+-esym(534, memmove)
+
+-esym(534, strcat)
+-esym(534, strcpy)
+-esym(534, strlcpy)
+-esym(534, strncpy)
+
+///////////////////////////////////////////////////////////////////////
+// <vas.h>
+
+-sem(VAS_Fail, r_no)		// does not return
+-emacro(506, assert)		// constant value boolean
+-emacro(827, assert)		// loop not reachable
+-emacro(774, assert)		// booelan always true
+-emacro(731, assert)		// booelan arg to eq/non-eq
+-emacro(731, xxxassert)		// arg to eq/non-eq
+-emacro(527, WRONG)		// unreachable code
+
+///////////////////////////////////////////////////////////////////////
+// <vsb.h>
+
+-esym(759, VSB_*)		// header decl could be moved
+-esym(765, VSB_*)		// exten could be made static
+-esym(714, VSB_*)		// symb not ref
+-sem(VSB_new, @p == (1p ? 1p : malloc(1)))
+-sem(VSB_delete, custodial(1))
+
+// ignore retval
+-esym(534, VSB_cat)
+-esym(534, VSB_bcat)
+-esym(534, VSB_putc)
+-esym(534, VSB_printf)
+-esym(534, VSB_vprintf)
+-esym(534, VSB_putc)
+
+
 
 ///////////////////////////////////////////////////////////////////////
 // <vqueue.h>
@@ -25,3 +83,6 @@
 -emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
 -emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
 
+///////////////////////////////////////////////////////////////////////
+
+-esym(785,VSL_tags)				// Sparse array
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index a5eb8bb..ce27df2 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -217,6 +217,7 @@ class Vmod(object):
 
 		vfn = 'Vmod_%s_Func' % self.nam
 
+		fo.write("/*lint -esym(754, %s::*) */\n" % vfn)
 		fo.write("\nstatic const struct %s Vmod_Func =" % vfn)
 		fo.write(self.c_initializer())
 		fo.write("\n")
@@ -235,7 +236,7 @@ class Vmod(object):
 		fo.write("\n")
 
 		nm = "Vmod_" + self.nam + "_Data"
-		fo.write("extern const struct vmod_data " + nm + ";\n\n")
+		fo.write("/*lint -esym(759, %s) */\n" % nm)
 		fo.write("const struct vmod_data " + nm + " = {\n")
 		fo.write("\t.vrt_major = VRT_MAJOR_VERSION,\n");
 		fo.write("\t.vrt_minor = VRT_MINOR_VERSION,\n");
@@ -288,7 +289,8 @@ class Vmod(object):
 		return s
 
 	def c_strspec(self):
-		s = "static const char * const Vmod_Spec[] = {\n"
+		s = "/*lint -save -e786 -e840 */\n"
+		s += "static const char * const Vmod_Spec[] = {\n"
 
 		for o in self.objs:
 			s += o.c_strspec(self.nam) + ",\n\n"
@@ -304,6 +306,7 @@ class Vmod(object):
 
 		s += "\t0\n"
 		s += "};\n"
+		s += "/*lint -restore */\n"
 		return s
 
 	def doc(self, l):
@@ -898,8 +901,9 @@ def runmain(inputvcc, outputname="vcc_if"):
 	write_c_file_warning(fc)
 	write_c_file_warning(fh)
 
-	fh.write('struct vmod_priv;\n')
-	fh.write("\n")
+	fh.write('struct vmod_priv;\n\n')
+
+	fh.write('extern const struct vmod_data Vmod_%s_Data;\n\n' % vx[0].nam)
 
 	vx[0].c_proto(fh)
 
diff --git a/lib/libvmod_debug/flint.sh b/lib/libvmod_debug/flint.sh
new file mode 100755
index 0000000..b4bc3e7
--- /dev/null
+++ b/lib/libvmod_debug/flint.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+flexelint \
+	-u \
+	../../flint.lnt \
+	-I. \
+	-I../.. \
+	-I../../include \
+	-I../../bin/varnishd \
+	*.c
diff --git a/lib/libvmod_std/flint.sh b/lib/libvmod_std/flint.sh
new file mode 100755
index 0000000..b4bc3e7
--- /dev/null
+++ b/lib/libvmod_std/flint.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+flexelint \
+	-u \
+	../../flint.lnt \
+	-I. \
+	-I../.. \
+	-I../../include \
+	-I../../bin/varnishd \
+	*.c



More information about the varnish-commit mailing list