summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-11-04 16:51:26 +0000
committerLennart Poettering <lennart@poettering.net>2007-11-04 16:51:26 +0000
commit961ce33b5ee183236363ef39d1afa93d8e5605b3 (patch)
treef89d3d5383fe85a39719791b49dd22d244af24a3
parentfaf1fd76a9bb9e47c867f9aa4ea18a7a70a14aae (diff)
fix two alignment issues found by the debian buildd gcc on sparc
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2022 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r--src/modules/module-esound-sink.c5
-rw-r--r--src/pulsecore/iochannel.c42
2 files changed, 27 insertions, 20 deletions
diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c
index 1c02cdfd..b18d3258 100644
--- a/src/modules/module-esound-sink.c
+++ b/src/modules/module-esound-sink.c
@@ -506,6 +506,7 @@ int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
char *t;
const char *espeaker;
+ uint32_t key;
pa_assert(m);
@@ -584,7 +585,9 @@ int pa__init(pa_module*m) {
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));
diff --git a/src/pulsecore/iochannel.c b/src/pulsecore/iochannel.c
index 01f17ab3..63ab2ad7 100644
--- a/src/pulsecore/iochannel.c
+++ b/src/pulsecore/iochannel.c
@@ -267,9 +267,11 @@ ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l
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 @@ ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l
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;
+ 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);
+ u = (struct ucred*) CMSG_DATA(&cmsg.hdr);
u->pid = getpid();
if (ucred) {
@@ -302,8 +303,8 @@ ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l
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 pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_cr
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 @@ ssize_t pa_iochannel_read_with_creds(pa_iochannel*io, void*data, size_t l, pa_cr
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)) {
+ for (cmh = CMSG_FIRSTHDR(&mh); cmh; cmh = CMSG_NXTHDR(&mh, cmh)) {
- if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_CREDENTIALS) {
+ 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;