From owner-svn-src-all@FreeBSD.ORG Thu Jan 20 13:12:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1FA8106567A; Thu, 20 Jan 2011 13:12:48 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id 5EFA78FC16; Thu, 20 Jan 2011 13:12:48 +0000 (UTC) Received: from c122-106-165-206.carlnfd1.nsw.optusnet.com.au (c122-106-165-206.carlnfd1.nsw.optusnet.com.au [122.106.165.206]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p0KDChMJ028380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Jan 2011 00:12:45 +1100 Date: Fri, 21 Jan 2011 00:12:43 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: David Malone In-Reply-To: <201101201127.aa23364@walton.maths.tcd.ie> Message-ID: <20110120234452.Y12697@besplex.bde.org> References: <201101201127.aa23364@walton.maths.tcd.ie> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Bruce Evans Subject: Re: svn commit: r217589 - head/usr.sbin/syslogd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jan 2011 13:12:48 -0000 On Thu, 20 Jan 2011, David Malone wrote: >> snprintf(buf, 2, "%*s%*s%*s", INT_MAX, "223", INT_MAX, "", 3, "bar"); > > Ah - good example. Would it be worth adding some clarification to > our man page? The paragraphs discussing return values suggest that > *printf() functions can only fail because of output or malloc errors. > I guess two other cases are invalid wide characters and the return > value not being representable as an int? I don't really understand wide characters. C99 doesn't seem to mention EILSEQ for the printf() family. POSIX seems to mention it for the printf() family only as an XSI extension, at least in an old draft. FreeBSD's printf(3) mentions it, but in FreeBSD stdio only fgetwc.c and vswprintf.c set it, and vswprintf() is documented in wprintf(3) which doesn't mention EILSEQ. EILSEQ is mentioned for vfswprintf() in POSIX via a long chain of cross references which eventually reach fwprintf(), where EILSEQ is again an XSI extension. Peharps the meta- sections associate this error with *all* wide character functions in both C and POSIX, but that is even harder to find than the chain. wprintf(3) doesn't have an ERRORS or RETURN VALUES section, but describes the return values (without mentioning errno) in the DESCRIPTION section. printf(3) doesn't have a RETURN VALUES section. But yes, any clarification would be worth it :-). The above format can be used with fprintf() and printf() too. These must fail at the INT_MAX limit, and I think they do in FreeBSD. Files of size >= 2GB have been small enough to create since about the same time as FreeBSD-2 release. Trying to printf() more than 2GB to a terminal has been possible for longer. Even at 300 bps, it only takes 2.26 years to write 2GB. Bruce