public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@seketeli.org>
To: Giuliano Procida <gprocida@google.com>
Cc: libabigail@sourceware.org,  kernel-team@android.com
Subject: Re: [PATCH 3/7] Better suppression section parsing delegation.
Date: Thu, 01 Oct 2020 17:56:48 +0200	[thread overview]
Message-ID: <87o8lmos73.fsf@seketeli.org> (raw)
In-Reply-To: <20200817093819.172380-4-gprocida@google.com> (Giuliano Procida's message of "Mon, 17 Aug 2020 10:38:15 +0100")

Giuliano Procida <gprocida@google.com> a écrit:

> 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.

Another way of seeing it is that the section is read either as type,
function, variable or file suppression.

> This can be simplified.

It's not obvious to me that the result you are proposing below is
"simpler" per se.  It seems to me that this just boils down to a matter
of taste.

>
> 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);
> -

As I was saying earlier, the above can be understood as "the section is
read either as a type, function, variable or file suppression."

> +    {
> +      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);
> +    }
>  }

I don't see how this is simpler than the initial code, quite frankly.

>  
>  /// 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;
> -

Actually, I'd prefer making this function return early when wrongly
called on a section that is not a type suppression.  So I think removing
this check actually makes the function less robust.

I have a similar comment for the changes to the other parsing
functions below this one.

[...]

Cheers,

-- 
		Dodji

  reply	other threads:[~2020-10-01 15:56 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 ` [PATCH 3/7] Better suppression section parsing delegation Giuliano Procida
2020-10-01 15:56   ` Dodji Seketeli [this message]
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=87o8lmos73.fsf@seketeli.org \
    --to=dodji@seketeli.org \
    --cc=gprocida@google.com \
    --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).