public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com
Subject: [PATCH 3/7] Better suppression section parsing delegation.
Date: Mon, 17 Aug 2020 10:38:15 +0100	[thread overview]
Message-ID: <20200817093819.172380-4-gprocida@google.com> (raw)
In-Reply-To: <20200817093819.172380-1-gprocida@google.com>

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 <gprocida@google.com>
---
 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",
-- 
2.28.0.220.ged08abb693-goog


  parent reply	other threads:[~2020-08-17  9:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17  9:38 [PATCH 0/7] Suppression parsing - preparatory work Giuliano Procida
2020-08-17  9:38 ` [PATCH 1/7] Add missing newlines to end of test files Giuliano Procida
2020-10-01 14:36   ` Dodji Seketeli
2020-08-17  9:38 ` [PATCH 2/7] Fix two wrongs in test suppression regex Giuliano Procida
2020-10-01 14:42   ` Dodji Seketeli
2020-08-17  9:38 ` Giuliano Procida [this message]
2020-10-01 15:56   ` [PATCH 3/7] Better suppression section parsing delegation Dodji Seketeli
2020-10-02  7:20     ` Giuliano Procida
2020-08-17  9:38 ` [PATCH 4/7] Add read_*_suppression success/failure plumbing Giuliano Procida
2020-08-17  9:38 ` [PATCH 5/7] Add error handling to read_suppressions Giuliano Procida
2020-08-17  9:38 ` [PATCH 6/7] Default construct suppression types Giuliano Procida
2020-08-17  9:38 ` [PATCH 7/7] Refresh getter/setter comments Giuliano Procida
2020-10-02  7:25 ` [PATCH 0/7] Suppression parsing - preparatory work Dodji Seketeli
2020-10-06 20:19   ` Giuliano Procida

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=20200817093819.172380-4-gprocida@google.com \
    --to=gprocida@google.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    /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).