linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drm_dp_mst_topology.c and old compilers
@ 2020-02-20  0:42 Paul E. McKenney
  2020-02-20  2:52 ` Alex Deucher
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Paul E. McKenney @ 2020-02-20  0:42 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, airlied, daniel; +Cc: dri-devel, linux-kernel

Hello!

A box with GCC 4.8.3 compiler didn't like drm_dp_mst_topology.c.  The
following (lightly tested) patch makes it happy and seems OK for newer
compilers as well.

Is this of interest?

							Thanx, Paul

-----------------------------------------------------------------------

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 20cdaf3..232408a 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -5396,7 +5396,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)
 {
 	struct drm_dp_mst_port *immediate_upstream_port;
 	struct drm_dp_mst_port *fec_port;
-	struct drm_dp_desc desc = { 0 };
+	struct drm_dp_desc desc = {{{ 0 }}};
 	u8 endpoint_fec;
 	u8 endpoint_dsc;
 

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

* Re: drm_dp_mst_topology.c and old compilers
  2020-02-20  0:42 drm_dp_mst_topology.c and old compilers Paul E. McKenney
@ 2020-02-20  2:52 ` Alex Deucher
  2020-02-20  7:58   ` Chris Wilson
  2020-02-20 11:59 ` Joe Perches
  2020-02-20 15:07 ` Christoph Hellwig
  2 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2020-02-20  2:52 UTC (permalink / raw)
  To: paulmck
  Cc: Maarten Lankhorst, Maxime Ripard, Dave Airlie, Daniel Vetter,
	LKML, Maling list - DRI developers

On Wed, Feb 19, 2020 at 7:42 PM Paul E. McKenney <paulmck@kernel.org> wrote:
>
> Hello!
>
> A box with GCC 4.8.3 compiler didn't like drm_dp_mst_topology.c.  The
> following (lightly tested) patch makes it happy and seems OK for newer
> compilers as well.
>
> Is this of interest?

How about a memset instead?  That should be consistent across compilers.

Alex


>
>                                                         Thanx, Paul
>
> -----------------------------------------------------------------------
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 20cdaf3..232408a 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -5396,7 +5396,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)
>  {
>         struct drm_dp_mst_port *immediate_upstream_port;
>         struct drm_dp_mst_port *fec_port;
> -       struct drm_dp_desc desc = { 0 };
> +       struct drm_dp_desc desc = {{{ 0 }}};
>         u8 endpoint_fec;
>         u8 endpoint_dsc;
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: drm_dp_mst_topology.c and old compilers
  2020-02-20  2:52 ` Alex Deucher
@ 2020-02-20  7:58   ` Chris Wilson
  2020-02-20 18:36     ` Paul E. McKenney
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Wilson @ 2020-02-20  7:58 UTC (permalink / raw)
  To: Alex Deucher, paulmck; +Cc: Dave Airlie, LKML, Maling list - DRI developers

Quoting Alex Deucher (2020-02-20 02:52:32)
> On Wed, Feb 19, 2020 at 7:42 PM Paul E. McKenney <paulmck@kernel.org> wrote:
> >
> > Hello!
> >
> > A box with GCC 4.8.3 compiler didn't like drm_dp_mst_topology.c.  The
> > following (lightly tested) patch makes it happy and seems OK for newer
> > compilers as well.
> >
> > Is this of interest?
> 
> How about a memset instead?  That should be consistent across compilers.

The kernel has adopted the gccism: struct drm_dp_desc desc = {};
git grep '= {}' | wc -l: 2046
git grep '= { }' | wc -l: 694
-Chris

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

* Re: drm_dp_mst_topology.c and old compilers
  2020-02-20  0:42 drm_dp_mst_topology.c and old compilers Paul E. McKenney
  2020-02-20  2:52 ` Alex Deucher
@ 2020-02-20 11:59 ` Joe Perches
  2020-02-20 15:07 ` Christoph Hellwig
  2 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2020-02-20 11:59 UTC (permalink / raw)
  To: paulmck, maarten.lankhorst, mripard, airlied, daniel
  Cc: dri-devel, linux-kernel

On Wed, 2020-02-19 at 16:42 -0800, Paul E. McKenney wrote:
> Hello!
> 
> A box with GCC 4.8.3 compiler didn't like drm_dp_mst_topology.c.  The
> following (lightly tested) patch makes it happy and seems OK for newer
> compilers as well.
> 
> Is this of interest?
[]
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
[]
> @@ -5396,7 +5396,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)
>  {
>  	struct drm_dp_mst_port *immediate_upstream_port;
>  	struct drm_dp_mst_port *fec_port;
> -	struct drm_dp_desc desc = { 0 };
> +	struct drm_dp_desc desc = {{{ 0 }}};

Perhaps this is simpler as:

	struct drm_dp_desc desc = {};



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

* Re: drm_dp_mst_topology.c and old compilers
  2020-02-20  0:42 drm_dp_mst_topology.c and old compilers Paul E. McKenney
  2020-02-20  2:52 ` Alex Deucher
  2020-02-20 11:59 ` Joe Perches
@ 2020-02-20 15:07 ` Christoph Hellwig
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2020-02-20 15:07 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: maarten.lankhorst, mripard, airlied, daniel, dri-devel, linux-kernel

On Wed, Feb 19, 2020 at 04:42:33PM -0800, Paul E. McKenney wrote:
> -	struct drm_dp_desc desc = { 0 };
> +	struct drm_dp_desc desc = {{{ 0 }}};

Does:

	struct drm_dp_desc desc = { };

work for your geriatric compiler?

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

* Re: drm_dp_mst_topology.c and old compilers
  2020-02-20  7:58   ` Chris Wilson
@ 2020-02-20 18:36     ` Paul E. McKenney
  0 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2020-02-20 18:36 UTC (permalink / raw)
  To: Chris Wilson
  Cc: Alex Deucher, Dave Airlie, LKML, Maling list - DRI developers

On Thu, Feb 20, 2020 at 07:58:58AM +0000, Chris Wilson wrote:
> Quoting Alex Deucher (2020-02-20 02:52:32)
> > On Wed, Feb 19, 2020 at 7:42 PM Paul E. McKenney <paulmck@kernel.org> wrote:
> > >
> > > Hello!
> > >
> > > A box with GCC 4.8.3 compiler didn't like drm_dp_mst_topology.c.  The
> > > following (lightly tested) patch makes it happy and seems OK for newer
> > > compilers as well.
> > >
> > > Is this of interest?
> > 
> > How about a memset instead?  That should be consistent across compilers.
> 
> The kernel has adopted the gccism: struct drm_dp_desc desc = {};
> git grep '= {}' | wc -l: 2046
> git grep '= { }' | wc -l: 694
> -Chris

And this works well, a big "thank you!" to all three of you!

Please see below for the updated patch.

							Thanx, Paul

------------------------------------------------------------------------

commit 78c0e53a98a9772a99e46806f8fcbe1140d667a4
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Wed Feb 19 16:42:47 2020 -0800

    EXP drm: Make drm_dp_mst_dsc_aux_for_port() safe for old compilers
    
    Older compilers either want two extra pairs of curly braces around the
    initializer for local variable desc, or they want a single pair of curly
    braces with nothing inside.  Current Linux-kernel practice favors the
    latter, so this commit makes it so.
    
    Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
    Suggested-by: Joe Perches <joe@perches.com>
    Suggested-by: Christoph Hellwig <hch@infradead.org>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 20cdaf3..b123f60 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -5396,7 +5396,7 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port)
 {
 	struct drm_dp_mst_port *immediate_upstream_port;
 	struct drm_dp_mst_port *fec_port;
-	struct drm_dp_desc desc = { 0 };
+	struct drm_dp_desc desc = { };
 	u8 endpoint_fec;
 	u8 endpoint_dsc;
 

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

end of thread, other threads:[~2020-02-20 18:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20  0:42 drm_dp_mst_topology.c and old compilers Paul E. McKenney
2020-02-20  2:52 ` Alex Deucher
2020-02-20  7:58   ` Chris Wilson
2020-02-20 18:36     ` Paul E. McKenney
2020-02-20 11:59 ` Joe Perches
2020-02-20 15:07 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).