[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <201903290431.x2T4Vq5A024120@sdf.org>
Date: Fri, 29 Mar 2019 04:31:52 GMT
From: George Spelvin <lkml@....org>
To: Andrew Morton <akpm@...ux-foundation.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
kbuild test robot <lkp@...el.com>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
George Spelvin <lkml@....org>,
Andrey Abramov <st5pub@...dex.ru>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Daniel Wagner <daniel.wagner@...mens.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Don Mullis <don.mullis@...il.com>,
Dave Chinner <dchinner@...hat.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH 6/5] lib/list_sort: Fix GCC warning
It turns out that GCC 4.9, 7.3, and 8.1 ignore the __pure
attribute on function pointers and (with the standard kernel
compile flags) emit a warning about it.
Even though it accurately describes a comparison function
(the compiler need not reload cached pointers across the call),
it doesn't actually help GCC 8.3's code generation, so just
omit it.
Signed-off-by: George Spelvin <lkml@....org>
Fixes: 820c81be5237 ("lib/list_sort: simplify and remove MAX_LIST_LENGTH_BITS")
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Stephen Rothwell <sfr@...b.auug.org.au>
---
lib/list_sort.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/list_sort.c b/lib/list_sort.c
index 623a9158ac8a..b1b492e20f1d 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -8,12 +8,16 @@
#include <linux/list.h>
/*
- * By declaring the compare function with the __pure attribute, we give
- * the compiler more opportunity to optimize. Ideally, we'd use this in
- * the prototype of list_sort(), but that would involve a lot of churn
- * at all call sites, so just cast the function pointer passed in.
+ * A more accurate type for comparison functions. Ideally, we'd use
+ * this in the prototype of list_sort(), but that would involve a lot of
+ * churn at all call sites, so just cast the function pointer passed in.
+ *
+ * This could also include __pure to give the compiler more opportunity
+ * to optimize, but that elicits an "attribute ignored" warning on
+ * GCC <= 8.1, and doesn't change GCC 8.3's code generation at all,
+ * so it's omitted.
*/
-typedef int __pure __attribute__((nonnull(2,3))) (*cmp_func)(void *,
+typedef int __attribute__((nonnull(2,3))) (*cmp_func)(void *,
struct list_head const *, struct list_head const *);
/*
--
2.20.1
Powered by blists - more mailing lists