From patchwork Sun Oct 16 04:26:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaole He X-Patchwork-Id: 58911 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6C763857C7D for ; Sun, 16 Oct 2022 04:28:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6C763857C7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665894531; bh=j+st+M/FPbGuKoTgmGp1uw8nX6casgSzzkarPww1RPE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=w1kDOaTyUIlcQM2EacUxj6zZ4ZNi4dRMWhLSSKMNuMnhbUQwjw8L1pp8KVBj2+NJo xw2PrPi/XdroLxxE5TQGvr+Lkq5/mcIay+KwLFFHxWuBH7iVf5X9AljuiO4b+mR8pM +HqkF7P086vcO84yWlmBZarFjaWXkBv3BmfhxMNA= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from m15114.mail.126.com (m15114.mail.126.com [220.181.15.114]) by sourceware.org (Postfix) with ESMTP id DD0163858D28 for ; Sun, 16 Oct 2022 04:28:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DD0163858D28 Received: from localhost.localdomain (unknown [117.61.19.197]) by smtp7 (Coremail) with SMTP id DsmowADn73sTiEtjHjJ2DA--.63692S2; Sun, 16 Oct 2022 12:26:59 +0800 (CST) To: libabigail@sourceware.org Subject: [PATCH] abg-ir: add missing else Date: Sun, 16 Oct 2022 04:26:42 +0000 Message-Id: <20221016042642.37944-1-hexiaole1994@126.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CM-TRANSID: DsmowADn73sTiEtjHjJ2DA--.63692S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr47ArW5Jr1kKF15XrWDurg_yoW8uF4Dpa nxGr1IyayxX3yxt3ykJr45WF18Jw4UGr1Syrs0vrn8tFZ5ZF97tay2kFyqvrySqan7ZFnx Xa1aqa90qwnrCw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UkMa5UUUUU= X-Originating-IP: [117.61.19.197] X-CM-SenderInfo: 5kh0xt5rohimizu6ij2wof0z/1tbifBOcBlpD7C-2iQAAsQ X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Xiaole He via Libabigail From: Xiaole He Reply-To: Xiaole He Cc: Xiaole He Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" From: Xiaole He In 'bind_function_type_life_time' function of 'src/abg-ir.cc', the code obtains the member 'const environment*' of 'class function_type', that is, the 'e' variable in below code. And assure the obtained 'environment*' is same as the 'const environment*' of the 'class translation_unit', that is, the'env' variable in below code: /* src/abg-ir.cc begin */ 1 void 2 translation_unit::bind_function_type_life_time(function_type_sptr ftype) 3 { 4 ... 5 const environment* env = get_environment(); 6 ... 7 if (const environment* e = ftype->get_environment()) 8 ABG_ASSERT(env == e); 9 ftype->set_environment(const_cast(env)); 10 11 if (const translation_unit* existing_tu = ftype->get_translation_unit()) 12 ABG_ASSERT(existing_tu == this); 13 else 14 ftype->set_translation_unit(const_cast(this)); 15 ... /* src/abg-ir.cc end */ There was a missing 'else' between the 'line 8' and line 9', as the explicit 'else' at the 'line 13'. Without the 'else' between the 'line 8' and line 9', there will be a redundant assignment at 'line 9' under the condition when the 'env' is equal to 'e'. This patch add the missing 'else' between the 'line 8' and 'line 9'. * src/abg-ir.cc (bind_function_type_life_time): add missing else Signed-off-by: Xiaole He Tested-by: Xiaole He --- src/abg-ir.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 51d1d550..b53df0cd 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -1509,7 +1509,8 @@ translation_unit::bind_function_type_life_time(function_type_sptr ftype) const // translation unit. if (const environment* e = ftype->get_environment()) ABG_ASSERT(env == e); - ftype->set_environment(const_cast(env)); + else + ftype->set_environment(const_cast(env)); if (const translation_unit* existing_tu = ftype->get_translation_unit()) ABG_ASSERT(existing_tu == this);