From 143f5a3837c4a61b76c6d0c7023bece11f966daa Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 31 Oct 2021 10:58:47 -0400 Subject: [PATCH] gdb: remove unnecessary cmd_list_element::aliases nullptr checks 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 27a80192c48..019aa629876 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.30.2