Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NXN0L-0006SP-T4 for mharc-grub-devel@gnu.org; Tue, 19 Jan 2010 17:56:57 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXN0J-0006Qn-Ss for grub-devel@gnu.org; Tue, 19 Jan 2010 17:56:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXN0E-0006NC-UY for grub-devel@gnu.org; Tue, 19 Jan 2010 17:56:55 -0500 Received: from [199.232.76.173] (port=47745 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXN0E-0006My-K7 for grub-devel@gnu.org; Tue, 19 Jan 2010 17:56:50 -0500 Received: from smarthost01.mail.zen.net.uk ([212.23.3.140]:35106) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXN0E-0006AM-8y for grub-devel@gnu.org; Tue, 19 Jan 2010 17:56:50 -0500 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1NXN0D-00036i-6N for grub-devel@gnu.org; Tue, 19 Jan 2010 22:56:49 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 3.36 #1 (Debian)) for grub-devel@gnu.org id 1NXN0C-00034P-00; Tue, 19 Jan 2010 22:56:48 +0000 Date: Tue, 19 Jan 2010 22:56:48 +0000 From: Colin Watson To: The development of GNU GRUB Message-ID: <20100119225648.GH5847@riva.ucam.org> References: <4B39CC24.9060607@gmail.com> <20100101093222.GU5847@riva.ucam.org> <20100101115256.GG3692@thorin> <4B52FC6F.5060100@gmail.com> <20100119222914.GB8599@thorin> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20100119222914.GB8599@thorin> User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-Smarthost01-IP: [82.69.40.219] X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: [PATCH] switch from sprintf to asprintf and snprintf X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2010 22:56:56 -0000 On Tue, Jan 19, 2010 at 11:29:14PM +0100, Robert Millan wrote: > On Sun, Jan 17, 2010 at 01:02:55PM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > > Robert Millan wrote: > > > On Fri, Jan 01, 2010 at 09:32:24AM +0000, Colin Watson wrote: > > >> On Tue, Dec 29, 2009 at 10:30:12AM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > > >>> +char *EXPORT_FUNC(grub_asprintf) (const char *fmt, ...) > > >>> + __attribute__ ((format (printf, 1, 2))); > > >> > > >> It's very confusing that you've made grub_asprintf have a dramatically > > >> different interface from asprintf. Perhaps you could call this > > >> grub_xasprintf instead? > > > > > > Is it feasible to implement the same interface as asprintf instead? > > > > it's feasible but the only advantage it gives is the return value nobody > > uses anyway > > What about consistency with what programmers expect? > > If you don't want the return value, you can just discard it. asprintf is not really an advantageous interface to emulate. It requires tedious manual error handling and hardly anyone gets it right (GRUB didn't get it right across the board, before I converted it to xasprintf!), not to mention that error_code = function (&string, ...) is unpleasant to start with. xasprintf is a much nicer interface; simply returning the string is what most programmers *actually* expect unless they've already bent their brains around asprintf. The only variance from xasprintf seems to be what the error behaviour ought to be. -- Colin Watson [cjwatson@ubuntu.com]