From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3349 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: patch: make the size of errbuf configurable Date: Sun, 19 May 2013 19:22:09 -0400 Message-ID: <20130519232209.GK20323@brightrain.aerifal.cx> References: <5199324A.7020805@eservices.virginia.edu> <20130519210341.GG20323@brightrain.aerifal.cx> <51994949.1060305@eservices.virginia.edu> <20130519220941.GJ20323@brightrain.aerifal.cx> <5199517C.8040403@eservices.virginia.edu> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1369005742 21040 80.91.229.3 (19 May 2013 23:22:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 May 2013 23:22:22 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3353-gllmg-musl=m.gmane.org@lists.openwall.com Mon May 20 01:22:23 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UeCvm-0002hh-FN for gllmg-musl@plane.gmane.org; Mon, 20 May 2013 01:22:22 +0200 Original-Received: (qmail 19807 invoked by uid 550); 19 May 2013 23:22:21 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 19790 invoked from network); 19 May 2013 23:22:21 -0000 Content-Disposition: inline In-Reply-To: <5199517C.8040403@eservices.virginia.edu> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:3349 Archived-At: On Sun, May 19, 2013 at 06:26:04PM -0400, Z. Gilboa wrote: > >>In my understanding, the current approach of having a fixed buffer > >>size is by far the superior one. > >Could you elaborate as to why? Are you concerned about memory usage? > >Code complexity? Or some other reason? > A little bit of both, with complexity being the main factor. As far > as I can tell (from looking at dynlink.c and otherwise), there is > only one case (do_relocs) where both the library name and symbol > name are sent to the buffer. So given the case's rarity and > singularity, I would not introduce "complex" code or memory > allocation into the function. We should also remember that this is > not about how the error is being handled, only about how it is being > presented, meaning that less code is probably better... >From what I can see, complexity can be avoided and maybe even reduced by refactoring the code so that all the places that set an error message call a short simple function that wraps snprintf and allocates a new buffer if needed. The complexity reduction would be if we can eliminate duplicate logic at each call point, which I haven't checked yet. Rich