r4915 - trunk/varnish-cache/bin/varnishtop

phk at varnish-cache.org phk at varnish-cache.org
Sun Jun 6 15:39:58 CEST 2010


Author: phk
Date: 2010-06-06 15:39:58 +0200 (Sun, 06 Jun 2010)
New Revision: 4915

Added:
   trunk/varnish-cache/bin/varnishtop/flint.lnt
   trunk/varnish-cache/bin/varnishtop/flint.sh
Modified:
   trunk/varnish-cache/bin/varnishtop/varnishtop.c
Log:
FlexeLint cleanup



Added: trunk/varnish-cache/bin/varnishtop/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishtop/flint.lnt	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtop/flint.lnt	2010-06-06 13:39:58 UTC (rev 4915)
@@ -0,0 +1,21 @@
+
+-e712	// 14      Info    712     Loss of precision (___) (___ to ___)
+-e747	// 16      Info    747     Significant prototype coercion (___) ___ to ___
+
+-e763	// Redundant declaration for symbol '...' previously declared
+-e716	// while(1) ... 
+
+-e457 // unprotected write access 
+-e459 // unprotected access 
+-e458 // unprotected access 
+
+-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
+
+///////////////////////////////////////////////////////////////////////
+// Varnishstat specific
+
+/// -e850 // for loop index variable '___' whose type category is '___' is modified in body of the for loop that began at '___'
+

Added: trunk/varnish-cache/bin/varnishtop/flint.sh
===================================================================
--- trunk/varnish-cache/bin/varnishtop/flint.sh	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtop/flint.sh	2010-06-06 13:39:58 UTC (rev 4915)
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+flexelint \
+	-I/usr/include \
+	-I. \
+	-I../../include \
+	-I../.. \
+	../flint.lnt \
+	flint.lnt \
+	*.c \
+	../../lib/libvarnishapi/*.c


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

Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c
===================================================================
--- trunk/varnish-cache/bin/varnishtop/varnishtop.c	2010-06-06 13:14:02 UTC (rev 4914)
+++ trunk/varnish-cache/bin/varnishtop/varnishtop.c	2010-06-06 13:39:58 UTC (rev 4915)
@@ -54,10 +54,12 @@
 #include "shmlog.h"
 #include "varnishapi.h"
 
+#define AC(x) assert((x) != ERR)
+
 struct top {
 	uint8_t			tag;
 	char			*rec_data;
-	unsigned		clen;
+	int			clen;
 	unsigned		hash;
 	VTAILQ_ENTRY(top)	list;
 	double			count;
@@ -76,7 +78,7 @@
 static unsigned maxfieldlen = 0;
 
 static void
-accumulate(uint32_t *p)
+accumulate(uint32_t * const p)
 {
 	struct top *tp, *tp2;
 	const char *q;
@@ -141,12 +143,12 @@
 }
 
 static void
-update(struct VSL_data *vd)
+update(const struct VSL_data *vd)
 {
 	struct top *tp, *tp2;
 	int l, len;
 	double t = 0;
-	static time_t last;
+	static time_t last = 0;
 	time_t now;
 
 	now = time(NULL);
@@ -154,19 +156,19 @@
 		return;
 	last = now;
 
-	erase();
 	l = 1;
-	mvprintw(0, 0, "%*s", COLS - 1, VSL_Name(vd));
-	mvprintw(0, 0, "list length %u", ntop);
+	AC(erase());
+	AC(mvprintw(0, 0, "%*s", COLS - 1, VSL_Name(vd)));
+	AC(mvprintw(0, 0, "list length %u", ntop));
 	VTAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
 		if (++l < LINES) {
 			len = tp->clen;
 			if (len > COLS - 20)
 				len = COLS - 20;
-			mvprintw(l, 0, "%9.2f %-*.*s %*.*s\n",
+			AC(mvprintw(l, 0, "%9.2f %-*.*s %*.*s\n",
 			    tp->count, maxfieldlen, maxfieldlen,
 			    VSL_tags[tp->tag],
-			    len, len, tp->rec_data);
+			    len, len, tp->rec_data));
 			t = tp->count;
 		}
 		tp->count *= .999;
@@ -177,7 +179,7 @@
 			ntop--;
 		}
 	}
-	refresh();
+	AC(refresh());
 }
 
 static void *
@@ -193,13 +195,13 @@
 		if (i < 0)
 			break;
 		if (i == 0) {
-			usleep(50000);
+			AZ(usleep(50000));
 			continue;
 		}
 
-		pthread_mutex_lock(&mtx);
+		AZ(pthread_mutex_lock(&mtx));
 		accumulate(p);
-		pthread_mutex_unlock(&mtx);
+		AZ(pthread_mutex_unlock(&mtx));
 	}
 	return (arg);
 }
@@ -208,7 +210,6 @@
 do_curses(struct VSL_data *vd)
 {
 	pthread_t thr;
-	int ch;
 	int i;
 
 	for (i = 0; i < 256; i++) {
@@ -223,46 +224,46 @@
 		exit(1);
 	}
 
-	initscr();
-	raw();
-	noecho();
-	nonl();
-	intrflush(stdscr, FALSE);
-	curs_set(0);
-	erase();
+	(void)initscr();
+	AC(raw());
+	AC(noecho());
+	AC(nonl());
+	AC(intrflush(stdscr, FALSE));
+	AC(curs_set(0));
+	AC(erase());
 	for (;;) {
-		pthread_mutex_lock(&mtx);
+		AZ(pthread_mutex_lock(&mtx));
 		update(vd);
-		pthread_mutex_unlock(&mtx);
+		AZ(pthread_mutex_unlock(&mtx));
 
 		timeout(1000);
-		switch ((ch = getch())) {
+		switch (getch()) {
 		case ERR:
 			break;
 #ifdef KEY_RESIZE
 		case KEY_RESIZE:
-			erase();
+			AC(erase());
 			break;
 #endif
 		case '\014': /* Ctrl-L */
 		case '\024': /* Ctrl-T */
-			redrawwin(stdscr);
-			refresh();
+			AC(redrawwin(stdscr));
+			AC(refresh());
 			break;
 		case '\003': /* Ctrl-C */
-			raise(SIGINT);
+			AZ(raise(SIGINT));
 			break;
 		case '\032': /* Ctrl-Z */
-			endwin();
-			raise(SIGTSTP);
+			AC(endwin());
+			AZ(raise(SIGTSTP));
 			break;
 		case '\021': /* Ctrl-Q */
 		case 'Q':
 		case 'q':
-			endwin();
+			AC(endwin());
 			return;
 		default:
-			beep();
+			AC(beep());
 			break;
 		}
 	}
@@ -311,7 +312,7 @@
 	while ((o = getopt(argc, argv, VSL_LOG_ARGS "1fV")) != -1) {
 		switch (o) {
 		case '1':
-			VSL_Log_Arg(vd, 'd', NULL);
+			AN(VSL_Log_Arg(vd, 'd', NULL));
 			once = 1;
 			break;
 		case 'f':




More information about the varnish-commit mailing list