Commit 0f343772 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

FlexeLint cleanup



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4915 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a0308b8a
-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 '___'
#!/bin/sh
flexelint \
-I/usr/include \
-I. \
-I../../include \
-I../.. \
../flint.lnt \
flint.lnt \
*.c \
../../lib/libvarnishapi/*.c
...@@ -54,10 +54,12 @@ SVNID("$Id$") ...@@ -54,10 +54,12 @@ SVNID("$Id$")
#include "shmlog.h" #include "shmlog.h"
#include "varnishapi.h" #include "varnishapi.h"
#define AC(x) assert((x) != ERR)
struct top { struct top {
uint8_t tag; uint8_t tag;
char *rec_data; char *rec_data;
unsigned clen; int clen;
unsigned hash; unsigned hash;
VTAILQ_ENTRY(top) list; VTAILQ_ENTRY(top) list;
double count; double count;
...@@ -76,7 +78,7 @@ static int f_flag = 0; ...@@ -76,7 +78,7 @@ static int f_flag = 0;
static unsigned maxfieldlen = 0; static unsigned maxfieldlen = 0;
static void static void
accumulate(uint32_t *p) accumulate(uint32_t * const p)
{ {
struct top *tp, *tp2; struct top *tp, *tp2;
const char *q; const char *q;
...@@ -141,12 +143,12 @@ accumulate(uint32_t *p) ...@@ -141,12 +143,12 @@ accumulate(uint32_t *p)
} }
static void static void
update(struct VSL_data *vd) update(const struct VSL_data *vd)
{ {
struct top *tp, *tp2; struct top *tp, *tp2;
int l, len; int l, len;
double t = 0; double t = 0;
static time_t last; static time_t last = 0;
time_t now; time_t now;
now = time(NULL); now = time(NULL);
...@@ -154,19 +156,19 @@ update(struct VSL_data *vd) ...@@ -154,19 +156,19 @@ update(struct VSL_data *vd)
return; return;
last = now; last = now;
erase();
l = 1; l = 1;
mvprintw(0, 0, "%*s", COLS - 1, VSL_Name(vd)); AC(erase());
mvprintw(0, 0, "list length %u", ntop); 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) { VTAILQ_FOREACH_SAFE(tp, &top_head, list, tp2) {
if (++l < LINES) { if (++l < LINES) {
len = tp->clen; len = tp->clen;
if (len > COLS - 20) if (len > COLS - 20)
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, tp->count, maxfieldlen, maxfieldlen,
VSL_tags[tp->tag], VSL_tags[tp->tag],
len, len, tp->rec_data); len, len, tp->rec_data));
t = tp->count; t = tp->count;
} }
tp->count *= .999; tp->count *= .999;
...@@ -177,7 +179,7 @@ update(struct VSL_data *vd) ...@@ -177,7 +179,7 @@ update(struct VSL_data *vd)
ntop--; ntop--;
} }
} }
refresh(); AC(refresh());
} }
static void * static void *
...@@ -193,13 +195,13 @@ accumulate_thread(void *arg) ...@@ -193,13 +195,13 @@ accumulate_thread(void *arg)
if (i < 0) if (i < 0)
break; break;
if (i == 0) { if (i == 0) {
usleep(50000); AZ(usleep(50000));
continue; continue;
} }
pthread_mutex_lock(&mtx); AZ(pthread_mutex_lock(&mtx));
accumulate(p); accumulate(p);
pthread_mutex_unlock(&mtx); AZ(pthread_mutex_unlock(&mtx));
} }
return (arg); return (arg);
} }
...@@ -208,7 +210,6 @@ static void ...@@ -208,7 +210,6 @@ static void
do_curses(struct VSL_data *vd) do_curses(struct VSL_data *vd)
{ {
pthread_t thr; pthread_t thr;
int ch;
int i; int i;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
...@@ -223,46 +224,46 @@ do_curses(struct VSL_data *vd) ...@@ -223,46 +224,46 @@ do_curses(struct VSL_data *vd)
exit(1); exit(1);
} }
initscr(); (void)initscr();
raw(); AC(raw());
noecho(); AC(noecho());
nonl(); AC(nonl());
intrflush(stdscr, FALSE); AC(intrflush(stdscr, FALSE));
curs_set(0); AC(curs_set(0));
erase(); AC(erase());
for (;;) { for (;;) {
pthread_mutex_lock(&mtx); AZ(pthread_mutex_lock(&mtx));
update(vd); update(vd);
pthread_mutex_unlock(&mtx); AZ(pthread_mutex_unlock(&mtx));
timeout(1000); timeout(1000);
switch ((ch = getch())) { switch (getch()) {
case ERR: case ERR:
break; break;
#ifdef KEY_RESIZE #ifdef KEY_RESIZE
case KEY_RESIZE: case KEY_RESIZE:
erase(); AC(erase());
break; break;
#endif #endif
case '\014': /* Ctrl-L */ case '\014': /* Ctrl-L */
case '\024': /* Ctrl-T */ case '\024': /* Ctrl-T */
redrawwin(stdscr); AC(redrawwin(stdscr));
refresh(); AC(refresh());
break; break;
case '\003': /* Ctrl-C */ case '\003': /* Ctrl-C */
raise(SIGINT); AZ(raise(SIGINT));
break; break;
case '\032': /* Ctrl-Z */ case '\032': /* Ctrl-Z */
endwin(); AC(endwin());
raise(SIGTSTP); AZ(raise(SIGTSTP));
break; break;
case '\021': /* Ctrl-Q */ case '\021': /* Ctrl-Q */
case 'Q': case 'Q':
case 'q': case 'q':
endwin(); AC(endwin());
return; return;
default: default:
beep(); AC(beep());
break; break;
} }
} }
...@@ -311,7 +312,7 @@ main(int argc, char **argv) ...@@ -311,7 +312,7 @@ main(int argc, char **argv)
while ((o = getopt(argc, argv, VSL_LOG_ARGS "1fV")) != -1) { while ((o = getopt(argc, argv, VSL_LOG_ARGS "1fV")) != -1) {
switch (o) { switch (o) {
case '1': case '1':
VSL_Log_Arg(vd, 'd', NULL); AN(VSL_Log_Arg(vd, 'd', NULL));
once = 1; once = 1;
break; break;
case 'f': case 'f':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment