>From 78988e6604ed05dfe6c7755f070d8fda69a9d36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 21 May 2020 13:45:01 +0100 Subject: [PATCH] maint: avoid warnings from GCC's -fanalyzer Reinstate a couple of -fanalyzer warning suppressions from commit v8.32-10-gc7194b43f, needed with Fedora 32: gcc (GCC) 10.1.1 20200507 (Red Hat 10.1.1-1) * src/tsort.c (record_relation): An assert doesn't suffice to avoid: [CWE-690] [-Wanalyzer-null-dereference] so disable the warning for this function. * src/chown-core.c: Suppress the following false positive for the file: [CWE-415] [-Wanalyzer-double-free] --- src/chown-core.c | 5 +++++ src/tsort.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/chown-core.c b/src/chown-core.c index f1e37eb26..6c221d287 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -16,6 +16,11 @@ /* Extracted from chown.c/chgrp.c and librarified by Jim Meyering. */ +/* GCC 10 gives a false postive warning with -fanalyzer for this. */ +#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__ +# pragma GCC diagnostic ignored "-Wanalyzer-double-free" +#endif + #include #include #include diff --git a/src/tsort.c b/src/tsort.c index 2a6961aa7..8373ca161 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -274,6 +274,13 @@ record_relation (struct item *j, struct item *k) { struct successor *p; +/* GCC 10 gives a false postive warning with -fanalyzer for this, + and an assert did not suppress the warning + with the initial GCC 10 release. */ +#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wanalyzer-null-dereference" +#endif if (!STREQ (j->str, k->str)) { k->count++; @@ -282,6 +289,9 @@ record_relation (struct item *j, struct item *k) p->next = j->top; j->top = p; } +#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__ +# pragma GCC diagnostic pop +#endif } static bool -- 2.26.2