r465 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Jul 13 00:52:08 CEST 2006


Author: phk
Date: 2006-07-13 00:52:08 +0200 (Thu, 13 Jul 2006)
New Revision: 465

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/cache_backend.c
   trunk/varnish-cache/bin/varnishd/cache_ban.c
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/bin/varnishd/cache_pass.c
   trunk/varnish-cache/bin/varnishd/cache_pipe.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
   trunk/varnish-cache/bin/varnishd/flint.lnt
   trunk/varnish-cache/bin/varnishd/mgt_child.c
Log:
More flexelinting.

No bugs so far.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-07-12 22:52:08 UTC (rev 465)
@@ -5,9 +5,11 @@
 #include <assert.h>
 #include <pthread.h>
 #include <sys/time.h>
-#include <queue.h>
-#include <event.h>
 
+#include "queue.h"
+#include "event.h"
+#include "sbuf.h"
+
 #include "vcl_returns.h"
 #include "common.h"
 

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -17,8 +17,6 @@
 
 #include <netdb.h>
 
-#include <sbuf.h>
-
 #include "config.h"
 #include "libvarnish.h"
 #include "heritage.h"

Modified: trunk/varnish-cache/bin/varnishd/cache_backend.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_backend.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -26,7 +26,6 @@
 #include <sys/socket.h>
 
 #include <netdb.h>
-#include <sbuf.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>

Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -36,7 +36,7 @@
 	if (i) {
 		char buf[512];
 	
-		regerror(i, &b->regexp, buf, sizeof buf);
+		(void)regerror(i, &b->regexp, buf, sizeof buf);
 		VSL(SLT_Debug, 0, "REGEX: <%s>", buf);
 	}
 	b->gen = ++ban_next;
@@ -71,9 +71,10 @@
 }
 
 void
-cli_func_url_purge(struct cli *cli, char **av, void *priv __unused)
+cli_func_url_purge(struct cli *cli, char **av, void *priv)
 {
 
+	(void)priv;
 	AddBan(av[2]);
 	cli_out(cli, "PURGE %s\n", av[2]);
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -33,10 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <sbuf.h>
 
-#include "libvarnish.h"
-#include "heritage.h"
 #include "shmlog.h"
 #include "vcl.h"
 #include "cache.h"
@@ -521,7 +518,7 @@
 CNT_Session(struct worker *w, struct sess *sp)
 {
 
-	time(&sp->t0);
+	sp->t0 = time(NULL);
 	sp->vcl = VCL_Get();
 
 	for (sp->step = STP_RECV; sp->step != STP_DONE; ) {

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -43,13 +43,15 @@
  */
 
 static void *
-exp_hangman(void *arg __unused)
+exp_hangman(void *arg)
 {
 	struct object *o;
 	time_t t;
 
+	(void)arg;
+
 	while (1) {
-		time (&t); 
+		t = time(NULL); 
 		AZ(pthread_mutex_lock(&exp_mtx));
 		TAILQ_FOREACH(o, &exp_deathrow, deathrow) {
 			if (o->ttl >= t)
@@ -64,7 +66,7 @@
 		}
 		if (o == NULL || o->ttl >= t || o->refcnt > 0) {
 			AZ(pthread_mutex_unlock(&exp_mtx));
-			sleep(1);
+			AZ(sleep(1));
 			continue;
 		}
 		TAILQ_REMOVE(&exp_deathrow, o, deathrow);
@@ -84,19 +86,21 @@
  */
 
 static void *
-exp_prefetch(void *arg __unused)
+exp_prefetch(void *arg)
 {
 	struct object *o;
 	time_t t;
 	struct sess sp;
 
+	(void)arg;
+
 	while (1) {
-		time(&t);
+		t = time(NULL);
 		AZ(pthread_mutex_lock(&exp_mtx));
 		o = binheap_root(exp_heap);
 		if (o == NULL || o->ttl > t + expearly) {
 			AZ(pthread_mutex_unlock(&exp_mtx));
-			sleep(1);
+			AZ(sleep(1));
 			continue;
 		}
 		binheap_delete(exp_heap, 0);
@@ -121,20 +125,23 @@
 /*--------------------------------------------------------------------*/
 
 static int
-object_cmp(void *priv __unused, void *a, void *b)
+object_cmp(void *priv, void *a, void *b)
 {
 	struct object *aa, *bb;
 
+	(void)priv;
+
 	aa = a;
 	bb = b;
 	return (aa->ttl < bb->ttl);
 }
 
 static void
-object_update(void *priv __unused, void *p, unsigned u)
+object_update(void *priv, void *p, unsigned u)
 {
 	struct object *o = p;
 
+	(void)priv;
 	o->heap_idx = u;
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -12,7 +12,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
-#include <sbuf.h>
 
 #include "libvarnish.h"
 #include "shmlog.h"
@@ -29,8 +28,9 @@
 #define CHUNK_PREALLOC		(128 * 1024)
 
 /*--------------------------------------------------------------------*/
+
 static int
-fetch_straight(struct sess *sp, int fd, struct http *hp, char *b)
+fetch_straight(const struct sess *sp, int fd, struct http *hp, char *b)
 {
 	int i;
 	char *e;
@@ -70,7 +70,7 @@
 /* XXX: Cleanup.  It must be possible somehow :-( */
 
 static int
-fetch_chunked(struct sess *sp, int fd, struct http *hp)
+fetch_chunked(const struct sess *sp, int fd, struct http *hp)
 {
 	int i;
 	char *b, *q, *e;
@@ -180,7 +180,7 @@
 #include <errno.h>
 
 static int
-fetch_eof(struct sess *sp, int fd, struct http *hp)
+fetch_eof(const struct sess *sp, int fd, struct http *hp)
 {
 	int i;
 	char *b, *e;
@@ -222,7 +222,7 @@
 		sp->obj->len += i;
 	}
 
-	if (st != NULL && stevedore->trim != NULL)
+	if (stevedore->trim != NULL)
 		stevedore->trim(st, st->len);
 
 	return (1);
@@ -294,7 +294,7 @@
 	http_BuildSbuf(vc->fd, Build_Fetch, w->sb, sp->http);
 	i = write(vc->fd, sbuf_data(w->sb), sbuf_len(w->sb));
 	assert(i == sbuf_len(w->sb));
-	time(&sp->t_req);
+	sp->t_req = time(NULL);
 
 	/* XXX: copy any body ?? */
 
@@ -303,8 +303,8 @@
 	 * XXX: read(2) the header
 	 */
 	http_RecvHead(hp, vc->fd, w->eb, NULL, NULL);
-	event_base_loop(w->eb, 0);
-	time(&sp->t_resp);
+	(void)event_base_loop(w->eb, 0);
+	sp->t_resp = time(NULL);
 	assert(http_DissectResponse(hp, vc->fd) == 0);
 	sp->vbc = vc;
 	sp->bkd_http = hp;

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -9,7 +9,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <sbuf.h>
 
 #include "libvarnish.h"
 #include "shmlog.h"

Modified: trunk/varnish-cache/bin/varnishd/cache_pass.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_pass.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -11,7 +11,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
-#include <sbuf.h>
 
 #include "libvarnish.h"
 #include "shmlog.h"

Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -7,7 +7,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/socket.h>
-#include <sbuf.h>
 
 #include "libvarnish.h"
 #include "shmlog.h"

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -9,7 +9,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <sbuf.h>
 
 #include "libvarnish.h"
 #include "heritage.h"

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -5,10 +5,8 @@
 #include <stdio.h>		/* XXX: for NULL ?? */
 #include <sys/types.h>
 #include <sys/time.h>
-#include <event.h>
 
 #include "libvarnish.h"
-#include "sbuf.h"
 #include "cache.h"
 
 

Modified: trunk/varnish-cache/bin/varnishd/flint.lnt
===================================================================
--- trunk/varnish-cache/bin/varnishd/flint.lnt	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/flint.lnt	2006-07-12 22:52:08 UTC (rev 465)
@@ -6,19 +6,33 @@
 -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 
 
+-emacro(740, TAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
+-emacro((826), TAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
+
+
+-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, sbuf_printf)	// Ignoring return value of function
+-esym(534, sbuf_cat)	// Ignoring return value of function
 
 // cache.h
 -emacro(506, INCOMPL) // Constant value Boolean
 
+// cache_center.c
+-efunc(525, CNT_Session)	// Negative indentation from line
+
 // cache_vcl.c
 -efunc(525, vcl_handlingname)	// Negative indentation from line
 -esym(528, vcl_handlingname)	// Not referenced
 -e641	// Converting enum 'cli_status_e' to int
 
+// storage_file.c
+
 // Review all below this line
 
 // -printf_code( H, void *, unsigned)
@@ -26,7 +40,13 @@
 // -printf_code( jx, long long unsigned)
 // 
 
+-e767	// Macro redef (system queue.h vs ours )
 
+-e574	// Signed-unsigned mix with relational
+-e712	// Loss of precision (assignment) (long long to
+-e747	// Significant prototype coercion (arg. no. 2) long
+-e713	// Loss of precision (assignment) (unsigned long long to long long)
+
 // 
 // 
 -e737	//  Loss of sign in promotion from int to unsigned int
@@ -40,18 +60,13 @@
 // -e506	// Constant value boolean
 // -e527	// Unreachable code at token 'return'
 // -e774	// Boolean within 'if' always evaluates to False
-// -e713	// Loss of precision (assignment) (unsigned long long to long long)
-// -e574	// Signed-unsigned mix with relational
 // 
 // -e525	// Negative indentation from line 90
 // -e539	// Did not expect positive indentation
 // -e725	// Expected positive indentation from line 136
 // -e734	// Loss of precision (assignment) (31 bits to 8 bits)
-// -e747	// Significant prototype coercion (arg. no. 2) long
-// -e712	// Loss of precision (assignment) (long long to
 // 
 // 
-// -e785	// Too few initializers for aggregate 
 // 
 // -e766	//  Header file '../../include/libvarnish.h' not used in module
 // 
@@ -59,6 +74,5 @@
 // 
 // -e788	// enum constant 'HND_Unclass' not used within defaulted switch
 // 
-// -e716	// while(1) ... 
 // 
 // -e786	// String concatenation within initializer

Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c	2006-07-12 22:07:00 UTC (rev 464)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c	2006-07-12 22:52:08 UTC (rev 465)
@@ -16,7 +16,7 @@
 #include <unistd.h>
 
 #include <sys/wait.h>
-#include <queue.h>
+#include "queue.h"
 
 #include <event.h>
 #include <sbuf.h>
@@ -58,10 +58,12 @@
  */
 
 static void
-std_rdcb(struct bufferevent *bev, void *arg __unused)
+std_rdcb(struct bufferevent *bev, void *arg)
 {
 	const char *p;
 
+	(void)arg;
+
 	while (1) {
 		p = evbuffer_readline(bev->input);
 		if (p == NULL)
@@ -74,7 +76,8 @@
 std_wrcb(struct bufferevent *bev, void *arg)
 {
 
-	printf("%s(%p, %p)\n", __func__, (void*)bev, arg);
+	printf("%s(%p, %p)\n",
+	    (const char *)__func__, (void*)bev, arg);
 	exit (2);
 }
 
@@ -82,7 +85,8 @@
 std_excb(struct bufferevent *bev, short what, void *arg)
 {
 
-	printf("%s(%p, %d, %p)\n", __func__, (void*)bev, what, arg);
+	printf("%s(%p, %d, %p)\n",
+	    (const char *)__func__, (void*)bev, what, arg);
 	exit (2);
 }
 
@@ -107,7 +111,7 @@
 		cli_encode_string(child_cli1->output, cr->argv[u]);
 	}
 	evbuffer_add_printf(child_cli1->output, "\n");
-	bufferevent_enable(child_cli1, EV_WRITE);
+	AZ(bufferevent_enable(child_cli1, EV_WRITE));
 }
 
 void
@@ -132,12 +136,14 @@
 }
 
 static void
-cli_rdcb(struct bufferevent *bev, void *arg __unused)
+cli_rdcb(struct bufferevent *bev, void *arg)
 {
 	const char *p;
 	char **av;
 	struct creq *cr;
 
+	(void)arg;
+
 	p = evbuffer_readline(bev->input);
 	if (p == NULL)
 		return;
@@ -167,32 +173,41 @@
 cli_excb(struct bufferevent *bev, short what, void *arg)
 {
 
-	printf("%s(%p, %d, %p)\n", __func__, (void*)bev, what, arg);
+	printf("%s(%p, %d, %p)\n",
+	    (const char *)__func__, (void*)bev, what, arg);
 	exit (2);
 }
 
 /*--------------------------------------------------------------------*/
 
 static void
-child_pingpong_ccb(unsigned u __unused, const char *r __unused, void *priv __unused)
+child_pingpong_ccb(unsigned u, const char *r, void *priv)
 {
+	(void)u;
+	(void)r;
+	(void)priv;
+
 	/* XXX: reset keepalive timer */
 }
 
 
 static void
-child_pingpong(int a __unused, short b __unused, void *c __unused)
+child_pingpong(int a, short b, void *c)
 {
 	time_t t;
 	struct timeval tv;
 
-	time(&t);
+	(void)a;
+	(void)b;
+	(void)c;
+
+	t = time(NULL);
 	mgt_child_request(child_pingpong_ccb, NULL, NULL, "ping %ld", t);
 	if (1) {
 		tv.tv_sec = 10;
 		tv.tv_usec = 0;
-		evtimer_del(&ev_child_pingpong);
-		evtimer_add(&ev_child_pingpong, &tv);
+		AZ(evtimer_del(&ev_child_pingpong));
+		AZ(evtimer_add(&ev_child_pingpong, &tv));
 	}
 }
 
@@ -237,22 +252,22 @@
 	child_std = bufferevent_new(child_fds[0],
 	    std_rdcb, std_wrcb, std_excb, NULL);
 	assert(child_std != NULL);
-	bufferevent_base_set(mgt_eb, child_std);
+	AZ(bufferevent_base_set(mgt_eb, child_std));
 	bufferevent_enable(child_std, EV_READ);
 
 	child_cli0 = bufferevent_new(heritage.fds[0],
 	    cli_rdcb, cli_wrcb, cli_excb, NULL);
 	assert(child_cli0 != NULL);
-	bufferevent_base_set(mgt_eb, child_cli0);
+	AZ(bufferevent_base_set(mgt_eb, child_cli0));
 	bufferevent_enable(child_cli0, EV_READ);
 
 	child_cli1 = bufferevent_new(heritage.fds[3],
 	    cli_rdcb, cli_wrcb, cli_excb, NULL);
 	assert(child_cli1 != NULL);
-	bufferevent_base_set(mgt_eb, child_cli1);
+	AZ(bufferevent_base_set(mgt_eb, child_cli1));
 
 	evtimer_set(&ev_child_pingpong, child_pingpong, NULL);
-	event_base_set(mgt_eb, &ev_child_pingpong);
+	AZ(event_base_set(mgt_eb, &ev_child_pingpong));
 	child_pingpong(0, 0, NULL);
 }
 
@@ -312,12 +327,12 @@
 	bufferevent_free(child_std); /* XXX: is this enough ? */
 	child_std = NULL;
 
-	close(heritage.fds[0]);
-	close(heritage.fds[1]);
-	close(heritage.fds[2]);
-	close(heritage.fds[3]);
-	close(child_fds[0]);
-	close(child_fds[1]);
+	AZ(close(heritage.fds[0]));
+	AZ(close(heritage.fds[1]));
+	AZ(close(heritage.fds[2]));
+	AZ(close(heritage.fds[3]));
+	AZ(close(child_fds[0]));
+	AZ(close(child_fds[1]));
 
 	if (desired == H_START)
 		start_child();




More information about the varnish-commit mailing list