public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/5] gdb: remove unnecessary cmd_list_element::aliases nullptr checks
Date: Mon,  1 Nov 2021 11:50:06 -0400	[thread overview]
Message-ID: <20211101155009.457224-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20211101155009.457224-1-simon.marchi@efficios.com>

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove two unnecessary nullptr checks.  If aliases is nullptr, then the
for loops will simply be skipped.

Change-Id: I9132063bb17798391f8d019af305383fa8e0229f
---
 gdb/cli/cli-decode.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 396aefb4b011..de90198dfa71 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1351,16 +1351,11 @@ static void
 fput_aliases_definition_styled (struct cmd_list_element *cmd,
 				struct ui_file *stream)
 {
-  if (cmd->aliases != nullptr)
-    {
-      for (cmd_list_element *iter = cmd->aliases;
-	   iter;
-	   iter = iter->alias_chain)
-	{
-	  if (!iter->default_args.empty ())
-	    fput_alias_definition_styled (iter, stream);
-	}
-    }
+  for (cmd_list_element *iter = cmd->aliases;
+       iter != nullptr;
+       iter = iter->alias_chain)
+    if (!iter->default_args.empty ())
+      fput_alias_definition_styled (iter, stream);
 }
 
 
@@ -1377,15 +1372,14 @@ fput_command_names_styled (struct cmd_list_element *c,
 {
   if (always_fput_c_name ||  c->aliases != nullptr)
     fput_command_name_styled (c, stream);
-  if (c->aliases != nullptr)
+
+  for (cmd_list_element *iter = c->aliases; iter; iter = iter->alias_chain)
     {
-      for (cmd_list_element *iter = c->aliases; iter; iter = iter->alias_chain)
-	{
-	  fputs_filtered (", ", stream);
-	  wrap_here ("   ");
-	  fput_command_name_styled (iter, stream);
-	}
+      fputs_filtered (", ", stream);
+      wrap_here ("   ");
+      fput_command_name_styled (iter, stream);
     }
+
   if (always_fput_c_name ||  c->aliases != nullptr)
     fputs_filtered (postfix, stream);
 }
-- 
2.26.2


  parent reply	other threads:[~2021-11-01 15:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 15:50 [PATCH 0/5] Change some index-cache commands Simon Marchi
2021-11-01 15:50 ` [PATCH 1/5] gdb: pass/return setting setter/getter scalar values by value Simon Marchi
2021-11-04 18:27   ` Tom Tromey
2021-11-04 18:59     ` Simon Marchi
2021-11-04 19:51       ` Simon Marchi
2021-11-01 15:50 ` Simon Marchi [this message]
2021-11-04 18:29   ` [PATCH 2/5] gdb: remove unnecessary cmd_list_element::aliases nullptr checks Tom Tromey
2021-11-04 19:45     ` Simon Marchi
2021-11-01 15:50 ` [PATCH 3/5] gdb: remove command_class enum class_deprecated Simon Marchi
2021-11-04 18:30   ` Tom Tromey
2021-11-04 19:45     ` Simon Marchi
2021-11-01 15:50 ` [PATCH 4/5] gdb: add "info index-cache stats", deprecate "show index-cache stats" Simon Marchi
2021-11-04 18:33   ` Tom Tromey
2021-11-04 19:19     ` Simon Marchi
2021-11-01 15:50 ` [PATCH 5/5] gdb: introduce "set index-cache enabled", deprecate "set index-cache on/off" Simon Marchi
2021-11-04 18:36   ` Tom Tromey
2021-11-04 19:51     ` Simon Marchi

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=20211101155009.457224-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.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).