diff mbox series

[RFC,2/5] libdrm: amdgpu: Initialize unions with memset rather than "= {0}"

Message ID 1555734295-31015-3-git-send-email-john.stultz@linaro.org
State Superseded
Headers show
Series libdrm: Patches from AOSP | expand

Commit Message

John Stultz April 20, 2019, 4:24 a.m. UTC
Clang complains when initializing unions using "= {0}"
so instead use memset.

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Marissa Wall <marissaw@google.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>

---
 amdgpu/amdgpu_cs.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

-- 
2.7.4

Comments

Alex Deucher April 22, 2019, 2:58 p.m. UTC | #1
On Sat, Apr 20, 2019 at 12:25 AM John Stultz <john.stultz@linaro.org> wrote:
>
> Clang complains when initializing unions using "= {0}"
> so instead use memset.
>
> Cc: Emil Velikov <emil.velikov@collabora.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Alistair Strachan <astrachan@google.com>
> Cc: Marissa Wall <marissaw@google.com>
> Signed-off-by: John Stultz <john.stultz@linaro.org>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Do you have commit rights?

Alex

> ---
>  amdgpu/amdgpu_cs.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
> index 7ee844f..7c5b9d1 100644
> --- a/amdgpu/amdgpu_cs.c
> +++ b/amdgpu/amdgpu_cs.c
> @@ -733,12 +733,13 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
>                                     struct drm_amdgpu_cs_chunk *chunks,
>                                     uint64_t *seq_no)
>  {
> -       union drm_amdgpu_cs cs = {0};
> +       union drm_amdgpu_cs cs;
>         uint64_t *chunk_array;
>         int i, r;
>         if (num_chunks == 0)
>                 return -EINVAL;
>
> +       memset(&cs, 0, sizeof(cs));
>         chunk_array = alloca(sizeof(uint64_t) * num_chunks);
>         for (i = 0; i < num_chunks; i++)
>                 chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
> @@ -763,10 +764,11 @@ drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
>                                      struct drm_amdgpu_cs_chunk *chunks,
>                                      uint64_t *seq_no)
>  {
> -       union drm_amdgpu_cs cs = {0};
> +       union drm_amdgpu_cs cs;
>         uint64_t *chunk_array;
>         int i, r;
>
> +       memset(&cs, 0, sizeof(cs));
>         chunk_array = alloca(sizeof(uint64_t) * num_chunks);
>         for (i = 0; i < num_chunks; i++)
>                 chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
> @@ -803,9 +805,10 @@ drm_public int amdgpu_cs_fence_to_handle(amdgpu_device_handle dev,
>                                          uint32_t what,
>                                          uint32_t *out_handle)
>  {
> -       union drm_amdgpu_fence_to_handle fth = {0};
> +       union drm_amdgpu_fence_to_handle fth;
>         int r;
>
> +       memset(&fth, 0, sizeof(fth));
>         fth.in.fence.ctx_id = fence->context->id;
>         fth.in.fence.ip_type = fence->ip_type;
>         fth.in.fence.ip_instance = fence->ip_instance;
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
John Stultz April 22, 2019, 6:35 p.m. UTC | #2
On Mon, Apr 22, 2019 at 7:59 AM Alex Deucher <alexdeucher@gmail.com> wrote:
> On Sat, Apr 20, 2019 at 12:25 AM John Stultz <john.stultz@linaro.org> wrote:
> >
> > Clang complains when initializing unions using "= {0}"
> > so instead use memset.
> >
> > Cc: Emil Velikov <emil.velikov@collabora.com>
> > Cc: Sean Paul <seanpaul@chromium.org>
> > Cc: Alistair Strachan <astrachan@google.com>
> > Cc: Marissa Wall <marissaw@google.com>
> > Signed-off-by: John Stultz <john.stultz@linaro.org>
>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Thanks for the review!

> Do you have commit rights?

I don't.

thanks again,
-john
Emil Velikov April 23, 2019, 10:13 a.m. UTC | #3
On Sat, 20 Apr 2019 at 05:25, John Stultz <john.stultz@linaro.org> wrote:
>
> Clang complains when initializing unions using "= {0}"
> so instead use memset.
>
> Cc: Emil Velikov <emil.velikov@collabora.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Alistair Strachan <astrachan@google.com>
> Cc: Marissa Wall <marissaw@google.com>
> Signed-off-by: John Stultz <john.stultz@linaro.org>

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

-Emil
Christian König April 23, 2019, 12:51 p.m. UTC | #4
Am 22.04.19 um 20:35 schrieb John Stultz:
> On Mon, Apr 22, 2019 at 7:59 AM Alex Deucher <alexdeucher@gmail.com> wrote:
>> On Sat, Apr 20, 2019 at 12:25 AM John Stultz <john.stultz@linaro.org> wrote:
>>> Clang complains when initializing unions using "= {0}"
>>> so instead use memset.
>>>
>>> Cc: Emil Velikov <emil.velikov@collabora.com>
>>> Cc: Sean Paul <seanpaul@chromium.org>
>>> Cc: Alistair Strachan <astrachan@google.com>
>>> Cc: Marissa Wall <marissaw@google.com>
>>> Signed-off-by: John Stultz <john.stultz@linaro.org>
>> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> Thanks for the review!

Reviewed-by: Christian König <christian.koenig@amd.com>

We should probably do the same thing for the kernel as well.

>
>> Do you have commit rights?

We will take care of getting this committed then.

Christian.

> I don't.
>
> thanks again,
> -john
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 7ee844f..7c5b9d1 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -733,12 +733,13 @@  drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
 				    struct drm_amdgpu_cs_chunk *chunks,
 				    uint64_t *seq_no)
 {
-	union drm_amdgpu_cs cs = {0};
+	union drm_amdgpu_cs cs;
 	uint64_t *chunk_array;
 	int i, r;
 	if (num_chunks == 0)
 		return -EINVAL;
 
+	memset(&cs, 0, sizeof(cs));
 	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
 	for (i = 0; i < num_chunks; i++)
 		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
@@ -763,10 +764,11 @@  drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
 				     struct drm_amdgpu_cs_chunk *chunks,
 				     uint64_t *seq_no)
 {
-	union drm_amdgpu_cs cs = {0};
+	union drm_amdgpu_cs cs;
 	uint64_t *chunk_array;
 	int i, r;
 
+	memset(&cs, 0, sizeof(cs));
 	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
 	for (i = 0; i < num_chunks; i++)
 		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
@@ -803,9 +805,10 @@  drm_public int amdgpu_cs_fence_to_handle(amdgpu_device_handle dev,
 					 uint32_t what,
 					 uint32_t *out_handle)
 {
-	union drm_amdgpu_fence_to_handle fth = {0};
+	union drm_amdgpu_fence_to_handle fth;
 	int r;
 
+	memset(&fth, 0, sizeof(fth));
 	fth.in.fence.ctx_id = fence->context->id;
 	fth.in.fence.ip_type = fence->ip_type;
 	fth.in.fence.ip_instance = fence->ip_instance;