From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com,
maennich@google.com
Subject: [PATCH] abg-reader: eliminate unreachable-code-loop-increment warnings
Date: Wed, 16 Jun 2021 14:30:03 +0100 [thread overview]
Message-ID: <20210616133003.3123930-1-gprocida@google.com> (raw)
This commit tidies up some debris from the change to use
xmlFirstElementChild and xmlNextElementSibling. A couple of while
loops had bodies which would be executed exactly once searching for
the next element with a given tag. These trigger warnings with recent
Clang++, at least.
This commit replaces the loops with their bodies and eliminates
a little redundant conditional logic.
There is no change in behaviour.
* src/abg-reader.cc (read_translation_unit_from_input): In the
branch where the context object holds a non-null node, just
check that it an abi-instr; remove the final null check on
node as it is guaranteed to be non-null.
(read_elf_needed_from_input): Save the context object's node
in node immediately; in the branch where the context object
holds a non-null node, just check that it an elf-needed;
remove the final null check on node as it is guaranteed to be
non-null.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
src/abg-reader.cc | 41 +++++++++--------------------------------
1 file changed, 9 insertions(+), 32 deletions(-)
diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index 0b8149f6..793ca828 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -1576,21 +1576,10 @@ read_translation_unit_from_input(read_context& ctxt)
}
else
{
- node = 0;
- for (xmlNodePtr n = ctxt.get_corpus_node();
- n;
- n = xmlNextElementSibling(n))
- {
- if (!xmlStrEqual(n->name, BAD_CAST("abi-instr")))
- return nil;
- node = n;
- break;
- }
+ if (!xmlStrEqual(node->name, BAD_CAST("abi-instr")))
+ return nil;
}
- if (node == 0)
- return nil;
-
tu = get_or_read_and_add_translation_unit(ctxt, node);
if (ctxt.get_corpus_node())
@@ -1740,9 +1729,8 @@ read_elf_needed_from_input(read_context& ctxt,
if (!reader)
return false;
- xmlNodePtr node = 0;
-
- if (ctxt.get_corpus_node() == 0)
+ xmlNodePtr node = ctxt.get_corpus_node();
+ if (!node)
{
int status = 1;
while (status == 1
@@ -1762,24 +1750,13 @@ read_elf_needed_from_input(read_context& ctxt,
}
else
{
- for (xmlNodePtr n = ctxt.get_corpus_node();
- n;
- n = xmlNextElementSibling(n))
- {
- if (!xmlStrEqual(n->name, BAD_CAST("elf-needed")))
- return false;
- node = n;
- break;
- }
+ if (!xmlStrEqual(node->name, BAD_CAST("elf-needed")))
+ return false;
}
- bool result = false;
- if (node)
- {
- result = build_needed(node, needed);
- node = xmlNextElementSibling(node);
- ctxt.set_corpus_node(node);
- }
+ bool result = build_needed(node, needed);
+ node = xmlNextElementSibling(node);
+ ctxt.set_corpus_node(node);
return result;
}
--
2.32.0.272.g935e593368-goog
next reply other threads:[~2021-06-16 13:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 13:30 Giuliano Procida [this message]
2021-06-16 13:35 ` Matthias Maennich
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=20210616133003.3123930-1-gprocida@google.com \
--to=gprocida@google.com \
--cc=dodji@seketeli.org \
--cc=kernel-team@android.com \
--cc=libabigail@sourceware.org \
--cc=maennich@google.com \
/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).