From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18901 invoked by alias); 3 Nov 2008 14:51:40 -0000 Received: (qmail 18832 invoked by uid 22791); 3 Nov 2008 14:51:39 -0000 X-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from londo.lunn.ch (HELO londo.lunn.ch) (80.238.139.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 03 Nov 2008 14:51:02 +0000 Received: from lunn by londo.lunn.ch with local (Exim 3.36 #1 (Debian)) id 1Kx0lc-00024o-00; Mon, 03 Nov 2008 15:50:56 +0100 Date: Mon, 03 Nov 2008 14:51:00 -0000 From: Andrew Lunn To: Berend Ozceri Cc: ecos-patches@sourceware.org Subject: Re: _vprintf() return code fix and diag_vsnprintf() addition Message-ID: <20081103145056.GN388@lunn.ch> References: <60567D22-14DE-43B4-8ACF-E62A69C6BBD1@eye.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60567D22-14DE-43B4-8ACF-E62A69C6BBD1@eye.fi> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2008-11/txt/msg00005.txt.bz2 On Mon, Oct 20, 2008 at 07:32:19PM -0700, Berend Ozceri wrote: > This fixes a return value error in _vprintf() (if _sputc() clips the > output due to the maximum output buffer length being reached) Could you explain this a bit more. Which functions are returning the wrong value? The man page for vprintf says this: Upon successful return, these functions return the number of characters printed (not including the trailing '\0' used to end output to strings). The functions snprintf() and vsnprintf() do not write more than size bytes (including the trailing '\0'). If the output was truncated due to this limit then the return value is the number of characters (not including the trailing '\0') which would have been written to the final string if enough space had been available. Thus, a return value of size or more means that the output was truncated. My understanding of the eCos code is that the current _vprintf() function returns the unrestricted number of characters. info->len is the number of characters actually output, which may of been truncated. It seems to me diag_vsprintf(), diag_snprintf() and diag_sprintf() are wrong. These all return info.len when they should return the return value from _vprintf(). Would you agree? Thanks Andrew