From patchwork Wed Aug 6 19:53:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 2333 Received: (qmail 10869 invoked by alias); 6 Aug 2014 19:53:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10859 invoked by uid 89); 6 Aug 2014 19:53:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg20.ericsson.net Received: from usevmg20.ericsson.net (HELO usevmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 06 Aug 2014 19:53:48 +0000 Received: from EUSAAHC001.ericsson.se (Unknown_Domain [147.117.188.75]) by usevmg20.ericsson.net (Symantec Mail Security) with SMTP id 3B.39.05330.71432E35; Wed, 6 Aug 2014 15:56:39 +0200 (CEST) Received: from [142.133.110.254] (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.75) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 6 Aug 2014 15:53:45 -0400 Message-ID: <53E287C8.6080207@ericsson.com> Date: Wed, 6 Aug 2014 15:53:44 -0400 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Joel Brobecker CC: Subject: Re: [PATCH] Rename variable with confusing name References: <1406930946-28195-1-git-send-email-simon.marchi@ericsson.com> <20140806131735.GB5204@adacore.com> <53E28348.9040607@ericsson.com> <20140806195124.GB4881@adacore.com> In-Reply-To: <20140806195124.GB4881@adacore.com> X-IsSubscribed: yes On 14-08-06 03:51 PM, Joel Brobecker wrote: >> Pushed with modifications to scan_dyntag_auxv as well. > > Thanks! Just to follow our procedures when a patch being pushed > is different from the patch already posted, would you mind posting > the patch you pushed here? Oh sure, I tend to forget things like that. Good thing you remind me. (I hope Thunderbird doesn't mess up with line wrapping.) From b6d7a4bf2932e5ae173dd7fb0213c3b004da8462 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 1 Aug 2014 18:09:06 -0400 Subject: [PATCH] Rename variable with confusing name I saw this gem of not so legible code in solib-svr4.c (scan_dyntag): if (dyn_tag == dyntag) and thought it deserved a small rename. This just renames variables to be a bit more clear for those who read the code. I also constified the parameter because, why not. The same was done in scan_dyntag_auxv as well. Tested only by rebuilding, since the change was done mechanically. gdb/Changelog: 2014-08-01 Simon Marchi * solib-svr4.c (scan_dyntag): Rename dyntag and dyn_tag variables. (scan_dyntag_auxv): Same. --- gdb/ChangeLog | 5 +++++ gdb/solib-svr4.c | 34 +++++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7ce30c8..c667f3e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-08-06 Simon Marchi + + * solib-svr4.c (scan_dyntag): Rename dyntag and dyn_tag variables. + (scan_dyntag_auxv): Same. + 2014-08-06 Yao Qi * amd64-linux-nat.c: Remove duplicated include diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index af9d648..05f29a9 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -614,14 +614,14 @@ find_program_interpreter (void) } -/* Scan for DYNTAG in .dynamic section of ABFD. If DYNTAG is found 1 is - returned and the corresponding PTR is set. */ +/* Scan for DESIRED_DYNTAG in .dynamic section of ABFD. If DESIRED_DYNTAG is + found, 1 is returned and the corresponding PTR is set. */ static int -scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr) +scan_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr) { int arch_size, step, sect_size; - long dyn_tag; + long current_dyntag; CORE_ADDR dyn_ptr, dyn_addr; gdb_byte *bufend, *bufstart, *buf; Elf32_External_Dyn *x_dynp_32; @@ -679,18 +679,18 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr) if (arch_size == 32) { x_dynp_32 = (Elf32_External_Dyn *) buf; - dyn_tag = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_tag); + current_dyntag = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_tag); dyn_ptr = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp_32->d_un.d_ptr); } else { x_dynp_64 = (Elf64_External_Dyn *) buf; - dyn_tag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag); + current_dyntag = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_tag); dyn_ptr = bfd_h_get_64 (abfd, (bfd_byte *) x_dynp_64->d_un.d_ptr); } - if (dyn_tag == DT_NULL) + if (current_dyntag == DT_NULL) return 0; - if (dyn_tag == dyntag) + if (current_dyntag == desired_dyntag) { /* If requested, try to read the runtime value of this .dynamic entry. */ @@ -713,16 +713,16 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr) return 0; } -/* Scan for DYNTAG in .dynamic section of the target's main executable, - found by consulting the OS auxillary vector. If DYNTAG is found 1 is - returned and the corresponding PTR is set. */ +/* Scan for DESIRED_DYNTAG in .dynamic section of the target's main executable, + found by consulting the OS auxillary vector. If DESIRED_DYNTAG is found, 1 + is returned and the corresponding PTR is set. */ static int -scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr) +scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr) { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); int sect_size, arch_size, step; - long dyn_tag; + long current_dyntag; CORE_ADDR dyn_ptr; gdb_byte *bufend, *bufstart, *buf; @@ -742,7 +742,7 @@ scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr) { Elf32_External_Dyn *dynp = (Elf32_External_Dyn *) buf; - dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, + current_dyntag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, 4, byte_order); dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr, 4, byte_order); @@ -751,15 +751,15 @@ scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr) { Elf64_External_Dyn *dynp = (Elf64_External_Dyn *) buf; - dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, + current_dyntag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, 8, byte_order); dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr, 8, byte_order); } - if (dyn_tag == DT_NULL) + if (current_dyntag == DT_NULL) break; - if (dyn_tag == dyntag) + if (current_dyntag == desired_dyntag) { if (ptr) *ptr = dyn_ptr;