[PATCH libdrm] amdgpu: Fix a structure initialization issue

Pan, Xinhui Xinhui.Pan at amd.com
Fri Apr 12 05:40:54 UTC 2019


Thanks.
After googling it, the behavior of {0} on local variable depends on compiler.


From: Deucher, Alexander <Alexander.Deucher at amd.com>
Sent: 2019年4月11日 22:16
To: Zhang, Hawking <Hawking.Zhang at amd.com>; Pan, Xinhui <Xinhui.Pan at amd.com>; amd-gfx at lists.freedesktop.org
Subject: Re: [PATCH libdrm] amdgpu: Fix a structure initialization issue

Please use memset rather than {0}.  Apparently some compilers don't like that.

Alex
________________________________
From: Zhang, Hawking
Sent: Thursday, April 11, 2019 9:24 AM
To: Pan, Xinhui; amd-gfx at lists.freedesktop.org<mailto:amd-gfx at lists.freedesktop.org>
Cc: Deucher, Alexander
Subject: RE: [PATCH libdrm] amdgpu: Fix a structure initialization issue

Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com<mailto:Hawking.Zhang at amd.com>>

Regards,
Hawking
-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org<mailto:amd-gfx-bounces at lists.freedesktop.org>> On Behalf Of Pan, Xinhui
Sent: 2019年4月11日 19:42
To: amd-gfx at lists.freedesktop.org<mailto:amd-gfx at lists.freedesktop.org>
Cc: Deucher, Alexander <Alexander.Deucher at amd.com<mailto:Alexander.Deucher at amd.com>>
Subject: [PATCH libdrm] amdgpu: Fix a structure initialization issue

struct drmPciBusInfo has been aligned to 6 bytes. So memcmp will access the last byte which is not initialized. That causes the lookup function fails.

Signed-off-by: xinhui pan <xinhui.pan at amd.com<mailto:xinhui.pan at amd.com>>
---
 tests/amdgpu/ras_tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/amdgpu/ras_tests.c b/tests/amdgpu/ras_tests.c index 612ad1d7..ebe774fc 100644
--- a/tests/amdgpu/ras_tests.c
+++ b/tests/amdgpu/ras_tests.c
@@ -190,7 +190,7 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device)  {
         char path[1024];
         char str[128];
-       drmPciBusInfo info;
+       drmPciBusInfo info = {0};
         int i;
         int ret;

--
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org<mailto:amd-gfx at lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20190412/7940869a/attachment.html>


More information about the amd-gfx mailing list