From af327df150b177c3fba6b97d72a71e6767fb2384 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 26 Sep 2011 13:44:40 -0400 Subject: [PATCH] Cleanup: fix strict aliasing ion tests Signed-off-by: Mathieu Desnoyers --- tests/ust-basic-tracing/ust-basic-tracing.c | 9 ++++++++- tests/ust-multi-test/ust-multi-test.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/ust-basic-tracing/ust-basic-tracing.c b/tests/ust-basic-tracing/ust-basic-tracing.c index a2f75d4e..583179c1 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 2737c18f..c4b4f212 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; -- 2.34.1