[master] 198caa60a flexelinting

Nils Goroll nils.goroll at uplex.de
Wed Mar 11 07:17:06 UTC 2020


commit 198caa60a70234e3a825642674689c435805cefd
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Mar 11 07:52:31 2020 +0100

    flexelinting
    
    fix signed/unsigned comparisons

diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 4f19de3f0..1e5905093 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -142,17 +142,18 @@ update(void)
 	const unsigned n = w * hist_range;
 	unsigned bm[n], bh[n];
 	unsigned max;
-	unsigned i, j, scale;
+	unsigned scale;
+	int i, j;
 	unsigned k, l;
 
 	erase();
 
 	/* Draw horizontal axis */
-	for (i = 0; i < n; ++i)
-		(void)mvaddch(LINES - 2, i, '-');
-	for (k = 0, l = hist_low; k < hist_range; ++k, ++l) {
-		(void)mvaddch(LINES - 2, w * k, '+');
-		mvprintw(LINES - 1, w * k, "|1e%d", l);
+	for (k = 0; k < n; ++k)
+		(void)mvaddch(LINES - 2, k, '-');
+	for (i = 0, j = hist_low; i < hist_range; ++i, ++j) {
+		(void)mvaddch(LINES - 2, w * i, '+');
+		mvprintw(LINES - 1, w * i, "|1e%d", j);
 	}
 
 	if (end_of_file)
@@ -191,11 +192,11 @@ update(void)
 		mvprintw((LINES - 2) - j, 0, "%u_", j * scale);
 
 	/* show them */
-	for (i = 0; i < n; ++i) {
-		for (j = 0; j < bm[i] / scale; ++j)
-			(void)mvaddch((LINES - 3) - j, i, '#');
-		for (; j < (bm[i] + bh[i]) / scale; ++j)
-			(void)mvaddch((LINES - 3) - j, i, '|');
+	for (k = 0; k < n; ++k) {
+		for (l = 0; l < bm[k] / scale; ++l)
+			(void)mvaddch((LINES - 3) - l, k, '#');
+		for (; l < (bm[k] + bh[k]) / scale; ++l)
+			(void)mvaddch((LINES - 3) - l, k, '|');
 	}
 
 	refresh();
@@ -306,7 +307,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
 			i = hist_high * HIST_RES - 1;
 		i -= hist_low * HIST_RES;
 		assert(i >= 0);
-		assert(i < hist_buckets);
+		assert((unsigned)i < hist_buckets);
 
 		AZ(pthread_mutex_lock(&mtx));
 
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 657d4a5fc..084cf4e70 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -710,7 +710,7 @@ parse_format(const char *format)
 			if (!*q)
 				VUT_Error(vut, 1, "Unmatched bracket at: %s",
 				    p - 2);
-			assert(q - p < sizeof buf - 1);
+			assert((unsigned)(q - p) < sizeof buf - 1);
 			strncpy(buf, p, q - p);
 			buf[q - p] = '\0';
 			q++;
@@ -755,7 +755,7 @@ isprefix(const char *prefix, size_t len, const char *b,
     const char *e, const char **next)
 {
 	assert(len > 0);
-	if (e - b < len || strncasecmp(b, prefix, len))
+	if (e < b + len || strncasecmp(b, prefix, len))
 		return (0);
 	b += len;
 	if (next) {
diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index de64c7519..8d8d572e8 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -77,7 +77,7 @@ struct top {
 	double			count;
 };
 
-static int period = 60; /* seconds */
+static unsigned period = 60; /* seconds */
 static int end_of_file = 0;
 static unsigned ntop;
 static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
@@ -184,7 +184,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
 }
 
 static void
-update(int p)
+update(unsigned p)
 {
 	struct top *tp, *tp2;
 	int l, len;


More information about the varnish-commit mailing list