From: Mathieu Desnoyers Date: Mon, 26 Sep 2011 17:44:40 +0000 (-0400) Subject: Cleanup: fix strict aliasing ion tests X-Git-Url: http://git.lttng.org/?a=commitdiff_plain;h=af327df150b177c3fba6b97d72a71e6767fb2384;hp=fb50c39dd77bec752b9695345fc2fab6cc7b9b46;p=ust.git Cleanup: fix strict aliasing ion tests Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/ust-basic-tracing/ust-basic-tracing.c b/tests/ust-basic-tracing/ust-basic-tracing.c index a2f75d4..583179c 100644 --- a/tests/ust-basic-tracing/ust-basic-tracing.c +++ b/tests/ust-basic-tracing/ust-basic-tracing.c @@ -159,6 +159,11 @@ static int lttcomm_recv_fd(int sock) struct cmsghdr *cmsg; char recv_fd[CMSG_SPACE(sizeof(int))]; struct msghdr msg = { 0 }; + union { + unsigned char vc[4]; + int vi; + } tmp; + int i; /* Prepare to receive the structures */ iov[0].iov_base = &data_fd; @@ -189,7 +194,9 @@ static int lttcomm_recv_fd(int sock) goto end; } /* this is our fd */ - ret = ((int *) CMSG_DATA(cmsg))[0]; + for (i = 0; i < sizeof(int); i++) + tmp.vc[i] = CMSG_DATA(cmsg)[0]; + ret = tmp.vi; printf("received fd %d\n", ret); end: return ret; diff --git a/tests/ust-multi-test/ust-multi-test.c b/tests/ust-multi-test/ust-multi-test.c index 2737c18..c4b4f21 100644 --- a/tests/ust-multi-test/ust-multi-test.c +++ b/tests/ust-multi-test/ust-multi-test.c @@ -167,6 +167,11 @@ static int lttcomm_recv_fd(int sock) struct cmsghdr *cmsg; char recv_fd[CMSG_SPACE(sizeof(int))]; struct msghdr msg = { 0 }; + union { + unsigned char vc[4]; + int vi; + } tmp; + int i; /* Prepare to receive the structures */ iov[0].iov_base = &data_fd; @@ -197,7 +202,9 @@ static int lttcomm_recv_fd(int sock) goto end; } /* this is our fd */ - ret = ((int *) CMSG_DATA(cmsg))[0]; + for (i = 0; i < sizeof(int); i++) + tmp.vc[i] = CMSG_DATA(cmsg)[0]; + ret = tmp.vi; printf("received fd %d\n", ret); end: return ret;