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

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

parent d4f532d2
......@@ -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);
......
......@@ -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 */
......
......@@ -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");
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
{
......
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