gnome-keyring Removing GCC-specific hack from



Hi all,

I was just trying to compile gnome-keyring with Clang (from the LLVM
project) and it seems it doesn't support this construct (which makes
a lot of sense in my opinion):

	const int i = 5;
	union {
		char foo[i];
	} bar;

The attached patch makes gnome-keyring build with Clang. This is
actually the first package I'm seeing that actually uses this construct
(nowhere used in FreeBSD, Xorg, etc).

-- 
 Ed Schouten <ed 80386 nl>
 WWW: http://80386.nl/
--- common/gkr-unix-credentials.c
+++ common/gkr-unix-credentials.c
@@ -50,16 +50,12 @@
 	 * remote PID. */
 #if defined(HAVE_CMSGCRED)
 	struct cmsgcred *cred;
-	const size_t cmsglen = CMSG_LEN (sizeof (struct cmsgcred));
-	const size_t cmsgspace = CMSG_SPACE (sizeof (struct cmsgcred));
 #else /* defined(LOCAL_CREDS) */
 	struct sockcred *cred;
-	const size_t cmsglen = CMSG_LEN (sizeof (struct sockcred));
-	const size_t cmsgspace = CMSG_SPACE (sizeof (struct sockcred));
 #endif
 	union {
 		struct cmsghdr hdr;
-		char cred[cmsgspace];
+		char cred[CMSG_SPACE(sizeof *cred)];
 	} cmsg;
 #endif
 	
@@ -80,7 +76,7 @@
 #if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS)
 	memset (&cmsg, 0, sizeof (cmsg));
 	msg.msg_control = (caddr_t) &cmsg;
-	msg.msg_controllen = cmsgspace;
+	msg.msg_controllen = CMSG_SPACE(sizeof *cred);
 #endif
 
  again:
@@ -102,7 +98,8 @@
 	}
 
 #if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS)
-	if (cmsg.hdr.cmsg_len < cmsglen || cmsg.hdr.cmsg_type != SCM_CREDS) {
+	if (cmsg.hdr.cmsg_len < CMSG_LEN(sizeof *cred) ||
+	    cmsg.hdr.cmsg_type != SCM_CREDS) {
 		fprintf (stderr, "message from recvmsg() was not SCM_CREDS\n");
 		return -1;
 	}

Attachment: pgpIMGnb57fR3.pgp
Description: PGP signature



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