[6.0] 941e00db3 Various Flexelinting

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Aug 16 08:53:01 UTC 2018


commit 941e00db3c120ed5fa0e6635b80a76d8bb9304f1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun May 27 07:08:49 2018 +0000

    Various Flexelinting

diff --git a/bin/varnishhist/flint.lnt b/bin/varnishhist/flint.lnt
index a4289bf2c..1342b8e4e 100644
--- a/bin/varnishhist/flint.lnt
+++ b/bin/varnishhist/flint.lnt
@@ -1,3 +1,4 @@
 -efile(451, "varnishhist_profiles.h")
 -efile(451, "varnishhist_options.h")
 -sem(usage, r_no)
+-sem(profile_error, r_no)
diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 5d32d6a80..6c72a655a 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -63,7 +63,7 @@ static struct VUT *vut;
 static int hist_low;
 static int hist_high;
 static int hist_range;
-static int hist_buckets;
+static unsigned hist_buckets;
 
 static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
 
@@ -143,7 +143,7 @@ update(void)
 	unsigned bm[n], bh[n];
 	unsigned max;
 	unsigned i, j, scale;
-	int k, l;
+	unsigned k, l;
 
 	erase();
 
@@ -161,10 +161,11 @@ update(void)
 		mvprintw(0, 0, "%*s", COLS - 1, ident);
 
 	/* count our flock */
-	for (i = 0; i < n; ++i)
-		bm[i] = bh[i] = 0;
+	memset(bm, 0, sizeof bm);
+	memset(bh, 0, sizeof bh);
 	for (k = 0, max = 1; k < hist_buckets; ++k) {
 		l = k * n / hist_buckets;
+		assert(l < n);
 		bm[l] += bucket_miss[k];
 		bh[l] += bucket_hit[k];
 		if (bm[l] + bh[l] > max)
@@ -413,13 +414,13 @@ do_curses(void *arg)
 			break;
 		case '\032':	/* Ctrl-Z */
 			endwin();
-			raise(SIGTSTP);
+			AZ(raise(SIGTSTP));
 			break;
 		case '\003':	/* Ctrl-C */
 		case '\021':	/* Ctrl-Q */
 		case 'Q':
 		case 'q':
-			raise(SIGINT);
+			AZ(raise(SIGINT));
 			endwin();
 			return (NULL);
 		case '0':
@@ -432,7 +433,7 @@ do_curses(void *arg)
 		case '7':
 		case '8':
 		case '9':
-			delay = 1 << (ch - '0');
+			delay = 1U << (ch - '0');
 			break;
 		case '+':
 			delay /= 2;
@@ -483,7 +484,7 @@ usage(int status)
 	exit(status);
 }
 
-static void
+static void v_noreturn_
 profile_error(const char *s)
 {
 	fprintf(stderr, "-P: '%s' is not a valid"
@@ -506,7 +507,7 @@ main(int argc, char **argv)
 	char *colon;
 	const char *ptag, *profile = "responsetime";
 	pthread_t thr;
-	int fnum = -1;
+	int fnum;
 	struct profile cli_p = {0};
 
 	vut = VUT_InitProg(argc, argv, &vopt_spec);
diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c
index 5c1a5347e..6e786d4f7 100644
--- a/lib/libvarnishapi/vsl_dispatch.c
+++ b/lib/libvarnishapi/vsl_dispatch.c
@@ -582,7 +582,6 @@ vtx_retire(struct VSLQ *vslq, struct vtx **pvtx)
 		vslq->n_cache++;
 	} else {
 		FREE_OBJ(vtx);
-		vtx = NULL;
 	}
 }
 
@@ -693,7 +692,7 @@ vtx_parse_link(const char *str, enum VSL_transaction_e *ptype,
 		return (0);
 
 	/* transaction type */
-	for (et = 0; et < VSL_t__MAX; et++)
+	for (et = VSL_t_unknown; et < VSL_t__MAX; et++)
 		if (!strcmp(type, vsl_t_names[et]))
 			break;
 	if (et >= VSL_t__MAX)
@@ -709,7 +708,7 @@ vtx_parse_link(const char *str, enum VSL_transaction_e *ptype,
 		return (2);
 
 	/* transaction reason */
-	for (er = 0; er < VSL_r__MAX; er++)
+	for (er = VSL_r_unknown; er < VSL_r__MAX; er++)
 		if (!strcmp(reason, vsl_r_names[er]))
 			break;
 	if (er >= VSL_r__MAX)
diff --git a/lib/libvmod_blob/flint.lnt b/lib/libvmod_blob/flint.lnt
index 1b6f0888f..016a8329d 100644
--- a/lib/libvmod_blob/flint.lnt
+++ b/lib/libvmod_blob/flint.lnt
@@ -1 +1,4 @@
 -efile(451, "tbl_*.h")		// No include guard
+
+-e784	// Nul character truncated from string
+


More information about the varnish-commit mailing list