public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] tests/sw_sync: fix gcc warning
@ 2019-10-13 19:08 Juha-Pekka Heikkila
  2019-10-14 14:26 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Juha-Pekka Heikkila @ 2019-10-13 19:08 UTC (permalink / raw)
  To: igt-dev

casting void pointer to int pointer causes gcc to be unhapy with comment:
"warning: dereferencing type-punned pointer will break strict-aliasing 
rules"

change:
*((int *) CMSG_DATA(cmsg)) = timeline;
to:
memcpy(CMSG_DATA(cmsg), &timeline, sizeof(timeline));

so everyting is nicely defined for compiler.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
---
 tests/sw_sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 62d1d17..626b6d3 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -228,7 +228,7 @@ static void test_sync_busy_fork_unixsocket(void)
 		cmsg->cmsg_type = SCM_RIGHTS;
 		cmsg->cmsg_len = CMSG_LEN(sizeof(timeline));
 
-		*((int *) CMSG_DATA(cmsg)) = timeline;
+		memcpy(CMSG_DATA(cmsg), &timeline, sizeof(timeline));
 		msg.msg_controllen = cmsg->cmsg_len;
 
 		igt_assert_f(sync_fence_wait(fence, 0) == -ETIME,
-- 
2.7.4

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-15 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-13 19:08 [igt-dev] [PATCH i-g-t] tests/sw_sync: fix gcc warning Juha-Pekka Heikkila
2019-10-14 14:26 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-10-14 20:08 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-10-15 10:52 ` [igt-dev] [PATCH i-g-t] " Petri Latvala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox