[pulseaudio-commits] r2022 - in /trunk/src: modules/module-esound-sink.c pulsecore/iochannel.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Nov 4 08:51:28 PST 2007


Author: lennart
Date: Sun Nov  4 17:51:26 2007
New Revision: 2022

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2022&root=pulseaudio&view=rev
Log:
fix two alignment issues found by the debian buildd gcc on sparc

Modified:
    trunk/src/modules/module-esound-sink.c
    trunk/src/pulsecore/iochannel.c

Modified: trunk/src/modules/module-esound-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-esound-sink.c?rev=2022&root=pulseaudio&r1=2021&r2=2022&view=diff
==============================================================================
--- trunk/src/modules/module-esound-sink.c (original)
+++ trunk/src/modules/module-esound-sink.c Sun Nov  4 17:51:26 2007
@@ -506,6 +506,7 @@
     pa_modargs *ma = NULL;
     char *t;
     const char *espeaker;
+    uint32_t key;
 
     pa_assert(m);
 
@@ -584,7 +585,9 @@
         pa_log("Failed to load cookie");
         goto fail;
     }
-    *(int32_t*) ((uint8_t*) u->write_data + ESD_KEY_LEN) = ESD_ENDIAN_KEY;
+
+    key = ESD_ENDIAN_KEY;
+    memcpy((uint8_t*) u->write_data + ESD_KEY_LEN, &key, sizeof(key));
 
     /* Reserve space for the response */
     u->read_data = pa_xmalloc(u->read_length = sizeof(int32_t));

Modified: trunk/src/pulsecore/iochannel.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/iochannel.c?rev=2022&root=pulseaudio&r1=2021&r2=2022&view=diff
==============================================================================
--- trunk/src/pulsecore/iochannel.c (original)
+++ trunk/src/pulsecore/iochannel.c Sun Nov  4 17:51:26 2007
@@ -267,9 +267,11 @@
     ssize_t r;
     struct msghdr mh;
     struct iovec iov;
-    uint8_t cmsg_data[CMSG_SPACE(sizeof(struct ucred))];
+    union {
+        struct cmsghdr hdr;
+        uint8_t data[CMSG_SPACE(sizeof(struct ucred))];
+    } cmsg;
     struct ucred *u;
-    struct cmsghdr *cmsg;
 
     pa_assert(io);
     pa_assert(data);
@@ -280,13 +282,12 @@
     iov.iov_base = (void*) data;
     iov.iov_len = l;
 
-    memset(cmsg_data, 0, sizeof(cmsg_data));
-    cmsg = (struct cmsghdr*)  cmsg_data;
-    cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred));
-    cmsg->cmsg_level = SOL_SOCKET;
-    cmsg->cmsg_type = SCM_CREDENTIALS;
-
-    u = (struct ucred*) CMSG_DATA(cmsg);
+    memset(&cmsg, 0, sizeof(cmsg));
+    cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(struct ucred));
+    cmsg.hdr.cmsg_level = SOL_SOCKET;
+    cmsg.hdr.cmsg_type = SCM_CREDENTIALS;
+
+    u = (struct ucred*) CMSG_DATA(&cmsg.hdr);
 
     u->pid = getpid();
     if (ucred) {
@@ -302,8 +303,8 @@
     mh.msg_namelen = 0;
     mh.msg_iov = &iov;
     mh.msg_iovlen = 1;
-    mh.msg_control = cmsg_data;
-    mh.msg_controllen = sizeof(cmsg_data);
+    mh.msg_control = &cmsg;
+    mh.msg_controllen = sizeof(cmsg);
     mh.msg_flags = 0;
 
     if ((r = sendmsg(io->ofd, &mh, MSG_NOSIGNAL)) >= 0) {
@@ -318,7 +319,10 @@
     ssize_t r;
     struct msghdr mh;
     struct iovec iov;
-    uint8_t cmsg_data[CMSG_SPACE(sizeof(struct ucred))];
+    union {
+        struct cmsghdr hdr;
+        uint8_t data[CMSG_SPACE(sizeof(struct ucred))];
+    } cmsg;
 
     pa_assert(io);
     pa_assert(data);
@@ -331,28 +335,28 @@
     iov.iov_base = data;
     iov.iov_len = l;
 
-    memset(cmsg_data, 0, sizeof(cmsg_data));
+    memset(&cmsg, 0, sizeof(cmsg));
 
     memset(&mh, 0, sizeof(mh));
     mh.msg_name = NULL;
     mh.msg_namelen = 0;
     mh.msg_iov = &iov;
     mh.msg_iovlen = 1;
-    mh.msg_control = cmsg_data;
-    mh.msg_controllen = sizeof(cmsg_data);
+    mh.msg_control = &cmsg;
+    mh.msg_controllen = sizeof(cmsg);
     mh.msg_flags = 0;
 
     if ((r = recvmsg(io->ifd, &mh, 0)) >= 0) {
-        struct cmsghdr *cmsg;
+        struct cmsghdr *cmh;
 
         *creds_valid = 0;
 
-        for (cmsg = CMSG_FIRSTHDR(&mh); cmsg; cmsg = CMSG_NXTHDR(&mh, cmsg)) {
-
-            if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDENTIALS) {
+        for (cmh = CMSG_FIRSTHDR(&mh); cmh; cmh = CMSG_NXTHDR(&mh, cmh)) {
+
+            if (cmh->cmsg_level == SOL_SOCKET && cmh->cmsg_type == SCM_CREDENTIALS) {
                 struct ucred u;
-                pa_assert(cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred)));
-                memcpy(&u, CMSG_DATA(cmsg), sizeof(struct ucred));
+                pa_assert(cmh->cmsg_len == CMSG_LEN(sizeof(struct ucred)));
+                memcpy(&u, CMSG_DATA(cmh), sizeof(struct ucred));
 
                 creds->gid = u.gid;
                 creds->uid = u.uid;




More information about the pulseaudio-commits mailing list