From: Petri Latvala <petri.latvala@intel.com>
To: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] tests/sw_sync: fix gcc warning
Date: Tue, 15 Oct 2019 13:52:29 +0300 [thread overview]
Message-ID: <20191015105229.GN4019@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <1570993695-3208-1-git-send-email-juhapekka.heikkila@gmail.com>
On Sun, Oct 13, 2019 at 10:08:15PM +0300, Juha-Pekka Heikkila wrote:
> casting void pointer to int pointer causes gcc to be unhapy with comment:
> "warning: dereferencing type-punned pointer will break strict-aliasing
> rules"
Make that "casting unsigned char pointer to int pointer".
If it had been void* it would have been fine.
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
>
> 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
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
prev parent reply other threads:[~2019-10-15 10:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Petri Latvala [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191015105229.GN4019@platvala-desk.ger.corp.intel.com \
--to=petri.latvala@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=juhapekka.heikkila@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox