From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 48E213850428 for ; Wed, 16 Jun 2021 13:35:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 48E213850428 Received: by mail-wr1-x42f.google.com with SMTP id c5so2711891wrq.9 for ; Wed, 16 Jun 2021 06:35:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/UxoG429YuRrWk5S+n2zw8CzNMU+qAFpDfnAEZK05PY=; b=LAqiP4SJAR5Gr+SAPyXuHtzw4jbGACwErNxQDCsZAPyANoX+WqmiJc7JDuEEQKXA2C zgxUNgPNk43T2/OlIPoahoM6qZfIXT7QRVlFbOIAJ4cbVoYZMRPea2dEoLrHe+2MMIyl WX2X57yxnFBjnsUsArukkEhgTXLPk7gbn/DVZcpovtttbuItErcxWr7WpZYVg/PsD/3v ilr7WSNPYkQ720K4IJ7oXV3iRu8yd33kObjhsTssjh3brY9yimgDB3tFlpxs3KdAPPjl 7VtMLIegUujfEQUEpnCe/8xRxCtk+ca5ZnGQoRMORD2Z+FbJllwSFGVGqCTqiiYB20pr DB6Q== X-Gm-Message-State: AOAM531r9yALppvIg6DJGnH0NoyKS/7EgmtcAovKa/5bjp9qNpo3Gv6+ QyFcbagvpr7hSU+5+xlNcWLGYQ== X-Google-Smtp-Source: ABdhPJxEU62lVYlF6ZnZPtFxuSsimBvmYbXKkQ36BUUhj4uaPjkvCUwnjXdezkqiThUaDMyv2KG3fg== X-Received: by 2002:a05:6000:89:: with SMTP id m9mr5345921wrx.8.1623850555886; Wed, 16 Jun 2021 06:35:55 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:dde2:86fa:532c:18b9]) by smtp.gmail.com with ESMTPSA id v132sm5234508wmb.14.2021.06.16.06.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 06:35:55 -0700 (PDT) Date: Wed, 16 Jun 2021 14:35:54 +0100 From: Matthias Maennich To: Giuliano Procida Cc: libabigail@sourceware.org, dodji@seketeli.org, kernel-team@android.com Subject: Re: [PATCH] abg-reader: eliminate unreachable-code-loop-increment warnings Message-ID: References: <20210616133003.3123930-1-gprocida@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210616133003.3123930-1-gprocida@google.com> X-Spam-Status: No, score=-29.9 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2021 13:35:58 -0000 On Wed, Jun 16, 2021 at 02:30:03PM +0100, Giuliano Procida wrote: >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 Reviewed-by: Matthias Maennich Cheers, Matthias >--- > 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 >