public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 4/6] Simplify add_target_sections_of_objfile
Date: Sat,  3 Oct 2020 13:37:33 -0600	[thread overview]
Message-ID: <20201003193735.2532-5-tom@tromey.com> (raw)
In-Reply-To: <20201003193735.2532-1-tom@tromey.com>

Now that target_section_table uses std::vector,
add_target_sections_of_objfile does not need to loop twice.  This
patch simplifies this code to have just a single loop.  Also, the
passed-in objfile can never be NULL, so this changes this function to
assert that.

2020-10-03  Tom Tromey  <tom@tromey.com>

	* exec.c (add_target_sections_of_objfile): Simplify.
---
 gdb/ChangeLog |  4 ++++
 gdb/exec.c    | 14 +-------------
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/gdb/exec.c b/gdb/exec.c
index d4b9b7bcf65..43385fe978f 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -661,22 +661,10 @@ add_target_sections_of_objfile (struct objfile *objfile)
 {
   struct target_section_table *table = current_target_sections;
   struct obj_section *osect;
-  unsigned count = 0;
 
-  if (objfile == NULL)
-    return;
+  gdb_assert (objfile != nullptr);
 
   /* Compute the number of sections to add.  */
-  ALL_OBJFILE_OSECTIONS (objfile, osect)
-    {
-      if (bfd_section_size (osect->the_bfd_section) == 0)
-	continue;
-      count++;
-    }
-
-  if (count == 0)
-    return;
-
   ALL_OBJFILE_OSECTIONS (objfile, osect)
     {
       if (bfd_section_size (osect->the_bfd_section) == 0)
-- 
2.17.2


  parent reply	other threads:[~2020-10-03 19:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-03 19:37 [PATCH 0/6] Change target section table management Tom Tromey
2020-10-03 19:37 ` [PATCH 1/6] Introduce target-section.h Tom Tromey
2020-10-04  8:29   ` Andrew Burgess
2020-10-09  1:17     ` Tom Tromey
2020-10-03 19:37 ` [PATCH 2/6] Use a std::vector in target_section_table Tom Tromey
2020-10-13 16:41   ` Luis Machado
2020-10-13 20:35     ` Tom Tromey
2020-10-13 22:48       ` Luis Machado
2020-10-14 12:58         ` Tom Tromey
2020-10-14 13:01           ` Luis Machado
2020-10-14 13:18             ` Tom Tromey
2020-10-14 13:23               ` Luis Machado
2020-10-14 14:06                 ` Simon Marchi
2020-10-14  9:09   ` Tom de Vries
2020-11-10 17:38   ` Simon Marchi
2020-10-03 19:37 ` [PATCH 3/6] build_section_table cannot fail Tom Tromey
2020-10-04  8:38   ` Andrew Burgess
2020-10-03 19:37 ` Tom Tromey [this message]
2020-10-04  8:40   ` [PATCH 4/6] Simplify add_target_sections_of_objfile Andrew Burgess
2020-10-03 19:37 ` [PATCH 5/6] Remove clear_section_table Tom Tromey
2020-10-04  8:44   ` Andrew Burgess
2020-10-03 19:37 ` [PATCH 6/6] Change target_section_table to std::vector alias Tom Tromey
2020-10-04  8:46   ` Andrew Burgess
2020-10-13  2:19 ` [PATCH 0/6] Change target section table management Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201003193735.2532-5-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).