From owner-svn-src-head@FreeBSD.ORG Mon May 16 17:35:21 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 521841065741; Mon, 16 May 2011 17:35:21 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 7A9BC8FC18; Mon, 16 May 2011 17:35:19 +0000 (UTC) Received: by wyf23 with SMTP id 23so4819693wyf.13 for ; Mon, 16 May 2011 10:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=TZ2OM833kNMOtNSBqaIOQCrDwISyetbRkIalRtUJJmE=; b=kqE7SkoihWcT9MpkjmVfsca1+/epK25NoaNIq5N1H9b+pPltild46e/V7Kp8dsCgFD YmTLzXIsjtRibk/4VCAs1vgWorfrTh18pZyu4qST8tyxQbMN1xikGKMAT5LkxcNZSiD+ 0g/1mAlB/l2SUHTRzsV6E7v7MeEB+NxGQNxJQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=LjYfb3EHjMlz4HxV8bb86xwfZ04+jXmaai6csldl4y0+5Rm6A6oqdHXwF7LUW07Xuu 7ckDgIsTfBiaqcwU6daamerP6xjaKarC+yO07c7dqskbSLkxcFrlmGLI5ugIrEs/gCG1 s8WRaEXkBcRoR7jFXYAfGU3lYxnNrGz4Wnug4= MIME-Version: 1.0 Received: by 10.216.65.8 with SMTP id e8mr2529248wed.35.1305567319004; Mon, 16 May 2011 10:35:19 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.216.153.104 with HTTP; Mon, 16 May 2011 10:35:18 -0700 (PDT) In-Reply-To: <201105161618.p4GGIeDd089851@svn.freebsd.org> References: <201105161618.p4GGIeDd089851@svn.freebsd.org> Date: Mon, 16 May 2011 10:35:18 -0700 X-Google-Sender-Auth: swh-YLcOXAxsnKw9yMLqVHf06NM Message-ID: From: mdf@FreeBSD.org To: Poul-Henning Kamp Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r221993 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2011 17:35:21 -0000 On Mon, May 16, 2011 at 9:18 AM, Poul-Henning Kamp wrote: > Author: phk > Date: Mon May 16 16:18:40 2011 > New Revision: 221993 > URL: http://svn.freebsd.org/changeset/base/221993 > > Log: > =A0Change 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 > =A0Constify a couple of arguments. > > Modified: > =A0head/sys/kern/subr_sbuf.c > =A0head/sys/sys/sbuf.h > > Modified: head/sys/kern/subr_sbuf.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/kern/subr_sbuf.c =A0 Mon May 16 15:59:50 2011 =A0 =A0 =A0 = =A0(r221992) > +++ head/sys/kern/subr_sbuf.c =A0 Mon May 16 16:18:40 2011 =A0 =A0 =A0 = =A0(r221993) > @@ -94,7 +94,8 @@ _assert_sbuf_integrity(const char *fun, > =A0 =A0 =A0 =A0KASSERT(s->s_buf !=3D NULL, > =A0 =A0 =A0 =A0 =A0 =A0("%s called with uninitialized or corrupt sbuf", f= un)); > =A0 =A0 =A0 =A0KASSERT(s->s_len < s->s_size, > - =A0 =A0 =A0 =A0 =A0 ("wrote past end of sbuf (%d >=3D %d)", s->s_len, s= ->s_size)); > + =A0 =A0 =A0 =A0 =A0 ("wrote past end of sbuf (%jd >=3D %jd)", > + =A0 =A0 =A0 =A0 =A0 (intmax_t)s->s_len, (intmax_t)s->s_size)); > =A0} > > =A0static void > @@ -255,16 +256,17 @@ sbuf_clear(struct sbuf *s) > =A0* Effectively truncates the sbuf at the new position. > =A0*/ > =A0int > -sbuf_setpos(struct sbuf *s, int pos) > +sbuf_setpos(struct sbuf *s, ssize_t pos) > =A0{ > > =A0 =A0 =A0 =A0assert_sbuf_integrity(s); > =A0 =A0 =A0 =A0assert_sbuf_state(s, 0); > > =A0 =A0 =A0 =A0KASSERT(pos >=3D 0, > - =A0 =A0 =A0 =A0 =A0 ("attempt to seek to a negative position (%d)", pos= )); > + =A0 =A0 =A0 =A0 =A0 ("attempt to seek to a negative position (%jd)", (i= ntmax_t)pos)); > =A0 =A0 =A0 =A0KASSERT(pos < s->s_size, > - =A0 =A0 =A0 =A0 =A0 ("attempt to seek past end of sbuf (%d >=3D %d)", p= os, s->s_size)); > + =A0 =A0 =A0 =A0 =A0 ("attempt to seek past end of sbuf (%jd >=3D %jd)", > + =A0 =A0 =A0 =A0 =A0 (intmax_t)pos, (intmax_t)s->s_size)); > > =A0 =A0 =A0 =A0if (pos < 0 || pos > s->s_len) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (-1); > @@ -640,7 +642,7 @@ sbuf_trim(struct sbuf *s) > =A0* Check if an sbuf has an error. > =A0*/ > =A0int > -sbuf_error(struct sbuf *s) > +sbuf_error(const struct sbuf *s) > =A0{ > > =A0 =A0 =A0 =A0return (s->s_error); > @@ -691,7 +693,7 @@ sbuf_data(struct sbuf *s) > =A0/* > =A0* Return the length of the sbuf data. > =A0*/ > -int > +ssize_t > =A0sbuf_len(struct sbuf *s) > =A0{ > > @@ -728,7 +730,7 @@ sbuf_delete(struct sbuf *s) > =A0* Check if an sbuf has been finished. > =A0*/ > =A0int > -sbuf_done(struct sbuf *s) > +sbuf_done(const struct sbuf *s) > =A0{ > > =A0 =A0 =A0 =A0return (SBUF_ISFINISHED(s)); > > Modified: head/sys/sys/sbuf.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/sys/sbuf.h Mon May 16 15:59:50 2011 =A0 =A0 =A0 =A0(r221992) > +++ head/sys/sys/sbuf.h Mon May 16 16:18:40 2011 =A0 =A0 =A0 =A0(r221993) > @@ -44,8 +44,8 @@ struct sbuf { > =A0 =A0 =A0 =A0sbuf_drain_func *s_drain_func; =A0/* drain function */ > =A0 =A0 =A0 =A0void =A0 =A0 =A0 =A0 =A0 =A0*s_drain_arg; =A0 /* user-supp= lied drain argument */ > =A0 =A0 =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0s_error; =A0 =A0 =A0 /* cur= rent error code */ > - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 =A0s_size; =A0 =A0 =A0 =A0/* si= ze of storage buffer */ > - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 =A0s_len; =A0 =A0 =A0 =A0 /* cu= rrent length of string */ > + =A0 =A0 =A0 ssize_t =A0 =A0 =A0 =A0 =A0s_size; =A0 =A0 =A0 =A0/* size o= f storage buffer */ > + =A0 =A0 =A0 ssize_t =A0 =A0 =A0 =A0 =A0s_len; =A0 =A0 =A0 =A0 /* curren= t length of string */ > =A0#define =A0 =A0 =A0 =A0SBUF_FIXEDLEN =A0 0x00000000 =A0 =A0 =A0/* fixe= d length buffer (default) */ > =A0#define =A0 =A0 =A0 =A0SBUF_AUTOEXTEND 0x00000001 =A0 =A0 =A0/* automa= tically extend buffer */ > =A0#define =A0 =A0 =A0 =A0SBUF_USRFLAGMSK 0x0000ffff =A0 =A0 =A0/* mask o= f flags the user may specify */ > @@ -63,7 +63,7 @@ struct sbuf =A0 *sbuf_new(struct sbuf *, cha > =A0#define =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sbuf_new_auto() =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ > =A0 =A0 =A0 =A0sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND) > =A0void =A0 =A0 =A0 =A0 =A0 =A0sbuf_clear(struct sbuf *); > -int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_setpos(struct sbuf *, int); > +int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_setpos(struct sbuf *, ssize_t); > =A0int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_bcat(struct sbuf *, const void *, siz= e_t); > =A0int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_bcpy(struct sbuf *, const void *, siz= e_t); > =A0int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_cat(struct sbuf *, const char *); > @@ -75,11 +75,11 @@ int =A0 =A0 =A0 =A0 =A0sbuf_vprintf(struct sbuf *, co= nst > =A0int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_putc(struct sbuf *, int); > =A0void =A0 =A0 =A0 =A0 =A0 =A0sbuf_set_drain(struct sbuf *, sbuf_drain_f= unc *, void *); > =A0int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_trim(struct sbuf *); > -int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_error(struct sbuf *); > +int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_error(const struct sbuf *); > =A0int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_finish(struct sbuf *); > =A0char =A0 =A0 =A0 =A0 =A0 *sbuf_data(struct sbuf *); > -int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_len(struct sbuf *); > -int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_done(struct sbuf *); > +ssize_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sbuf_len(struct sbuf *); > +int =A0 =A0 =A0 =A0 =A0 =A0 sbuf_done(const struct sbuf *); > =A0void =A0 =A0 =A0 =A0 =A0 =A0sbuf_delete(struct sbuf *); > > =A0#ifdef _KERNEL >