From patchwork Mon Aug 17 09:38:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 40274 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 7BA5A385700C; Mon, 17 Aug 2020 09:38:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BA5A385700C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1597657117; bh=EMAM0WQ7uqWd+L545MjBvQsX74pLPytNgTczheFn34s=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=R5qgzYcwXnJ9dmJm7VfGpSFeuR43nLJW1CdxaTouuOxMJGHEaJjQEFefpwFzukssA ZptByoRXkY1Dil35h92W8Yu8fqs866ORu7TRJty+xAhKdnFsytCqsx6thVeXexAqb/ 5tJ7n/OJwjZzyDmwWZJiszzYc/dRGAzXgPSnDA1I= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by sourceware.org (Postfix) with ESMTPS id A13813857023 for ; Mon, 17 Aug 2020 09:38:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A13813857023 Received: by mail-yb1-xb4a.google.com with SMTP id w17so17729520ybl.9 for ; Mon, 17 Aug 2020 02:38:34 -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:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EMAM0WQ7uqWd+L545MjBvQsX74pLPytNgTczheFn34s=; b=UaPobLJ1+gzSDvcdgCdA9H2z87bTD4JxpBiCjObqeG5RaE2u97OewI1S9mfqKpiYRB aIrjdFvKxMJ8vKVi2bPkb1w7KQ14UUrOFKFja1m4t0Hz0FSWABx+VLSwIfZIGKjCwm68 B0Ow1B8bizMW9rFsFqv/aqznVUHg4UQiNGoCSo6P/scKjOt8tKTKg5McnNBBx1vEHfiP Q/JLLKaM8UO8JByVzt9P+ogsddpDDHk/3jtA59vQfhQ+DgodyTGERGtU+SLCPPPsYeeD EHDQ5OcrAarZOx9slVCZmf2Qu0h3PACOFlyCDSVv3y2gturqjXZ9hemFLN+vkjpOACWV 7tcg== X-Gm-Message-State: AOAM533B5ofhdMZjT9pYCCwXshzigk6XkIk9kKIGQrNhZDfc1mxHQo8f fESPsKQXL0CJYPzCrADR7chsSKvutZvkMwn7a/Z4VY+iWeI/W2DDKwkdYpvrL4Gieqdl/Hv3cKj 82PELEOfUNhbOBjJeK8Nsr80R9ILh2vS5yGjWtS4zv67p5xsb07mq34l+ijY4EXVI2r8hKUw= X-Google-Smtp-Source: ABdhPJyvGKUZF5tv85O2JMSa6ouL/goMF1STh8B6d0+576nPnfbqla67EtM3sg8lB5Wh8XEfDGg4wkurY4rIJg== X-Received: by 2002:a5b:904:: with SMTP id a4mr19850508ybq.397.1597657114058; Mon, 17 Aug 2020 02:38:34 -0700 (PDT) Date: Mon, 17 Aug 2020 10:38:15 +0100 In-Reply-To: <20200817093819.172380-1-gprocida@google.com> Message-Id: <20200817093819.172380-4-gprocida@google.com> Mime-Version: 1.0 References: <20200817093819.172380-1-gprocida@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH 3/7] Better suppression section parsing delegation. To: libabigail@sourceware.org X-Spam-Status: No, score=-22.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_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-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" The function read_suppressions hands the same ini config section to each of four parsing functions, until one succeeds. Each of those in turn has an early exit if the name of the section doesn't correspond. This can be simplified. This patch moves the name checking into read_suppressions so that exactly one parsing function is called per section. * src/abg-suppression.cc (read_suppressions): Call appropriate read_foo_suppression function based on section name. (read_type_suppression): Remove section name check. (read_function_suppression): Ditto. (read_variable_suppression): Ditto. (read_file_suppression): Ditto. Signed-off-by: Giuliano Procida --- src/abg-suppression.cc | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index ae7cc95ce..682bb8742 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -372,17 +372,25 @@ static void read_suppressions(const ini::config& config, suppressions_type& suppressions) { - suppression_sptr s; for (ini::config::sections_type::const_iterator i = config.get_sections().begin(); i != config.get_sections().end(); ++i) - if ((s = read_type_suppression(**i)) - || (s = read_function_suppression(**i)) - || (s = read_variable_suppression(**i)) - || (s = read_file_suppression(**i))) - suppressions.push_back(s); - + { + const ini::config::section_sptr& section = *i; + const std::string& name = section->get_name(); + suppression_sptr s; + if (name == "suppress_type") + s = read_type_suppression(*section); + else if (name == "suppress_function") + s = read_function_suppression(*section); + else if (name == "suppress_variable") + s = read_variable_suppression(*section); + else if (name == "suppress_file") + s = read_file_suppression(*section); + if (s) + suppressions.push_back(s); + } } /// Read suppressions specifications from an input stream. @@ -1564,9 +1572,6 @@ read_type_suppression(const ini::config::section& section) { type_suppression_sptr result; - if (section.get_name() != "suppress_type") - return result; - static const char *const sufficient_props[] = { "file_name_regexp", "file_name_not_regexp", @@ -3153,9 +3158,6 @@ read_function_suppression(const ini::config::section& section) { function_suppression_sptr result; - if (section.get_name() != "suppress_function") - return result; - static const char *const sufficient_props[] = { "label", "file_name_regexp", @@ -4033,9 +4035,6 @@ read_variable_suppression(const ini::config::section& section) { variable_suppression_sptr result; - if (section.get_name() != "suppress_variable") - return result; - static const char *const sufficient_props[] = { "label", "file_name_regexp", @@ -4298,9 +4297,6 @@ read_file_suppression(const ini::config::section& section) { file_suppression_sptr result; - if (section.get_name() != "suppress_file") - return result; - static const char *const sufficient_props[] = { "file_name_regexp", "file_name_not_regexp",