r2682 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Sun Jun 15 15:36:51 CEST 2008


Author: phk
Date: 2008-06-15 15:36:50 +0200 (Sun, 15 Jun 2008)
New Revision: 2682

Added:
   trunk/varnish-cache/bin/varnishtest/flint.lnt
   trunk/varnish-cache/bin/varnishtest/flint.sh
Modified:
   trunk/varnish-cache/bin/varnishtest/vtc.c
   trunk/varnish-cache/bin/varnishtest/vtc_client.c
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
   trunk/varnish-cache/bin/varnishtest/vtc_server.c
Log:
FlexeLint varnishtest



Added: trunk/varnish-cache/bin/varnishtest/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishtest/flint.lnt	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/flint.lnt	2008-06-15 13:36:50 UTC (rev 2682)
@@ -0,0 +1,78 @@
+-passes=3
+
++libh mgt_event.h
++libh ../../config.h
+
+-emacro((???),va_arg)   // the va_arg() macro can yield 415, 416, 661, 662
+                        // 796 and 797 (out-of-bounds errors).
+-elib(123)  // size is both a variable and a macro with args
+-emacro(736, isnan)  // isnanf
+
+
+-sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
+
+-sem(vsb_new, @p == malloc(1))
+-sem(vsb_delete, custodial(1))
+-sem(lbv_assert, r_no)
+-sem(lbv_xxxassert, r_no)
+
+-ffc	// No automatic custody
+
+-e763	// Redundant declaration for symbol '...' previously declared
+-e726	// Extraneous comma ignored
+-e728	// Symbol ... not explicitly initialized
+-e716	// while(1) ... 
+-e785	// Too few initializers for aggregate 
+-e786	// String concatenation within initializer
+
+-emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
+-emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
+-emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
+-emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
+-emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean
+
+-esym(534, sprintf)	// Ignoring return value of function
+-esym(534, asprintf)	// Ignoring return value of function
+-esym(534, printf)	// Ignoring return value of function
+-esym(534, fprintf)	// Ignoring return value of function
+-esym(534, memset)	// Ignoring return value of function
+-esym(534, memcpy)	// Ignoring return value of function
+-esym(534, memmove)	// Ignoring return value of function
+-esym(534, strcpy)	// Ignoring return value of function
+-esym(534, vsb_printf)	// Ignoring return value of function
+-esym(534, vsb_cat)	// Ignoring return value of function
+-esym(534, vsb_bcat)	// Ignoring return value of function
+-esym(534, vsb_putc)	// Ignoring return value of function
+-esym(534, strcat)	// Ignoring return value of function
+-esym(534, strcpy)	// Ignoring return value of function
+-esym(534, strlcpy)	// Ignoring return value of function
+
+-emacro(506, isnan)	// constant value boolean
+-emacro(747, isnan)	// significant coersion
+-emacro(506, assert)	// constant value boolean
+-emacro(827, assert)	// loop not reachable
+-emacro(774, assert)	// booelan always true
+
+// cache.h
+-emacro(506, INCOMPL) // Constant value Boolean
+
+// Review all below this line ///////////////////////////////////////////////
+
+-e732   // Loss of sign (arg. no. 2) (int to unsigned
+-e737	// [45]  Loss of sign in promotion from 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
+
+/*
+
+-e767	// Macro redef (system queue.h vs ours )
+
+-e506	// Constant value boolean
+-e818	// Pointer parameter '...' could be declared as pointing to const
+-e774	// Boolean within 'if' always evaluates to False
+-e534	// Ignoring return value of function
+-e557	// unrecog format
+
+*/

Added: trunk/varnish-cache/bin/varnishtest/flint.sh
===================================================================
--- trunk/varnish-cache/bin/varnishtest/flint.sh	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/flint.sh	2008-06-15 13:36:50 UTC (rev 2682)
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+T=/tmp/_$$
+flexelint \
+	-I/usr/include \
+	-I. \
+	-I../../include \
+	-I../.. \
+	-DVARNISH_STATE_DIR=\"foo\" \
+	flint.lnt \
+	*.c > $T 2>&1
+
+for t in Error Warning Info
+do
+	sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T
+done | awk '
+$2 == 830	{ next }
+$2 == 831	{ next }
+	{
+	i=$2"_"$1
+	h[i]++
+	n++
+	}
+END	{
+	printf "%5d %s\n", n, "Total"
+	for (i in h)
+		printf "%5d %s\n", h[i], i
+	}
+' | sort -rn
+
+cat $T


Property changes on: trunk/varnish-cache/bin/varnishtest/flint.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2008-06-15 13:16:18 UTC (rev 2681)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2008-06-15 13:36:50 UTC (rev 2682)
@@ -30,11 +30,12 @@
 #include <string.h>
 #include <ctype.h>
 #include <fcntl.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <err.h>
 
+#include "libvarnish.h"
+
 #include "vtc.h"
 
 #define		MAX_FILESIZE		(1024 * 1024)
@@ -61,7 +62,7 @@
 	if (s <= 0) 
 		err(1, "Cannot read %s", fn);
 	assert(s < sz);		/* XXX: increase MAX_FILESIZE */
-	close (fd);
+	AZ(close (fd));
 	buf[s] = '\0';
 	buf = realloc(buf, s + 1);
 	assert(buf != NULL);
@@ -100,11 +101,16 @@
 			assert(tn < MAX_TOKENS);
 			if (*p == '\n') { /* End on NL */
 				break;
-			} else if (isspace(*p)) { /* Inter-token whitespace */
+			}
+			if (isspace(*p)) { /* Inter-token whitespace */
 				p++;
-			} else if (*p == '\\' && p[1] == '\n') {
+				continue;
+			}
+			if (*p == '\\' && p[1] == '\n') { /* line-cont */
 				p += 2;
-			} else if (*p == '"') { /* quotes */
+				continue;
+			}
+			if (*p == '"') { /* quotes */
 				token_s[tn] = ++p;
 				q = p;
 				for (; *p != '\0'; p++) {
@@ -149,8 +155,10 @@
 		}
 		assert(tn < MAX_TOKENS);
 		token_s[tn] = NULL;
-		for (tn = 0; token_s[tn] != NULL; tn++)
-			*token_e[tn] = '\0';
+		for (tn = 0; token_s[tn] != NULL; tn++) {
+			AN(token_e[tn]);	/*lint !e771 */
+			*token_e[tn] = '\0';	/*lint !e771 */
+		}
 
 		for (cp = cmd; cp->name != NULL; cp++)
 			if (!strcmp(token_s[0], cp->name))

Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_client.c	2008-06-15 13:16:18 UTC (rev 2681)
+++ trunk/varnish-cache/bin/varnishtest/vtc_client.c	2008-06-15 13:36:50 UTC (rev 2682)
@@ -71,7 +71,7 @@
 {
 	struct client *c;
 	int i;
-	int fd;
+	int fd = -1;
 
 	CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC);
 	assert(c->naddr > 0);
@@ -87,7 +87,7 @@
 	printf("#### Client %s connected to %s fd is %d\n",
 	    c->name, c->connect, fd);
 	http_process(c->spec, fd, 1);
-	close(fd);
+	AZ(close(fd));
 	printf("### Client %s ending\n", c->name);
 
 	return (NULL);
@@ -103,6 +103,7 @@
 	struct client *c;
 
 	ALLOC_OBJ(c, CLIENT_MAGIC);
+	AN(c);
 	c->name = name;
 	c->connect = ":8080";
 	VTAILQ_INSERT_TAIL(&clients, c, list);

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-06-15 13:16:18 UTC (rev 2681)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-06-15 13:36:50 UTC (rev 2682)
@@ -308,6 +308,7 @@
 	char *s, *q;
 
 	ALLOC_OBJ(hp, HTTP_MAGIC);
+	AN(hp);
 	hp->fd = sock;
 	hp->client = client;
 	hp->timeout = 1000;
@@ -321,4 +322,5 @@
 	*q = '\0';
 	AN(s);
 	parse_string(s, http_cmds, hp);
+	free(hp);
 }

Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c	2008-06-15 13:16:18 UTC (rev 2681)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c	2008-06-15 13:36:50 UTC (rev 2682)
@@ -91,7 +91,7 @@
 		fd = accept(s->sock, addr, &l);
 		printf("#### Accepted socket %d\n", fd);
 		http_process(s->spec, fd, 0);
-		close(fd);
+		AZ(close(fd));
 	}
 	printf("### Server %s ending\n", s->name);
 
@@ -108,6 +108,7 @@
 	struct server *s;
 
 	ALLOC_OBJ(s, SERVER_MAGIC);
+	AN(s);
 	s->name = name;
 	s->listen = ":9080";
 	s->repeat = 1;




More information about the varnish-commit mailing list