From owner-freebsd-arch Tue Dec 12 6:48:45 2000 From owner-freebsd-arch@FreeBSD.ORG Tue Dec 12 06:48:42 2000 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 8E3CD37B400 for ; Tue, 12 Dec 2000 06:48:41 -0800 (PST) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id PAA61139; Tue, 12 Dec 2000 15:48:32 +0100 (CET) (envelope-from des@ofug.org) Sender: des@ofug.org X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Peter Jeremy Cc: arch@FreeBSD.ORG Subject: Re: Safe string formatting in the kernel References: <20001212141958.P69646@gsmx07.alcatel.com.au> From: Dag-Erling Smorgrav Date: 12 Dec 2000 15:48:32 +0100 In-Reply-To: Peter Jeremy's message of "Tue, 12 Dec 2000 14:19:58 +1100" Message-ID: Lines: 37 User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Peter Jeremy writes: > Overall the purpose of this isn't clear to me. It doesn't appear to > have any real advantages over using the standard string functions. This has been explained elsewhere in this thread both by Poul-Henning and myself. > The main advantage I can see for having a proper set of string > functions would be to support dynamic (growable) strings and sbuf uses a > fixed size buffer. Please read the comments that precede the patch. > The s_flags and s_next fields appear to be unused. What is their > purpose? This is documented in patch itself and in the comments that precede it. > 2 int's (s_dynamic and s_done) to store 2 boolean values seems > excessive. Yes, I'll move those into s_flags. > How about strlcpy()? I suppose sbuf_cat() and sbuf_cpy() could be modified to take an additional size argument (with a magic value, e.g. (size_t)(-1), meaning "the whole shebang") which would allow them to function in a manner similar to strlcat() and strlcpy(). Poul-Henning didn't specify that in his design, and I didn't think of it myself (I implemented his design almost to the letter, except for adding the flags argument to sbuf_new() and adding sbuf_setpos() and sbuf_putc()) DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message