[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] acl: Address pure attribute errors with gcc 4.9

From: Ben Walton
Subject: [PATCH] acl: Address pure attribute errors with gcc 4.9
Date: Sun, 1 Jun 2014 09:42:25 +0100

    * lib/acl-internal.h (acl_ace_nontrivial): Apply pure attribute
    * lib/file-has-acl.c: Disable pure attribute error.
      - The AIX version of acl_nontrivial isn't pure while other
        versions are. We cannot apply the attribute globally.

Signed-off-by: Ben Walton <address@hidden>
When building coreutils 8.22 on Solaris 10 x86, gcc 4.9.0 emits:

b/file-has-acl.c: In function 'acl_nontrivial':
lib/file-has-acl.c:133:1: error: function might be candidate for attribute 
'pure' [-Werror=suggest-attribute=pure]
 acl_nontrivial (int count, aclent_t *entries)
lib/file-has-acl.c: In function 'acl_ace_nontrivial':
lib/file-has-acl.c:164:1: error: function might be candidate for attribute 
'pure' [-Werror=suggest-attribute=pure]
 acl_ace_nontrivial (int count, ace_t *entries)

It seems that acl_ace_nontrivial is pure, so mark it as such.
For acl_nontrivial though, the AIX version isn't pure, so disable
the warning instead.  I'm not keen on squashing the warning for all
versions of the function, but applying the attribute selectively
doesn't feel right either. Maybe I'm missing the nicest solution

 lib/acl-internal.h | 2 +-
 lib/file-has-acl.c | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index fdffe64..8c26dae 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -181,7 +181,7 @@ extern int acl_nontrivial (int count, aclent_t *entries);
 /* Test an ACL retrieved with ACE_GETACL.
    Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
    Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.  */
-extern int acl_ace_nontrivial (int count, ace_t *entries);
+extern int acl_ace_nontrivial (int count, ace_t *entries) _GL_ATTRIBUTE_PURE;
 /* Definitions for when the built executable is executed on Solaris 10
    (newer version) or Solaris 11.  */
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index 5104a41..3ac12e3 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -23,6 +23,14 @@
 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
+/* Without this pragma, gcc 4.9.0 may suggest that the
+   acl_nontrivial function might be a candidate for attribute
+   'pure'. The AIX version of the function invalidates the
+   suggestion.  The other versions would be ok.                    */
+#if (__GNUC__ == 4 && 9 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
 #include <config.h>
 #include "acl.h"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]