From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=j+st+ M/FPbGuKoTgmGp1uw8nX6casgSzzkarPww1RPE=; b=kSqQHxgj9gNGLNakkRDL1 XUcJ/eoNc/37Enl3RTFaeGy7bfxbVk3jYEYWPbgoMeb5LC5KMVPs3lLwUwirV4Li ReliW4XhX+D1R3Gq1l+hPLBMqBf9mVqDuA+W7ymj327LMUHEQSsnwXMtpvYS21sC KmJHNOHwDV3bQMZZGFfaZE= 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) From: Xiaole He To: libabigail@sourceware.org Cc: Xiaole He 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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); -- 2.27.0