From: Adhemerval Zanella Date: Fri, 17 Oct 2025 19:12:47 +0000 (-0300) Subject: sunrpc: Suppress clang -Wgnu-variable-sized-type-not-at-end warning on struct cmessage X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6eb1d9a9ed64b97a1800b0f7310c2a3a92245bc5;p=thirdparty%2Fglibc.git sunrpc: Suppress clang -Wgnu-variable-sized-type-not-at-end warning on struct cmessage 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 --- diff --git a/sunrpc/svc_unix.c b/sunrpc/svc_unix.c index 2743c1419a..c97880c012 100644 --- a/sunrpc/svc_unix.c +++ b/sunrpc/svc_unix.c @@ -65,6 +65,7 @@ #include #include #include +#include /* * 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