From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60351 invoked by alias); 12 Oct 2018 04:50:53 -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 60315 invoked by uid 89); 12 Oct 2018 04:50:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Oct 2018 04:50:46 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37AB7C070E11; Fri, 12 Oct 2018 04:50:45 +0000 (UTC) Received: from pinnacle.lan (ovpn-117-243.phx2.redhat.com [10.3.117.243]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0296F16D20; Fri, 12 Oct 2018 04:50:44 +0000 (UTC) Date: Fri, 12 Oct 2018 04:50:00 -0000 From: Kevin Buettner To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 4/8] Avoid shadowing in linux-tdep.c Message-ID: <20181011215043.47e1a6fc@pinnacle.lan> In-Reply-To: <20180923040814.27941-5-tom@tromey.com> References: <20180923040814.27941-1-tom@tromey.com> <20180923040814.27941-5-tom@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00287.txt.bz2 On Sat, 22 Sep 2018 22:08:10 -0600 Tom Tromey wrote: > This is one of the uglier changes to avoid local shadowing. Because > obstack.h uses statement expressions, in some cases a nested obstack > call will result in shadowing. Rather than try to fix obstack.h, this > patch simply works around the one instance of this problem. > > gdb/ChangeLog > 2018-09-22 Tom Tromey > > * linux-tdep.c (linux_make_mappings_corefile_notes): Introduce new > variable "size". > --- > gdb/ChangeLog | 5 +++++ > gdb/linux-tdep.c | 3 ++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c > index 8c76ec316b..352114943f 100644 > --- a/gdb/linux-tdep.c > +++ b/gdb/linux-tdep.c > @@ -1547,8 +1547,9 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, > long_type, mapping_data.file_count); > > /* Copy the filenames to the data obstack. */ > + int size = obstack_object_size (&filename_obstack); > obstack_grow (&data_obstack, obstack_base (&filename_obstack), > - obstack_object_size (&filename_obstack)); > + size); > > note_data = elfcore_write_note (obfd, note_data, note_size, > "CORE", NT_FILE, > -- > 2.17.1 It took me a while to understand this one. IIUC, the problem is that __o in obstack_object_size will shadow __o in obstack_grow. Yeah, this is ugly. But I can't think of a better way to fix it short of mucking about in obstack.h. My only suggestion is to add a brief comment on the matter so that someone else doesn't rewrite this code back to the way it was before this patch. Otherwise, LGTM. Kevin