All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
@ 2018-09-12  0:25 Nathan Chancellor
  2018-09-12 17:38 ` Nick Desaulniers
  0 siblings, 1 reply; 11+ messages in thread
From: Nathan Chancellor @ 2018-09-12  0:25 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou
  Cc: amd-gfx, dri-devel, linux-kernel, Nick Desaulniers, Nathan Chancellor

Clang warns if there are missing braces around a subobject
initializer.

drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
around initialization of subobject [-Wmissing-braces]
                struct amdgpu_task_info task_info = { 0 };
                                                      ^
                                                      {}
1 warning generated.

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
around initialization of subobject [-Wmissing-braces]
                struct amdgpu_task_info task_info = { 0 };
                                                      ^
                                                      {}
1 warning generated.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 9333109b210d..968cc1b8cdff 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
 		gmc_v8_0_set_fault_enable_default(adev, false);
 
 	if (printk_ratelimit()) {
-		struct amdgpu_task_info task_info = { 0 };
+		struct amdgpu_task_info task_info = { { 0 } };
 
 		amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 72f8018fa2a8..a781a5027212 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
 	}
 
 	if (printk_ratelimit()) {
-		struct amdgpu_task_info task_info = { 0 };
+		struct amdgpu_task_info task_info = { { 0 } };
 
 		amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
 
-- 
2.18.0


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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
  2018-09-12  0:25 [PATCH] drm/amdgpu: Add braces to initialize task_info subojects Nathan Chancellor
@ 2018-09-12 17:38 ` Nick Desaulniers
  2018-09-12 18:38   ` Nathan Chancellor
       [not found]   ` <CAKwvOdkMg_1JxVNhKrUM0CZxF6nQo8c5h7t4zu4RP2xEXyQdKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 2 replies; 11+ messages in thread
From: Nick Desaulniers @ 2018-09-12 17:38 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: alexander.deucher, christian.koenig, David1.Zhou, amd-gfx,
	dri-devel, LKML, Richard Smith

On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns if there are missing braces around a subobject
> initializer.
>
> drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> around initialization of subobject [-Wmissing-braces]
>                 struct amdgpu_task_info task_info = { 0 };
>                                                       ^
>                                                       {}
> 1 warning generated.
>
> drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> around initialization of subobject [-Wmissing-braces]
>                 struct amdgpu_task_info task_info = { 0 };
>                                                       ^
>                                                       {}
> 1 warning generated.
>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
>  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> index 9333109b210d..968cc1b8cdff 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
>                 gmc_v8_0_set_fault_enable_default(adev, false);
>
>         if (printk_ratelimit()) {
> -               struct amdgpu_task_info task_info = { 0 };
> +               struct amdgpu_task_info task_info = { { 0 } };

Hi Nathan,
Thanks for this patch.  I discussed this syntax with our language
lawyers.  Turns out, this is not quite correct, as you're now saying
"initialize the first subobject to zero, but not the rest of the
object."  -Wmissing-field-initializers would highlight this, but it's
not part of -Wall.  It would be more correct to zero initialize the
full struct, including all of its subobjects with `= {};`.

>
>                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index 72f8018fa2a8..a781a5027212 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
>         }
>
>         if (printk_ratelimit()) {
> -               struct amdgpu_task_info task_info = { 0 };
> +               struct amdgpu_task_info task_info = { { 0 } };
>
>                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
>
> --
> 2.18.0
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
  2018-09-12 17:38 ` Nick Desaulniers
@ 2018-09-12 18:38   ` Nathan Chancellor
  2018-09-12 18:44       ` Alex Deucher
       [not found]   ` <CAKwvOdkMg_1JxVNhKrUM0CZxF6nQo8c5h7t4zu4RP2xEXyQdKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 11+ messages in thread
From: Nathan Chancellor @ 2018-09-12 18:38 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: alexander.deucher, christian.koenig, David1.Zhou, amd-gfx,
	dri-devel, LKML, Richard Smith

On Wed, Sep 12, 2018 at 10:38:30AM -0700, Nick Desaulniers wrote:
> On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang warns if there are missing braces around a subobject
> > initializer.
> >
> > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> > around initialization of subobject [-Wmissing-braces]
> >                 struct amdgpu_task_info task_info = { 0 };
> >                                                       ^
> >                                                       {}
> > 1 warning generated.
> >
> > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> > around initialization of subobject [-Wmissing-braces]
> >                 struct amdgpu_task_info task_info = { 0 };
> >                                                       ^
> >                                                       {}
> > 1 warning generated.
> >
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > index 9333109b210d..968cc1b8cdff 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
> >                 gmc_v8_0_set_fault_enable_default(adev, false);
> >
> >         if (printk_ratelimit()) {
> > -               struct amdgpu_task_info task_info = { 0 };
> > +               struct amdgpu_task_info task_info = { { 0 } };
> 
> Hi Nathan,
> Thanks for this patch.  I discussed this syntax with our language
> lawyers.  Turns out, this is not quite correct, as you're now saying
> "initialize the first subobject to zero, but not the rest of the
> object."  -Wmissing-field-initializers would highlight this, but it's
> not part of -Wall.  It would be more correct to zero initialize the
> full struct, including all of its subobjects with `= {};`.
> 

Good point, I was debating on which one was correct. There are several
places in this driver that use the multiple brace + 0 idiom, which is
why I used this form. I will spin up a v2 with your suggestion, thank
you for the review!

Nathan

> >
> >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > index 72f8018fa2a8..a781a5027212 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
> >         }
> >
> >         if (printk_ratelimit()) {
> > -               struct amdgpu_task_info task_info = { 0 };
> > +               struct amdgpu_task_info task_info = { { 0 } };
> >
> >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> >
> > --
> > 2.18.0
> >
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
  2018-09-12 18:38   ` Nathan Chancellor
@ 2018-09-12 18:44       ` Alex Deucher
  0 siblings, 0 replies; 11+ messages in thread
From: Alex Deucher @ 2018-09-12 18:44 UTC (permalink / raw)
  To: natechancellor
  Cc: ndesaulniers, Chunming Zhou, LKML, Maling list - DRI developers,
	richardsmith, amd-gfx list, Deucher, Alexander, Christian Koenig

On Wed, Sep 12, 2018 at 2:40 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Wed, Sep 12, 2018 at 10:38:30AM -0700, Nick Desaulniers wrote:
> > On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> > <natechancellor@gmail.com> wrote:
> > >
> > > Clang warns if there are missing braces around a subobject
> > > initializer.
> > >
> > > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> > > around initialization of subobject [-Wmissing-braces]
> > >                 struct amdgpu_task_info task_info = { 0 };
> > >                                                       ^
> > >                                                       {}
> > > 1 warning generated.
> > >
> > > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> > > around initialization of subobject [-Wmissing-braces]
> > >                 struct amdgpu_task_info task_info = { 0 };
> > >                                                       ^
> > >                                                       {}
> > > 1 warning generated.
> > >
> > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> > >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > index 9333109b210d..968cc1b8cdff 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
> > >                 gmc_v8_0_set_fault_enable_default(adev, false);
> > >
> > >         if (printk_ratelimit()) {
> > > -               struct amdgpu_task_info task_info = { 0 };
> > > +               struct amdgpu_task_info task_info = { { 0 } };
> >
> > Hi Nathan,
> > Thanks for this patch.  I discussed this syntax with our language
> > lawyers.  Turns out, this is not quite correct, as you're now saying
> > "initialize the first subobject to zero, but not the rest of the
> > object."  -Wmissing-field-initializers would highlight this, but it's
> > not part of -Wall.  It would be more correct to zero initialize the
> > full struct, including all of its subobjects with `= {};`.
> >
>
> Good point, I was debating on which one was correct. There are several
> places in this driver that use the multiple brace + 0 idiom, which is
> why I used this form. I will spin up a v2 with your suggestion, thank
> you for the review!

Feel free to fix up the others as well. The others were only changed
due to the same warning you sent the patch for.

Alex

>
> Nathan
>
> > >
> > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > index 72f8018fa2a8..a781a5027212 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
> > >         }
> > >
> > >         if (printk_ratelimit()) {
> > > -               struct amdgpu_task_info task_info = { 0 };
> > > +               struct amdgpu_task_info task_info = { { 0 } };
> > >
> > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > >
> > > --
> > > 2.18.0
> > >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
@ 2018-09-12 18:44       ` Alex Deucher
  0 siblings, 0 replies; 11+ messages in thread
From: Alex Deucher @ 2018-09-12 18:44 UTC (permalink / raw)
  To: natechancellor-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Chunming Zhou, ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA, LKML,
	amd-gfx list, Christian Koenig, Maling list - DRI developers,
	Deucher, Alexander, richardsmith-hpIqsD4AKlfQT0dZR+AlfA

On Wed, Sep 12, 2018 at 2:40 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> On Wed, Sep 12, 2018 at 10:38:30AM -0700, Nick Desaulniers wrote:
> > On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> > <natechancellor@gmail.com> wrote:
> > >
> > > Clang warns if there are missing braces around a subobject
> > > initializer.
> > >
> > > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> > > around initialization of subobject [-Wmissing-braces]
> > >                 struct amdgpu_task_info task_info = { 0 };
> > >                                                       ^
> > >                                                       {}
> > > 1 warning generated.
> > >
> > > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> > > around initialization of subobject [-Wmissing-braces]
> > >                 struct amdgpu_task_info task_info = { 0 };
> > >                                                       ^
> > >                                                       {}
> > > 1 warning generated.
> > >
> > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> > >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > index 9333109b210d..968cc1b8cdff 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
> > >                 gmc_v8_0_set_fault_enable_default(adev, false);
> > >
> > >         if (printk_ratelimit()) {
> > > -               struct amdgpu_task_info task_info = { 0 };
> > > +               struct amdgpu_task_info task_info = { { 0 } };
> >
> > Hi Nathan,
> > Thanks for this patch.  I discussed this syntax with our language
> > lawyers.  Turns out, this is not quite correct, as you're now saying
> > "initialize the first subobject to zero, but not the rest of the
> > object."  -Wmissing-field-initializers would highlight this, but it's
> > not part of -Wall.  It would be more correct to zero initialize the
> > full struct, including all of its subobjects with `= {};`.
> >
>
> Good point, I was debating on which one was correct. There are several
> places in this driver that use the multiple brace + 0 idiom, which is
> why I used this form. I will spin up a v2 with your suggestion, thank
> you for the review!

Feel free to fix up the others as well. The others were only changed
due to the same warning you sent the patch for.

Alex

>
> Nathan
>
> > >
> > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > index 72f8018fa2a8..a781a5027212 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
> > >         }
> > >
> > >         if (printk_ratelimit()) {
> > > -               struct amdgpu_task_info task_info = { 0 };
> > > +               struct amdgpu_task_info task_info = { { 0 } };
> > >
> > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > >
> > > --
> > > 2.18.0
> > >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
  2018-09-12 18:44       ` Alex Deucher
@ 2018-09-12 18:45         ` Nathan Chancellor
  -1 siblings, 0 replies; 11+ messages in thread
From: Nathan Chancellor @ 2018-09-12 18:45 UTC (permalink / raw)
  To: Alex Deucher
  Cc: ndesaulniers, Chunming Zhou, LKML, Maling list - DRI developers,
	richardsmith, amd-gfx list, Deucher, Alexander, Christian Koenig

On Wed, Sep 12, 2018 at 02:44:34PM -0400, Alex Deucher wrote:
> On Wed, Sep 12, 2018 at 2:40 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > On Wed, Sep 12, 2018 at 10:38:30AM -0700, Nick Desaulniers wrote:
> > > On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> > > <natechancellor@gmail.com> wrote:
> > > >
> > > > Clang warns if there are missing braces around a subobject
> > > > initializer.
> > > >
> > > > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> > > > around initialization of subobject [-Wmissing-braces]
> > > >                 struct amdgpu_task_info task_info = { 0 };
> > > >                                                       ^
> > > >                                                       {}
> > > > 1 warning generated.
> > > >
> > > > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> > > > around initialization of subobject [-Wmissing-braces]
> > > >                 struct amdgpu_task_info task_info = { 0 };
> > > >                                                       ^
> > > >                                                       {}
> > > > 1 warning generated.
> > > >
> > > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > > ---
> > > >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> > > >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> > > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > > index 9333109b210d..968cc1b8cdff 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
> > > >                 gmc_v8_0_set_fault_enable_default(adev, false);
> > > >
> > > >         if (printk_ratelimit()) {
> > > > -               struct amdgpu_task_info task_info = { 0 };
> > > > +               struct amdgpu_task_info task_info = { { 0 } };
> > >
> > > Hi Nathan,
> > > Thanks for this patch.  I discussed this syntax with our language
> > > lawyers.  Turns out, this is not quite correct, as you're now saying
> > > "initialize the first subobject to zero, but not the rest of the
> > > object."  -Wmissing-field-initializers would highlight this, but it's
> > > not part of -Wall.  It would be more correct to zero initialize the
> > > full struct, including all of its subobjects with `= {};`.
> > >
> >
> > Good point, I was debating on which one was correct. There are several
> > places in this driver that use the multiple brace + 0 idiom, which is
> > why I used this form. I will spin up a v2 with your suggestion, thank
> > you for the review!
> 
> Feel free to fix up the others as well. The others were only changed
> due to the same warning you sent the patch for.
> 
> Alex
> 

Hi Alex,

Thank you for the information, I will do that in v2.

Thanks,
Nathan

> >
> > Nathan
> >
> > > >
> > > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > > >
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > > index 72f8018fa2a8..a781a5027212 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > > @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
> > > >         }
> > > >
> > > >         if (printk_ratelimit()) {
> > > > -               struct amdgpu_task_info task_info = { 0 };
> > > > +               struct amdgpu_task_info task_info = { { 0 } };
> > > >
> > > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > > >
> > > > --
> > > > 2.18.0
> > > >
> > >
> > >
> > > --
> > > Thanks,
> > > ~Nick Desaulniers
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
@ 2018-09-12 18:45         ` Nathan Chancellor
  0 siblings, 0 replies; 11+ messages in thread
From: Nathan Chancellor @ 2018-09-12 18:45 UTC (permalink / raw)
  To: Alex Deucher
  Cc: ndesaulniers, Chunming Zhou, LKML, Maling list - DRI developers,
	richardsmith, amd-gfx list, Deucher, Alexander, Christian Koenig

On Wed, Sep 12, 2018 at 02:44:34PM -0400, Alex Deucher wrote:
> On Wed, Sep 12, 2018 at 2:40 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > On Wed, Sep 12, 2018 at 10:38:30AM -0700, Nick Desaulniers wrote:
> > > On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> > > <natechancellor@gmail.com> wrote:
> > > >
> > > > Clang warns if there are missing braces around a subobject
> > > > initializer.
> > > >
> > > > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> > > > around initialization of subobject [-Wmissing-braces]
> > > >                 struct amdgpu_task_info task_info = { 0 };
> > > >                                                       ^
> > > >                                                       {}
> > > > 1 warning generated.
> > > >
> > > > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> > > > around initialization of subobject [-Wmissing-braces]
> > > >                 struct amdgpu_task_info task_info = { 0 };
> > > >                                                       ^
> > > >                                                       {}
> > > > 1 warning generated.
> > > >
> > > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > > ---
> > > >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> > > >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> > > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > > index 9333109b210d..968cc1b8cdff 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
> > > >                 gmc_v8_0_set_fault_enable_default(adev, false);
> > > >
> > > >         if (printk_ratelimit()) {
> > > > -               struct amdgpu_task_info task_info = { 0 };
> > > > +               struct amdgpu_task_info task_info = { { 0 } };
> > >
> > > Hi Nathan,
> > > Thanks for this patch.  I discussed this syntax with our language
> > > lawyers.  Turns out, this is not quite correct, as you're now saying
> > > "initialize the first subobject to zero, but not the rest of the
> > > object."  -Wmissing-field-initializers would highlight this, but it's
> > > not part of -Wall.  It would be more correct to zero initialize the
> > > full struct, including all of its subobjects with `= {};`.
> > >
> >
> > Good point, I was debating on which one was correct. There are several
> > places in this driver that use the multiple brace + 0 idiom, which is
> > why I used this form. I will spin up a v2 with your suggestion, thank
> > you for the review!
> 
> Feel free to fix up the others as well. The others were only changed
> due to the same warning you sent the patch for.
> 
> Alex
> 

Hi Alex,

Thank you for the information, I will do that in v2.

Thanks,
Nathan

> >
> > Nathan
> >
> > > >
> > > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > > >
> > > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > > index 72f8018fa2a8..a781a5027212 100644
> > > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > > @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev,
> > > >         }
> > > >
> > > >         if (printk_ratelimit()) {
> > > > -               struct amdgpu_task_info task_info = { 0 };
> > > > +               struct amdgpu_task_info task_info = { { 0 } };
> > > >
> > > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > > >
> > > > --
> > > > 2.18.0
> > > >
> > >
> > >
> > > --
> > > Thanks,
> > > ~Nick Desaulniers
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
       [not found]   ` <CAKwvOdkMg_1JxVNhKrUM0CZxF6nQo8c5h7t4zu4RP2xEXyQdKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2018-09-12 20:24     ` Richard Smith
  2018-09-12 20:30       ` Nathan Chancellor
  2018-09-12 23:13       ` Nick Desaulniers
  0 siblings, 2 replies; 11+ messages in thread
From: Richard Smith @ 2018-09-12 20:24 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: David1.Zhou-5C7GfCeVMHo, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo,
	natechancellor-Re5JQEeQqe8AvxtiuMwx3w,
	christian.koenig-5C7GfCeVMHo


[-- Attachment #1.1: Type: text/plain, Size: 3901 bytes --]

On Wed, Sep 12, 2018 at 10:38 AM Nick Desaulniers <ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
wrote:

> On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> <natechancellor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >
> > Clang warns if there are missing braces around a subobject
> > initializer.
> >
> > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> > around initialization of subobject [-Wmissing-braces]
> >                 struct amdgpu_task_info task_info = { 0 };
> >                                                       ^
> >                                                       {}
> > 1 warning generated.
> >
> > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> > around initialization of subobject [-Wmissing-braces]
> >                 struct amdgpu_task_info task_info = { 0 };
> >                                                       ^
> >                                                       {}
> > 1 warning generated.
> >
> > Reported-by: Nick Desaulniers <ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> > Signed-off-by: Nathan Chancellor <natechancellor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > index 9333109b210d..968cc1b8cdff 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct
> amdgpu_device *adev,
> >                 gmc_v8_0_set_fault_enable_default(adev, false);
> >
> >         if (printk_ratelimit()) {
> > -               struct amdgpu_task_info task_info = { 0 };
> > +               struct amdgpu_task_info task_info = { { 0 } };
>
> Hi Nathan,
> Thanks for this patch.  I discussed this syntax with our language
> lawyers.  Turns out, this is not quite correct, as you're now saying
> "initialize the first subobject to zero, but not the rest of the
> object."  -Wmissing-field-initializers would highlight this, but it's
> not part of -Wall.  It would be more correct to zero initialize the
> full struct, including all of its subobjects with `= {};`.
>

Sorry, I think I've caused some confusion here.

Elements with an omitted initializer get implicitly zero-initialized. In
C++, it's idiomatic to write `= {}` to perform aggregate
zero-initialization, but in C, that's invalid because at least one
initializer is syntactically required within the braces. As a result, `=
{0}` is an idiomatic way to perform zero-initialization of an aggregate in
C. Clang intends to suppress the -Wmissing-braces in that case; if the
warning is still being produced in a recent version of Clang, that's a bug.
However, the warning suppression was added between Clang 5 and Clang 6, so
it's very plausible that the compiler being used here is simply older than
the warning fix.

(Long story short: the change here seems fine, but should be unnecessary as
of Clang 6.)


> >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > index 72f8018fa2a8..a781a5027212 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct
> amdgpu_device *adev,
> >         }
> >
> >         if (printk_ratelimit()) {
> > -               struct amdgpu_task_info task_info = { 0 };
> > +               struct amdgpu_task_info task_info = { { 0 } };
> >
> >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> >
> > --
> > 2.18.0
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers
>

[-- Attachment #1.2: Type: text/html, Size: 5197 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
  2018-09-12 20:24     ` Richard Smith
@ 2018-09-12 20:30       ` Nathan Chancellor
  2018-09-12 23:13       ` Nick Desaulniers
  1 sibling, 0 replies; 11+ messages in thread
From: Nathan Chancellor @ 2018-09-12 20:30 UTC (permalink / raw)
  To: Richard Smith
  Cc: Nick Desaulniers, alexander.deucher, christian.koenig,
	David1.Zhou, amd-gfx, dri-devel, linux-kernel

On Wed, Sep 12, 2018 at 01:24:34PM -0700, Richard Smith wrote:
> On Wed, Sep 12, 2018 at 10:38 AM Nick Desaulniers <ndesaulniers@google.com>
> wrote:
> 
> > On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> > <natechancellor@gmail.com> wrote:
> > >
> > > Clang warns if there are missing braces around a subobject
> > > initializer.
> > >
> > > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> > > around initialization of subobject [-Wmissing-braces]
> > >                 struct amdgpu_task_info task_info = { 0 };
> > >                                                       ^
> > >                                                       {}
> > > 1 warning generated.
> > >
> > > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> > > around initialization of subobject [-Wmissing-braces]
> > >                 struct amdgpu_task_info task_info = { 0 };
> > >                                                       ^
> > >                                                       {}
> > > 1 warning generated.
> > >
> > > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> > >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > index 9333109b210d..968cc1b8cdff 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> > > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct
> > amdgpu_device *adev,
> > >                 gmc_v8_0_set_fault_enable_default(adev, false);
> > >
> > >         if (printk_ratelimit()) {
> > > -               struct amdgpu_task_info task_info = { 0 };
> > > +               struct amdgpu_task_info task_info = { { 0 } };
> >
> > Hi Nathan,
> > Thanks for this patch.  I discussed this syntax with our language
> > lawyers.  Turns out, this is not quite correct, as you're now saying
> > "initialize the first subobject to zero, but not the rest of the
> > object."  -Wmissing-field-initializers would highlight this, but it's
> > not part of -Wall.  It would be more correct to zero initialize the
> > full struct, including all of its subobjects with `= {};`.
> >
> 
> Sorry, I think I've caused some confusion here.
> 
> Elements with an omitted initializer get implicitly zero-initialized. In
> C++, it's idiomatic to write `= {}` to perform aggregate
> zero-initialization, but in C, that's invalid because at least one
> initializer is syntactically required within the braces. As a result, `=
> {0}` is an idiomatic way to perform zero-initialization of an aggregate in
> C. Clang intends to suppress the -Wmissing-braces in that case; if the
> warning is still being produced in a recent version of Clang, that's a bug.
> However, the warning suppression was added between Clang 5 and Clang 6, so
> it's very plausible that the compiler being used here is simply older than
> the warning fix.
> 
> (Long story short: the change here seems fine, but should be unnecessary as
> of Clang 6.)
> 

Interesting...

nathan@flashbox ~/kernels/next (master >) $ clang --version | head -n1
clang version 6.0.1 (tags/RELEASE_601/final)

I guess the v2 I sent is unnecessary then. I'll leave it up to the
maintainers to decide which one they want to take.

Thanks!
Nathan

> 
> > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > index 72f8018fa2a8..a781a5027212 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> > > @@ -259,7 +259,7 @@ static int gmc_v9_0_process_interrupt(struct
> > amdgpu_device *adev,
> > >         }
> > >
> > >         if (printk_ratelimit()) {
> > > -               struct amdgpu_task_info task_info = { 0 };
> > > +               struct amdgpu_task_info task_info = { { 0 } };
> > >
> > >                 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
> > >
> > > --
> > > 2.18.0
> > >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
> >

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
  2018-09-12 20:24     ` Richard Smith
  2018-09-12 20:30       ` Nathan Chancellor
@ 2018-09-12 23:13       ` Nick Desaulniers
       [not found]         ` <CAKwvOdkSy74TKqASdMtWwHKOeAVQn+mEfv0Fi8q+-35dGjXtHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 11+ messages in thread
From: Nick Desaulniers @ 2018-09-12 23:13 UTC (permalink / raw)
  To: Richard Smith
  Cc: Nathan Chancellor, alexander.deucher, christian.koenig,
	David1.Zhou, amd-gfx, dri-devel, LKML

On Wed, Sep 12, 2018 at 1:24 PM Richard Smith <richardsmith@google.com> wrote:
>
> On Wed, Sep 12, 2018 at 10:38 AM Nick Desaulniers <ndesaulniers@google.com> wrote:
>>
>> On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
>> <natechancellor@gmail.com> wrote:
>> >
>> > Clang warns if there are missing braces around a subobject
>> > initializer.
>> >
>> > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
>> > around initialization of subobject [-Wmissing-braces]
>> >                 struct amdgpu_task_info task_info = { 0 };
>> >                                                       ^
>> >                                                       {}
>> > 1 warning generated.
>> >
>> > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
>> > around initialization of subobject [-Wmissing-braces]
>> >                 struct amdgpu_task_info task_info = { 0 };
>> >                                                       ^
>> >                                                       {}
>> > 1 warning generated.
>> >
>> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
>> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>> > ---
>> >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
>> >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
>> >  2 files changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> > index 9333109b210d..968cc1b8cdff 100644
>> > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
>> > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
>> >                 gmc_v8_0_set_fault_enable_default(adev, false);
>> >
>> >         if (printk_ratelimit()) {
>> > -               struct amdgpu_task_info task_info = { 0 };
>> > +               struct amdgpu_task_info task_info = { { 0 } };
>>
>> Hi Nathan,
>> Thanks for this patch.  I discussed this syntax with our language
>> lawyers.  Turns out, this is not quite correct, as you're now saying
>> "initialize the first subobject to zero, but not the rest of the
>> object."  -Wmissing-field-initializers would highlight this, but it's
>> not part of -Wall.  It would be more correct to zero initialize the
>> full struct, including all of its subobjects with `= {};`.
>
>
> Sorry, I think I've caused some confusion here.
>
> Elements with an omitted initializer get implicitly zero-initialized. In C++, it's idiomatic to write `= {}` to perform aggregate zero-initialization, but in C, that's invalid because at least one initializer is syntactically required within the braces. As a result, `= {0}` is an idiomatic way to perform zero-initialization of an aggregate in C.

That doesn't seem to be the case:
https://godbolt.org/z/TZzfo6 shouldn't Clang warn in the case of bar()?

> Clang intends to suppress the -Wmissing-braces in that case; if the warning is still being produced in a recent version of Clang, that's a bug. However, the warning suppression was added between Clang 5 and Clang 6, so it's very plausible that the compiler being used here is simply older than the warning fix.
>
> (Long story short: the change here seems fine, but should be unnecessary as of Clang 6.)

The warning was identified from clang-8 ToT synced yesterday.

-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] drm/amdgpu: Add braces to initialize task_info subojects
       [not found]         ` <CAKwvOdkSy74TKqASdMtWwHKOeAVQn+mEfv0Fi8q+-35dGjXtHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2018-09-13 22:08           ` Richard Smith
  0 siblings, 0 replies; 11+ messages in thread
From: Richard Smith @ 2018-09-13 22:08 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: David1.Zhou-5C7GfCeVMHo, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	alexander.deucher-5C7GfCeVMHo, Nathan Chancellor,
	christian.koenig-5C7GfCeVMHo


[-- Attachment #1.1: Type: text/plain, Size: 4055 bytes --]

On Wed, Sep 12, 2018 at 4:13 PM Nick Desaulniers <ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
wrote:

> On Wed, Sep 12, 2018 at 1:24 PM Richard Smith <richardsmith-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> wrote:
> >
> > On Wed, Sep 12, 2018 at 10:38 AM Nick Desaulniers <
> ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> wrote:
> >>
> >> On Tue, Sep 11, 2018 at 5:26 PM Nathan Chancellor
> >> <natechancellor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> >> >
> >> > Clang warns if there are missing braces around a subobject
> >> > initializer.
> >> >
> >> > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c:1447:41: warning: suggest braces
> >> > around initialization of subobject [-Wmissing-braces]
> >> >                 struct amdgpu_task_info task_info = { 0 };
> >> >                                                       ^
> >> >                                                       {}
> >> > 1 warning generated.
> >> >
> >> > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c:262:41: warning: suggest braces
> >> > around initialization of subobject [-Wmissing-braces]
> >> >                 struct amdgpu_task_info task_info = { 0 };
> >> >                                                       ^
> >> >                                                       {}
> >> > 1 warning generated.
> >> >
> >> > Reported-by: Nick Desaulniers <ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> >> > Signed-off-by: Nathan Chancellor <natechancellor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> >> > ---
> >> >  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +-
> >> >  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +-
> >> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> >> > index 9333109b210d..968cc1b8cdff 100644
> >> > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> >> > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
> >> > @@ -1444,7 +1444,7 @@ static int gmc_v8_0_process_interrupt(struct
> amdgpu_device *adev,
> >> >                 gmc_v8_0_set_fault_enable_default(adev, false);
> >> >
> >> >         if (printk_ratelimit()) {
> >> > -               struct amdgpu_task_info task_info = { 0 };
> >> > +               struct amdgpu_task_info task_info = { { 0 } };
> >>
> >> Hi Nathan,
> >> Thanks for this patch.  I discussed this syntax with our language
> >> lawyers.  Turns out, this is not quite correct, as you're now saying
> >> "initialize the first subobject to zero, but not the rest of the
> >> object."  -Wmissing-field-initializers would highlight this, but it's
> >> not part of -Wall.  It would be more correct to zero initialize the
> >> full struct, including all of its subobjects with `= {};`.
> >
> >
> > Sorry, I think I've caused some confusion here.
> >
> > Elements with an omitted initializer get implicitly zero-initialized. In
> C++, it's idiomatic to write `= {}` to perform aggregate
> zero-initialization, but in C, that's invalid because at least one
> initializer is syntactically required within the braces. As a result, `=
> {0}` is an idiomatic way to perform zero-initialization of an aggregate in
> C.
>
> That doesn't seem to be the case:
> https://godbolt.org/z/TZzfo6 shouldn't Clang warn in the case of bar()?
>

This is a GNU extension. Use -pedantic-errors to turn off extensions, then
Clang and GCC reject bar(): https://godbolt.org/z/pIzI6M


> > Clang intends to suppress the -Wmissing-braces in that case; if the
> warning is still being produced in a recent version of Clang, that's a bug.
> However, the warning suppression was added between Clang 5 and Clang 6, so
> it's very plausible that the compiler being used here is simply older than
> the warning fix.
> >
> > (Long story short: the change here seems fine, but should be unnecessary
> as of Clang 6.)
>
> The warning was identified from clang-8 ToT synced yesterday.
>

Thanks for the testcase. This is a Clang bug. Apparently the warning
suppression only works when the first member is of type 'int'!
https://godbolt.org/z/sxnZvv

[-- Attachment #1.2: Type: text/html, Size: 5983 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2018-09-13 22:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12  0:25 [PATCH] drm/amdgpu: Add braces to initialize task_info subojects Nathan Chancellor
2018-09-12 17:38 ` Nick Desaulniers
2018-09-12 18:38   ` Nathan Chancellor
2018-09-12 18:44     ` Alex Deucher
2018-09-12 18:44       ` Alex Deucher
2018-09-12 18:45       ` Nathan Chancellor
2018-09-12 18:45         ` Nathan Chancellor
     [not found]   ` <CAKwvOdkMg_1JxVNhKrUM0CZxF6nQo8c5h7t4zu4RP2xEXyQdKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-12 20:24     ` Richard Smith
2018-09-12 20:30       ` Nathan Chancellor
2018-09-12 23:13       ` Nick Desaulniers
     [not found]         ` <CAKwvOdkSy74TKqASdMtWwHKOeAVQn+mEfv0Fi8q+-35dGjXtHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-13 22:08           ` Richard Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.