Subject: bug#20733: coreutils build problem

From: Paul Eggert <[email-masked]>
Date: Fri, 05 Jun 2015 08:29:26 -0700

Michael Felt wrote:
> "lib/get-permissions.c", line 258.5: 1506-045 (S) Undeclared identifier ret.
> "lib/get-permissions.c", line 260.20: 1506-280 (W) Function argument
> assignment between types "char*" and "const char*" is not allowed.
> make: 1254-004 The error code from the last command is 1.

That's a bug recently introduced into gnulib, and it's the sort of fun one gets 
on the bleeding edge.  I installed the attached patch and will cc: this to 
bug-gnulib.  Now please try:

http://www.cs.ucla.edu/~eggert/coreutils-8.23.211-b1d1a.tar.xz

diff --git a/ChangeLog b/ChangeLog
index e1f2492..ed68032 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-06-05  Paul Eggert  <[email-masked]>
+
+	acl-permissions: port to older AIX, C89 HP-UX
+	* lib/get-permissions.c (get_permissions):
+	If USE_ACL && HAVE_GETACL /* HP-UX */, don't assume C99.
+	If USE_ACL && HAVE_STATACL /* older AIX */, add missing decl
+	that broke a build, reported by Michael Felt.
+
 2015-06-03  Pádraig Brady  <[email-masked]>
 
 	vasprintf-posix: avoid compiling vasnprintf where possible
diff --git a/lib/get-permissions.c b/lib/get-permissions.c
index ccee1f1..6c6618d 100644
--- a/lib/get-permissions.c
+++ b/lib/get-permissions.c
@@ -33,7 +33,7 @@ int
 get_permissions (const char *name, int desc, mode_t mode,
 		 struct permission_context *ctx)
 {
-  memset (ctx, 0, sizeof(*ctx));
+  memset (ctx, 0, sizeof *ctx);
   ctx->mode = mode;
 
 #if USE_ACL && HAVE_ACL_GET_FILE
@@ -215,38 +215,40 @@ get_permissions (const char *name, int desc, mode_t mode,
 
 #elif USE_ACL && HAVE_GETACL /* HP-UX */
 
-  int ret;
-
-  if (desc != -1)
-    ret = fgetacl (desc, NACLENTRIES, ctx->entries);
-  else
-    ret = getacl (name, NACLENTRIES, ctx->entries);
-  if (ret < 0)
-    {
-      if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
-	ret = 0;
-      else
-        return -1;
-    }
-  else if (ret > NACLENTRIES)
-    /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
-    abort ();
-  ctx->count = ret;
+  {
+    int ret;
+
+    if (desc != -1)
+      ret = fgetacl (desc, NACLENTRIES, ctx->entries);
+    else
+      ret = getacl (name, NACLENTRIES, ctx->entries);
+    if (ret < 0)
+      {
+        if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
+          ret = 0;
+        else
+          return -1;
+      }
+    else if (ret > NACLENTRIES)
+      /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
+      abort ();
+    ctx->count = ret;
 
 # if HAVE_ACLV_H
-  ret = acl ((char *) name, ACL_GET, NACLVENTRIES, ctx->aclv_entries);
-  if (ret < 0)
-    {
-      if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
-        ret = 0;
-      else
-        return -2;
-    }
-  else if (ret > NACLVENTRIES)
-    /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation.  */
+    ret = acl ((char *) name, ACL_GET, NACLVENTRIES, ctx->aclv_entries);
+    if (ret < 0)
+      {
+        if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+          ret = 0;
+        else
+          return -2;
+      }
+    else if (ret > NACLVENTRIES)
+      /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation.  */
       abort ();
-  ctx->aclv_count = ret;
+    ctx->aclv_count = ret;
 # endif
+  }
 
 #elif USE_ACL && HAVE_ACLX_GET && ACL_AIX_WIP /* AIX */
 
@@ -254,24 +256,27 @@ get_permissions (const char *name, int desc, mode_t mode,
 
 #elif USE_ACL && HAVE_STATACL /* older AIX */
 
-  if (desc != -1)
-    ret = fstatacl (desc, STX_NORMAL, &ctx->u.a, sizeof (ctx->u));
-  else
-    ret = statacl (name, STX_NORMAL, &ctx->u.a, sizeof (ctx->u));
-  if (ret == 0)
-    ctx->have_u = true;
+  {
+    int ret;
+    if (desc != -1)
+      ret = fstatacl (desc, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+    else
+      ret = statacl ((char *) name, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+    if (ret == 0)
+      ctx->have_u = true;
+  }
 
 #elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
 
-  int ret;
-
-  ret = acl ((char *) name, ACL_GET, NACLENTRIES, ctx->entries);
-  if (ret < 0)
-    return -1;
-  else if (ret > NACLENTRIES)
-    /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
-    abort ();
-  ctx->count = ret;
+  {
+    int ret = acl ((char *) name, ACL_GET, NACLENTRIES, ctx->entries);
+    if (ret < 0)
+      return -1;
+    else if (ret > NACLENTRIES)
+      /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
+      abort ();
+    ctx->count = ret;
+  }
 
 #endif