[master] 0d1e783 And one more sweep over FreeBSD/Varnish sbuf/vsb differences.

Poul-Henning Kamp phk at varnish-cache.org
Mon Apr 4 17:08:26 CEST 2011


commit 0d1e7837a6dbe5a8eb851740dcea0ab1ffadf0d7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Apr 4 15:08:04 2011 +0000

    And one more sweep over FreeBSD/Varnish sbuf/vsb differences.

diff --git a/bin/varnishd/cache_panic.c b/bin/varnishd/cache_panic.c
index 3405d92..715bfb6 100644
--- a/bin/varnishd/cache_panic.c
+++ b/bin/varnishd/cache_panic.c
@@ -71,15 +71,15 @@ pan_ws(const struct ws *ws, int indent)
 	vsb_printf(vsp, "%*sid = \"%s\",\n", indent + 2, "", ws->id);
 	vsb_printf(vsp, "%*s{s,f,r,e} = {%p", indent + 2, "", ws->s);
 	if (ws->f > ws->s)
-		vsb_printf(vsp, ",+%d", ws->f - ws->s);
+		vsb_printf(vsp, ",+%ld", ws->f - ws->s);
 	else
 		vsb_printf(vsp, ",%p", ws->f);
 	if (ws->r > ws->s)
-		vsb_printf(vsp, ",+%d", ws->r - ws->s);
+		vsb_printf(vsp, ",+%ld", ws->r - ws->s);
 	else
 		vsb_printf(vsp, ",%p", ws->r);
 	if (ws->e > ws->s)
-		vsb_printf(vsp, ",+%d", ws->e - ws->s);
+		vsb_printf(vsp, ",+%ld", ws->e - ws->s);
 	else
 		vsb_printf(vsp, ",%p", ws->e);
 	vsb_printf(vsp, "},\n");
@@ -166,7 +166,7 @@ pan_object(const struct object *o)
 	vsb_printf(vsp, "    xid = %u,\n", o->xid);
 	pan_ws(o->ws_o, 4);
 	pan_http("obj", o->http, 4);
-	vsb_printf(vsp, "    len = %u,\n", o->len);
+	vsb_printf(vsp, "    len = %lu,\n", o->len);
 	vsb_printf(vsp, "    store = {\n");
 	VTAILQ_FOREACH(st, &o->store, list)
 		pan_storage(st);
diff --git a/bin/varnishd/cache_vary.c b/bin/varnishd/cache_vary.c
index 69ff52f..3a4fa59 100644
--- a/bin/varnishd/cache_vary.c
+++ b/bin/varnishd/cache_vary.c
@@ -96,7 +96,8 @@ VRY_Create(const struct sess *sp, const struct http *hp)
 
 		/* Build a header-matching string out of it */
 		vsb_clear(sbh);
-		vsb_printf(sbh, "%c%.*s:%c", 1 + (q - p), q - p, p, 0);
+		vsb_printf(sbh, "%c%.*s:%c",
+		    (char)(1 + (q - p)), (int)(q - p), p, 0);
 		AZ(vsb_finish(sbh));
 
 		/* Append to vary matching string */
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 486b656..74cf65f 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -845,7 +845,7 @@ cmd_http_txreq(CMD_ARGS)
 	if (*av != NULL)
 		vtc_log(hp->vl, 0, "Unknown http txreq spec: %s\n", *av);
 	if (body != NULL)
-		vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
+		vsb_printf(hp->vsb, "Content-Length: %lu%s", strlen(body), nl);
 	vsb_cat(hp->vsb, nl);
 	if (body != NULL) {
 		vsb_cat(hp->vsb, body);
@@ -890,7 +890,7 @@ cmd_http_chunked(CMD_ARGS)
 	AN(av[1]);
 	AZ(av[2]);
 	vsb_clear(hp->vsb);
-	vsb_printf(hp->vsb, "%x%s%s%s", strlen(av[1]), nl, av[1], nl);
+	vsb_printf(hp->vsb, "%lx%s%s%s", strlen(av[1]), nl, av[1], nl);
 	http_write(hp, 4, "chunked");
 }
 
diff --git a/include/vsb.h b/include/vsb.h
index 278dcb5..e7b62ef 100644
--- a/include/vsb.h
+++ b/include/vsb.h
@@ -39,12 +39,12 @@
 struct vsb {
 	unsigned	s_magic;
 	char		*s_buf;		/* storage buffer */
+	int		 s_error;	/* current error code */
 	ssize_t		 s_size;	/* size of storage buffer */
 	ssize_t		 s_len;		/* current length of string */
-	int		 s_error;	/* current error code */
 #define	VSB_FIXEDLEN	0x00000000	/* fixed length buffer (default) */
 #define	VSB_AUTOEXTEND	0x00000001	/* automatically extend buffer */
-#define	VSB_USRFLAGMSK 0x0000ffff	/* mask of flags the user may specify */
+#define	VSB_USRFLAGMSK	0x0000ffff	/* mask of flags the user may specify */
 #define	VSB_DYNAMIC	0x00010000	/* s_buf must be freed */
 #define	VSB_FINISHED	0x00020000	/* set by vsb_finish() */
 #define	VSB_DYNSTRUCT	0x00080000	/* vsb must be freed */
@@ -61,23 +61,23 @@ struct vsb	*vsb_new(struct vsb *, char *, int, int);
 #define		 vsb_new_auto()				\
 	vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND)
 void		 vsb_clear(struct vsb *);
-int		 vsb_setpos(struct vsb *, int);
+int		 vsb_setpos(struct vsb *, ssize_t);
 int		 vsb_bcat(struct vsb *, const void *, size_t);
 int		 vsb_bcpy(struct vsb *, const void *, size_t);
 int		 vsb_cat(struct vsb *, const char *);
 int		 vsb_cpy(struct vsb *, const char *);
 int		 vsb_printf(struct vsb *, const char *, ...)
-	/* __printflike(2, 3) */;
+	__printflike(2, 3);
 #ifdef va_start
 int		 vsb_vprintf(struct vsb *, const char *, va_list)
-	/* __printflike(2, 0) */;
+	__printflike(2, 0);
 #endif
 int		 vsb_putc(struct vsb *, char);
 int		 vsb_trim(struct vsb *);
 int		 vsb_error(const struct vsb *);
 int		 vsb_finish(struct vsb *);
 char		*vsb_data(struct vsb *);
-int		 vsb_len(struct vsb *);
+ssize_t		 vsb_len(struct vsb *);
 int		 vsb_done(const struct vsb *);
 void		 vsb_delete(struct vsb *);
 void		 vsb_quote(struct vsb *s, const char *p, int len, int how);
diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index a3bbb94..c0efc27 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -100,7 +100,7 @@ cli_writeres(int fd, const struct cli *cli)
 	assert(cli->result <= 999);	/*lint !e650 const out of range */
 
 	i = snprintf(res, sizeof res,
-	    "%-3d %-8d\n", cli->result, vsb_len(cli->sb));
+	    "%-3d %-8ld\n", cli->result, (long)vsb_len(cli->sb));
 	assert(i == CLI_LINE0_LEN);
 
 	iov[0].iov_base = res;
diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c
index b7ba1e3..bdc40b1 100644
--- a/lib/libvarnish/vsb.c
+++ b/lib/libvarnish/vsb.c
@@ -24,7 +24,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
-__FBSDID("$FreeBSD: head/sys/kern/subr_sbuf.c 181462 2008-08-09 10:26:21Z des $");
+__FBSDID("$FreeBSD: head/sys/kern/subr_vsb.c 212750 2010-09-16 16:13:12Z mdf $
  */
 
 #include "config.h"
@@ -65,8 +65,13 @@ SVNID("$Id$")
 #define	VSB_CLEARFLAG(s, f)	do { (s)->s_flags &= ~(f); } while (0)
 
 #define	VSB_MINEXTENDSIZE	16		/* Should be power of 2. */
+#ifdef PAGE_SIZE
+#define	VSB_MAXEXTENDSIZE	PAGE_SIZE
+#define	VSB_MAXEXTENDINCR	PAGE_SIZE
+#else
 #define	VSB_MAXEXTENDSIZE	4096
 #define	VSB_MAXEXTENDINCR	4096
+#endif
 
 /*
  * Debugging support
@@ -158,8 +163,9 @@ vsb_newbuf(struct vsb *s, char *buf, int length, int flags)
 {
 
 	memset(s, 0, sizeof(*s));
-	s->s_magic = VSB_MAGIC;
 	s->s_flags = flags;
+	s->s_magic = VSB_MAGIC;
+
 	if (buf != NULL) {
 		KASSERT(length > 0,
 		    ("zero or negative length (%d)", length));
@@ -224,7 +230,7 @@ vsb_clear(struct vsb *s)
  * Effectively truncates the vsb at the new position.
  */
 int
-vsb_setpos(struct vsb *s, int pos)
+vsb_setpos(struct vsb *s, ssize_t pos)
 {
 
 	assert_vsb_integrity(s);
@@ -476,7 +482,7 @@ vsb_data(struct vsb *s)
 /*
  * Return the length of the vsb data.
  */
-int
+ssize_t
 vsb_len(struct vsb *s)
 {
 



More information about the varnish-commit mailing list