]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
sunrpc: Suppress clang -Wgnu-variable-sized-type-not-at-end warning on struct cmessage
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 17 Oct 2025 19:12:47 +0000 (16:12 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 21 Oct 2025 12:24:10 +0000 (09:24 -0300)
clang issues:

svc_unix.c:318:18: error: field 'cmsg' with variable sized type 'struct cmsghdr' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
  318 |   struct cmsghdr cmsg;
      |                  ^

The __msgread explicitly expects that 'struct ucred' is after the 'cmsg',
so suppress the warning.

Reviewed-by: Sam James <sam@gentoo.org>
sunrpc/svc_unix.c

index 2743c1419af9aa4ad8c6f534ac3fe4614e1d3382..c97880c01230e9645d31c149b3a51cf0003b795b 100644 (file)
@@ -65,6 +65,7 @@
 #include <libintl.h>
 #include <wchar.h>
 #include <shlib-compat.h>
+#include <libc-diag.h>
 
 /*
  * Ops vector for AF_UNIX based rpc service handle
@@ -308,12 +309,18 @@ svcunix_destroy (SVCXPRT *xprt)
 }
 
 #ifdef SCM_CREDENTIALS
+/* clang complains if a flexible array member (struct cmsghdr) is not a the
+   end of the struct (it is a GNU extension).  The __msgread explicitly
+   expects that 'struct ucred' is after the 'cmsg', so disable the warning.  */
+DIAG_PUSH_NEEDS_COMMENT_CLANG;
+DIAG_IGNORE_NEEDS_COMMENT_CLANG (18, "-Wgnu-variable-sized-type-not-at-end");
 struct cmessage {
   struct cmsghdr cmsg;
   struct ucred cmcred;
   /* hack to make sure we have enough memory */
   char dummy[(CMSG_ALIGN (sizeof (struct ucred)) - sizeof (struct ucred) + sizeof (long))];
 };
+DIAG_POP_NEEDS_COMMENT_CLANG;
 
 /* XXX This is not thread safe, but since the main functions in svc.c
    and the rpcgen generated *_svc functions for the daemon are also not