From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4208 invoked by alias); 24 May 2013 04:27:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 4197 invoked by uid 89); 24 May 2013 04:27:44 -0000 X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO,TW_XS autolearn=ham version=3.3.1 Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 24 May 2013 04:27:43 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 00ACB2ED99; Fri, 24 May 2013 00:27:42 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id YFR50ADinXEC; Fri, 24 May 2013 00:27:41 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 430112E985; Fri, 24 May 2013 00:27:41 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 4F446C2861; Fri, 24 May 2013 08:27:34 +0400 (RET) Date: Fri, 24 May 2013 04:27:00 -0000 From: Joel Brobecker To: Sergio Durigan Junior Cc: Svante Signell , gdb-patches@sourceware.org Subject: Re: Small patch to enable build of gdb-7.6 for GNU/Hurd Message-ID: <20130524042734.GG4017@adacore.com> References: <1369326967.8127.33.camel@s1499.it.kth.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-05/txt/msg00905.txt.bz2 On Thu, May 23, 2013 at 11:59:46PM -0300, Sergio Durigan Junior wrote: > Thanks for your patch, Svante. > > On Thursday, May 23 2013, Svante Signell wrote: > > > --- a/gdb/nto-tdep.c 2013-05-23 14:28:24.000000000 +0000 > > +++ b/gdb/nto-tdep.c 2013-05-23 15:01:24.000000000 +0000 > > @@ -147,9 +147,11 @@ nto_find_and_open_solib (char *solib, un > > void > > nto_init_solib_absolute_prefix (void) > > { > > - char buf[PATH_MAX * 2], arch_path[PATH_MAX]; > > + char *buf, *arch_path; > > char *nto_root, *endian; > > const char *arch; > > + int arch_len, len; > > +#define FMT "set solib-absolute-prefix %s" > > > > nto_root = nto_target (); > > if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name, "i386") == 0) > > @@ -172,9 +174,13 @@ nto_init_solib_absolute_prefix (void) > > == BFD_ENDIAN_BIG ? "be" : "le"; > > } > > > > - xsnprintf (arch_path, sizeof (arch_path), "%s/%s%s", nto_root, arch, endian); > > + arch_len = strlen (nto_root) + 1 + strlen (arch) + strlen (endian) + 1; > > + arch_path = alloca (arch_len); > > + xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian); > > > > - xsnprintf (buf, sizeof (buf), "set solib-absolute-prefix %s", arch_path); > > + len = strlen (FMT) - 2 + strlen (arch_path) + 1; > > + buf = alloca (len); > > + xsnprintf (buf, len, FMT, arch_path); > > When I define things in the middle of functions/code, I usually #undef > them just after I finished using, to avoid conflicts with others > #defines. Specially when the #define is called "FMT", which is very > generic IMO. Agreed. And quite honestly, I find this use of a macro in the middle of a function quite ugly and unnecessary, no matter what was done before. My preference mirrors Tom's suggestion, but failing that, I'd rather FMT be a const char * or a const char []. I do not think that this file has a responsible maintainer, so it falls under Global Maintainership... -- Joel