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,
	 maennich@google.com
Subject: [PATCH v3 06/21] diff suppression: Fix handling of change kinds.
Date: Fri, 24 Apr 2020 10:21:17 +0100	[thread overview]
Message-ID: <20200424092132.150547-7-gprocida@google.com> (raw)
In-Reply-To: <20200424092132.150547-1-gprocida@google.com>

When parsing suppression specifications, libabigail attempts to detect
and ignore suppressions that are empty and so would match everything
in their category by default.

Unfortunately, with the way the parser currently works, these checks
have to be against an exhaustive list of fields that matter, rather
than by listing the fields that don't (like label). They are fragile
in the face of changes that add new fields.

Two of the short-cut checks are in fact buggy, missing out the
change_kind field. One of the checks also risks a null pointer
dereference as it doesn't actually trigger a return from the function.

This patch eliminates (rather than fixes up) this short-cutting on the
grounds that it is a maintenance burden and inconsistent behaviour.
Users should be able to do this:

[suppress_variable]
  label = Suppress all changes to variables

We could reinstate the logic when the code has global knowledge of
which fields are present and which have no suppression (restriction)
semantics, or perhaps just emit a warning message to the user if they
have supplied a completely empty (no label even) specification.

The patch also corrects 4 affected test cases to reflect that
suppression is actually happening (according to change_kind).

	* src/abg-suppression.cc (read_type_suppression): Remove
	short-circuiting of useless suppressions.
	(read_function_suppression): Ditto.
	(read_variable_suppression: Ditto.
	(read_file_suppression): Ditto.
	tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt:
	Fix test - something is actually suppressed.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt:
	Ditto.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt:
	Ditto.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt:
	Ditto.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-suppression.cc                        | 91 +++++--------------
 .../test15-suppr-added-fn-report-5.txt        |  6 +-
 .../test16-suppr-removed-fn-report-5.txt      | 15 +--
 .../test17-suppr-added-var-report-5.txt       | 15 +--
 .../test18-suppr-removed-var-report-5.txt     | 15 +--
 5 files changed, 26 insertions(+), 116 deletions(-)

diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc
index 2fbbd61b..831a61ef 100644
--- a/src/abg-suppression.cc
+++ b/src/abg-suppression.cc
@@ -1840,19 +1840,6 @@ read_type_suppression(const ini::config::section& section)
 	changed_enumerator_names.push_back(p->get_value()->as_string());
     }
 
-  if (file_name_regex_str.empty()
-      && file_name_not_regex_str.empty()
-      && soname_regex_str.empty()
-      && soname_not_regex_str.empty()
-      && (!name_regex_prop || name_regex_prop->get_value()->as_string().empty())
-      && (!name_not_regex_prop
-	  || name_not_regex_prop->get_value()->as_string().empty())
-      && (!name_prop || name_prop->get_value()->as_string().empty())
-      && !consider_type_kind
-      && srcloc_not_regexp_str.empty()
-      && srcloc_not_in.empty())
-    return result;
-
   result.reset(new type_suppression(label_str, name_regex_str, name_str));
 
   if (consider_type_kind)
@@ -3288,32 +3275,16 @@ read_function_suppression(const ini::config::section& section)
 	  parms.push_back(parm);
       }
 
-  if (!label_str.empty()
-      || !name.empty()
-      || !name_regex_str.empty()
-      || !name_not_regex_str.empty()
-      || !file_name_regex_str.empty()
-      || !file_name_not_regex_str.empty()
-      || !soname_regex_str.empty()
-      || !soname_not_regex_str.empty()
-      || !return_type_name.empty()
-      || !return_type_regex_str.empty()
-      || !sym_name.empty()
-      || !sym_name_regex_str.empty()
-      || !sym_name_not_regex_str.empty()
-      || !sym_version.empty()
-      || !sym_ver_regex_str.empty()
-      || !parms.empty())
-
-    result.reset(new function_suppression(label_str, name,
-					  name_regex_str,
-					  return_type_name,
-					  return_type_regex_str,
-					  parms,
-					  sym_name,
-					  sym_name_regex_str,
-					  sym_version,
-					  sym_ver_regex_str));
+  result.reset(new function_suppression(label_str,
+					name,
+					name_regex_str,
+					return_type_name,
+					return_type_regex_str,
+					parms,
+					sym_name,
+					sym_name_regex_str,
+					sym_version,
+					sym_ver_regex_str));
 
   if ((drop_artifact_str == "yes" || drop_artifact_str == "true")
       && (!name.empty()
@@ -3324,11 +3295,11 @@ read_function_suppression(const ini::config::section& section)
 	  || !sym_name_not_regex_str.empty()))
     result->set_drops_artifact_from_ir(true);
 
-  if (result && !change_kind_str.empty())
+  if (!change_kind_str.empty())
     result->set_change_kind
       (function_suppression::parse_change_kind(change_kind_str));
 
-  if (result && !allow_other_aliases.empty())
+  if (!allow_other_aliases.empty())
     result->set_allow_other_aliases(allow_other_aliases == "yes"
 				    || allow_other_aliases == "true");
 
@@ -4157,27 +4128,15 @@ read_variable_suppression(const ini::config::section& section)
     ? type_name_regex_prop->get_value()->as_string()
      : "";
 
-  if (label_str.empty()
-      && name_str.empty()
-      && name_regex_str.empty()
-      && name_not_regex_str.empty()
-      && file_name_regex_str.empty()
-      && file_name_not_regex_str.empty()
-      && soname_regex_str.empty()
-      && soname_not_regex_str.empty()
-      && symbol_name.empty()
-      && symbol_name_regex_str.empty()
-      && symbol_name_not_regex_str.empty()
-      && symbol_version.empty()
-      && symbol_version_regex_str.empty()
-      && type_name_str.empty()
-      && type_name_regex_str.empty())
-    return result;
-
-  result.reset(new variable_suppression(label_str, name_str, name_regex_str,
-					symbol_name, symbol_name_regex_str,
-					symbol_version, symbol_version_regex_str,
-					type_name_str, type_name_regex_str));
+  result.reset(new variable_suppression(label_str,
+					name_str,
+					name_regex_str,
+					symbol_name,
+					symbol_name_regex_str,
+					symbol_version,
+					symbol_version_regex_str,
+					type_name_str,
+					type_name_regex_str));
 
   if ((drop_artifact_str == "yes" || drop_artifact_str == "true")
       && (!name_str.empty()
@@ -4194,7 +4153,7 @@ read_variable_suppression(const ini::config::section& section)
   if (!symbol_name_not_regex_str.empty())
     result->set_symbol_name_not_regex_str(symbol_name_not_regex_str);
 
-  if (result && !change_kind_str.empty())
+  if (!change_kind_str.empty())
     result->set_change_kind
       (variable_suppression::parse_change_kind(change_kind_str));
 
@@ -4337,12 +4296,6 @@ read_file_suppression(const ini::config::section& section)
     ? soname_not_regex_prop->get_value()->as_string()
     : "";
 
-  if (file_name_regex_str.empty()
-      && file_name_not_regex_str.empty()
-      && soname_regex_str.empty()
-      && soname_not_regex_str.empty())
-    return result;
-
   result.reset(new file_suppression(label_str,
 				    file_name_regex_str,
 				    file_name_not_regex_str));
diff --git a/tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt b/tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt
index 4eaba5b7..83dfe326 100644
--- a/tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt
+++ b/tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt
@@ -1,10 +1,6 @@
-Functions changes summary: 0 Removed, 1 Changed, 1 Added functions
+Functions changes summary: 0 Removed, 1 Changed, 0 Added (1 filtered out) functions
 Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
 
-1 Added function:
-
-  [A] 'function void bar()'    {_Z3barv}
-
 1 function with some indirect sub-type change:
 
   [C] 'function void bar(S&)' has some indirect sub-type changes:
diff --git a/tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt b/tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt
index b28fbd16..851f7728 100644
--- a/tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt
+++ b/tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt
@@ -1,16 +1,3 @@
-Functions changes summary: 1 Removed, 1 Changed, 0 Added functions
+Functions changes summary: 0 Removed (1 filtered out), 0 Changed (1 filtered out), 0 Added functions
 Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
 
-1 Removed function:
-
-  [D] 'function void bar()'    {_Z3barv}
-
-1 function with some indirect sub-type change:
-
-  [C] 'function void bar(S*)' has some indirect sub-type changes:
-    parameter 1 of type 'S*' has sub-type changes:
-      in pointed to type 'struct S':
-        type size changed from 32 to 64 (in bits)
-        1 data member insertion:
-          'unsigned int S::bar', at offset 32 (in bits)
-
diff --git a/tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt b/tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt
index 6965a151..f4e0aa29 100644
--- a/tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt
+++ b/tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt
@@ -1,16 +1,3 @@
 Functions changes summary: 0 Removed, 0 Changed, 0 Added function
-Variables changes summary: 0 Removed, 1 Changed, 1 Added variables
-
-1 Added variable:
-
-  [A] 'int var1'    {var1}
-
-1 Changed variable:
-
-  [C] 'S* var0' was changed:
-    type of variable changed:
-      in pointed to type 'struct S':
-        type size changed from 32 to 64 (in bits)
-        1 data member insertion:
-          'char S::m1', at offset 32 (in bits)
+Variables changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added (1 filtered out) variables
 
diff --git a/tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt b/tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt
index 3edf2bd1..ac380a4a 100644
--- a/tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt
+++ b/tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt
@@ -1,16 +1,3 @@
 Functions changes summary: 0 Removed, 0 Changed, 0 Added function
-Variables changes summary: 1 Removed, 1 Changed, 0 Added variables
-
-1 Removed variable:
-
-  [D] 'int var1'    {var1}
-
-1 Changed variable:
-
-  [C] 'S* var0' was changed:
-    type of variable changed:
-      in pointed to type 'struct S':
-        type size changed from 32 to 64 (in bits)
-        1 data member insertion:
-          'char S::m1', at offset 32 (in bits)
+Variables changes summary: 0 Removed (1 filtered out), 0 Changed (1 filtered out), 0 Added variables
 
-- 
2.26.2.303.gf8c07b1a785-goog


  parent reply	other threads:[~2020-04-24  9:22 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 15:44 [PATCH 00/21] Simplify regex and suppression parsing Giuliano Procida
2020-04-23 15:44 ` [PATCH 01/21] Move regex definitions to own files Giuliano Procida
2020-04-23 15:44 ` [PATCH 02/21] Move libxml bits out of abg-sptr-utils.h Giuliano Procida
2020-04-23 15:44 ` [PATCH 03/21] Simplify generation of symbol whitelist regex Giuliano Procida
2020-04-23 15:44 ` [PATCH 04/21] Escape names used in symbol whitelisting regex Giuliano Procida
2020-04-23 15:44 ` [PATCH 05/21] abg-suppression.cc: More uniform variable naming Giuliano Procida
2020-04-23 15:44 ` [PATCH 06/21] diff suppression: Fix handling of change kinds Giuliano Procida
2020-04-23 15:44 ` [PATCH 07/21] Add POSIX regex wrapper functions Giuliano Procida
2020-04-23 18:07   ` [PATCH v2 " Giuliano Procida
2020-04-23 15:44 ` [PATCH 08/21] Use regex::compile wrapper instead of regcomp Giuliano Procida
2020-04-23 15:44 ` [PATCH 09/21] Use regex::match wrapper instead of regexec Giuliano Procida
2020-04-23 18:02   ` [PATCH v2 " Giuliano Procida
2020-04-23 15:44 ` [PATCH 10/21] Refactor read_parameter_spec_from_string logic Giuliano Procida
2020-04-23 15:44 ` [PATCH 11/21] Compile suppression regexes earlier Giuliano Procida
2020-04-23 15:44 ` [PATCH 12/21] Reduce direct access to suppression priv_ members Giuliano Procida
2020-04-23 15:44 ` [PATCH 13/21] Move match methods from priv to suppression_base Giuliano Procida
2020-04-23 15:44 ` [PATCH 14/21] Remove suppression types' priv class methods Giuliano Procida
2020-04-23 15:44 ` [PATCH 15/21] abg-suppression.cc: More consistent regex matching Giuliano Procida
2020-04-23 15:44 ` [PATCH 16/21] abg-tools-utils.cc: Assert generated regexes OK Giuliano Procida
2020-04-23 15:44 ` [PATCH 17/21] Refactor suppression property string parsing Giuliano Procida
2020-04-23 15:44 ` [PATCH 18/21] Refactor suppression property regex parsing Giuliano Procida
2020-04-23 15:44 ` [PATCH 19/21] Warn if user-supplied regexes fail to compile Giuliano Procida
2020-04-23 18:04   ` [PATCH v2 " Giuliano Procida
2020-04-23 15:44 ` [PATCH 20/21] Default construct suppression types Giuliano Procida
2020-04-23 15:44 ` [PATCH 21/21] Remove unused suppression type priv constructors Giuliano Procida
2020-04-23 18:11 ` [PATCH 00/21] Simplify regex and suppression parsing Giuliano Procida
2020-04-24  8:54   ` Giuliano Procida
2020-04-24  9:21 ` [PATCH v3 00/21]Simplify " Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 01/21] Move regex definitions to own files Giuliano Procida
2020-04-27 10:52     ` Matthias Maennich
2020-04-29 14:19       ` Dodji Seketeli
2020-04-29 14:35         ` Giuliano Procida
2020-05-04  9:19     ` Dodji Seketeli
2020-04-24  9:21   ` [PATCH v3 02/21] Move libxml bits out of abg-sptr-utils.h Giuliano Procida
2020-04-27 10:53     ` Matthias Maennich
2020-04-29 14:30     ` Dodji Seketeli
2020-05-04  9:20     ` Dodji Seketeli
2020-04-24  9:21   ` [PATCH v3 03/21] Simplify generation of symbol whitelist regex Giuliano Procida
2020-04-27 11:01     ` Matthias Maennich
2020-04-27 15:31       ` Giuliano Procida
2020-05-04  9:20     ` Dodji Seketeli
2020-04-24  9:21   ` [PATCH v3 04/21] Escape names used in symbol whitelisting regex Giuliano Procida
2020-04-27 11:14     ` Matthias Maennich
2020-04-27 15:37       ` Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 05/21] abg-suppression.cc: More uniform variable naming Giuliano Procida
2020-04-27 11:17     ` Matthias Maennich
2020-04-24  9:21   ` Giuliano Procida [this message]
2020-04-24  9:21   ` [PATCH v3 07/21] Add POSIX regex wrapper functions Giuliano Procida
2020-04-27 11:23     ` Matthias Maennich
2020-04-24  9:21   ` [PATCH v3 08/21] Use regex::compile wrapper instead of regcomp Giuliano Procida
2020-04-27 11:34     ` Matthias Maennich
2020-04-27 16:01       ` Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 09/21] Use regex::match wrapper instead of regexec Giuliano Procida
2020-04-27 11:38     ` Matthias Maennich
2020-04-24  9:21   ` [PATCH v3 10/21] Refactor read_parameter_spec_from_string logic Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 11/21] Compile suppression regexes earlier Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 12/21] Reduce direct access to suppression priv_ members Giuliano Procida
2020-04-27 11:54     ` Matthias Maennich
2020-04-24  9:21   ` [PATCH v3 13/21] Move match methods from priv to suppression_base Giuliano Procida
2020-04-27 11:55     ` Matthias Maennich
2020-04-24  9:21   ` [PATCH v3 14/21] Remove suppression types' priv class methods Giuliano Procida
2020-04-27 11:57     ` Matthias Maennich
2020-04-24  9:21   ` [PATCH v3 15/21] abg-suppression.cc: More consistent regex matching Giuliano Procida
2020-04-27 12:07     ` Matthias Maennich
2020-04-27 16:18       ` Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 16/21] abg-tools-utils.cc: Assert generated regexes OK Giuliano Procida
2020-04-27 12:08     ` Matthias Maennich
2020-04-27 16:21       ` Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 17/21] Refactor suppression property string parsing Giuliano Procida
2020-04-27 12:17     ` Matthias Maennich
2020-04-27 16:42       ` Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 18/21] Refactor suppression property regex parsing Giuliano Procida
2020-04-27 14:55     ` Matthias Maennich
2020-04-27 16:59       ` Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 19/21] Warn if user-supplied regexes fail to compile Giuliano Procida
2020-04-27 15:36     ` Matthias Maennich
2020-05-01  8:49       ` Giuliano Procida
2020-04-24  9:21   ` [PATCH v3 20/21] Default construct suppression types Giuliano Procida
2020-04-27 15:40     ` Matthias Maennich
2020-04-24  9:21   ` [PATCH v3 21/21] Remove unused suppression type priv constructors Giuliano Procida
2020-04-27 15:41     ` Matthias Maennich
2020-05-04 12:34   ` [PATCH v4 00/15] Simplify regex and suppression parsing Giuliano Procida
2020-05-04 12:34     ` [PATCH v4 01/15] Tidy #includes in a few files Giuliano Procida
2020-05-04 12:49       ` Matthias Maennich
2020-05-11 13:24       ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 02/15] Document ^_^ regex in generate_from_strings Giuliano Procida
2020-05-04 12:49       ` Matthias Maennich
2020-05-11 13:32       ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 03/15] Escape names used in symbol whitelisting regex Giuliano Procida
2020-05-04 12:57       ` Matthias Maennich
2020-05-04 16:45         ` [PATCH v5 " Giuliano Procida
2020-05-11 13:59           ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 04/15] abg-suppression.cc: More uniform variable naming Giuliano Procida
2020-05-11 14:04       ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 05/15] diff suppression: Fix handling of change kinds Giuliano Procida
2020-05-04 13:04       ` Matthias Maennich
2020-05-11 14:15       ` Dodji Seketeli
2020-05-11 15:47         ` Giuliano Procida
2020-05-11 17:53           ` Dodji Seketeli
2020-05-12  9:54             ` Giuliano Procida
2020-05-12 10:14               ` [PATCH v5 05/15] Tidy checks for sufficient suppression properties Giuliano Procida
2020-05-12 16:11                 ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 06/15] Add POSIX regex wrapper functions Giuliano Procida
2020-05-11 16:37       ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 07/15] Use regex::compile wrapper instead of regcomp Giuliano Procida
2020-05-11 16:38       ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 08/15] Use regex::match wrapper instead of regexec Giuliano Procida
2020-05-12 16:35       ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 09/15] Refactor read_parameter_spec_from_string logic Giuliano Procida
2020-05-13  7:51       ` Dodji Seketeli
2020-05-04 12:34     ` [PATCH v4 10/15] Compile suppression regexes earlier Giuliano Procida
2020-05-04 13:14       ` Matthias Maennich
2020-05-13  8:07       ` Dodji Seketeli
2020-05-13 15:36         ` Giuliano Procida
2020-05-04 12:34     ` [PATCH v4 11/15] Reduce direct access to suppression priv_ members Giuliano Procida
2020-05-04 12:34     ` [PATCH v4 12/15] Move match methods from priv to suppression_base Giuliano Procida
2020-05-04 12:34     ` [PATCH v4 13/15] Remove suppression type priv class methods Giuliano Procida
2020-05-04 12:34     ` [PATCH v4 14/15] abg-suppression.cc: More consistent regex matching Giuliano Procida
2020-05-04 13:17       ` Matthias Maennich
2020-05-04 12:34     ` [PATCH v4 15/15] abg-tools-utils.cc: Assert generated regexes OK 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=20200424092132.150547-7-gprocida@google.com \
    --to=gprocida@google.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    --cc=maennich@google.com \
    /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).