On Mon, May 16, 2011 at 9:18 AM, Poul-Henning Kamp <p...@freebsd.org> wrote: > Author: phk > Date: Mon May 16 16:18:40 2011 > New Revision: 221993 > URL: http://svn.freebsd.org/changeset/base/221993 > > Log: > Change the length quantities of sbufs to be ssize_t rather than int.
Why? I don't object at all to changing the API to return ssize_t (though I see no need), but changing the struct breaks the KBI for no perceivable gain. Do we really expect someone to put more than 2GB into something that is a string buffer? Thanks, matthew > Constify a couple of arguments. > > Modified: > head/sys/kern/subr_sbuf.c > head/sys/sys/sbuf.h > > Modified: head/sys/kern/subr_sbuf.c > ============================================================================== > --- head/sys/kern/subr_sbuf.c Mon May 16 15:59:50 2011 (r221992) > +++ head/sys/kern/subr_sbuf.c Mon May 16 16:18:40 2011 (r221993) > @@ -94,7 +94,8 @@ _assert_sbuf_integrity(const char *fun, > KASSERT(s->s_buf != NULL, > ("%s called with uninitialized or corrupt sbuf", fun)); > KASSERT(s->s_len < s->s_size, > - ("wrote past end of sbuf (%d >= %d)", s->s_len, s->s_size)); > + ("wrote past end of sbuf (%jd >= %jd)", > + (intmax_t)s->s_len, (intmax_t)s->s_size)); > } > > static void > @@ -255,16 +256,17 @@ sbuf_clear(struct sbuf *s) > * Effectively truncates the sbuf at the new position. > */ > int > -sbuf_setpos(struct sbuf *s, int pos) > +sbuf_setpos(struct sbuf *s, ssize_t pos) > { > > assert_sbuf_integrity(s); > assert_sbuf_state(s, 0); > > KASSERT(pos >= 0, > - ("attempt to seek to a negative position (%d)", pos)); > + ("attempt to seek to a negative position (%jd)", (intmax_t)pos)); > KASSERT(pos < s->s_size, > - ("attempt to seek past end of sbuf (%d >= %d)", pos, s->s_size)); > + ("attempt to seek past end of sbuf (%jd >= %jd)", > + (intmax_t)pos, (intmax_t)s->s_size)); > > if (pos < 0 || pos > s->s_len) > return (-1); > @@ -640,7 +642,7 @@ sbuf_trim(struct sbuf *s) > * Check if an sbuf has an error. > */ > int > -sbuf_error(struct sbuf *s) > +sbuf_error(const struct sbuf *s) > { > > return (s->s_error); > @@ -691,7 +693,7 @@ sbuf_data(struct sbuf *s) > /* > * Return the length of the sbuf data. > */ > -int > +ssize_t > sbuf_len(struct sbuf *s) > { > > @@ -728,7 +730,7 @@ sbuf_delete(struct sbuf *s) > * Check if an sbuf has been finished. > */ > int > -sbuf_done(struct sbuf *s) > +sbuf_done(const struct sbuf *s) > { > > return (SBUF_ISFINISHED(s)); > > Modified: head/sys/sys/sbuf.h > ============================================================================== > --- head/sys/sys/sbuf.h Mon May 16 15:59:50 2011 (r221992) > +++ head/sys/sys/sbuf.h Mon May 16 16:18:40 2011 (r221993) > @@ -44,8 +44,8 @@ struct sbuf { > sbuf_drain_func *s_drain_func; /* drain function */ > void *s_drain_arg; /* user-supplied drain argument */ > int s_error; /* current error code */ > - int s_size; /* size of storage buffer */ > - int s_len; /* current length of string */ > + ssize_t s_size; /* size of storage buffer */ > + ssize_t s_len; /* current length of string */ > #define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer > (default) */ > #define SBUF_AUTOEXTEND 0x00000001 /* automatically extend > buffer */ > #define SBUF_USRFLAGMSK 0x0000ffff /* mask of flags the user may > specify */ > @@ -63,7 +63,7 @@ struct sbuf *sbuf_new(struct sbuf *, cha > #define sbuf_new_auto() \ > sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND) > void sbuf_clear(struct sbuf *); > -int sbuf_setpos(struct sbuf *, int); > +int sbuf_setpos(struct sbuf *, ssize_t); > int sbuf_bcat(struct sbuf *, const void *, size_t); > int sbuf_bcpy(struct sbuf *, const void *, size_t); > int sbuf_cat(struct sbuf *, const char *); > @@ -75,11 +75,11 @@ int sbuf_vprintf(struct sbuf *, const > int sbuf_putc(struct sbuf *, int); > void sbuf_set_drain(struct sbuf *, sbuf_drain_func *, void *); > int sbuf_trim(struct sbuf *); > -int sbuf_error(struct sbuf *); > +int sbuf_error(const struct sbuf *); > int sbuf_finish(struct sbuf *); > char *sbuf_data(struct sbuf *); > -int sbuf_len(struct sbuf *); > -int sbuf_done(struct sbuf *); > +ssize_t sbuf_len(struct sbuf *); > +int sbuf_done(const struct sbuf *); > void sbuf_delete(struct sbuf *); > > #ifdef _KERNEL > _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"