Skip to contentSkip to conversation

drm_dp_mst_topology.c and old compilers

PATCH Paul E. McKenney 5 participants 6 messages Feb 20, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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

drivers/gpu/drm/drm_dp_mst_topology.c +1 -1
index 20cdaf3..232408a 100644
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw
Quoted 8 lines · Paul E. McKenney

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

Quoted 18 lines

Thanx, Paul

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

drivers/gpu/drm/drm_dp_mst_topology.c +1 -1
index 20cdaf3..232408a 100644
@@ -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;
 
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Quoting Alex Deucher (2020-02-20 02:52:32)

Quoted 11 lines · Paul E. McKenney
Quoted 8 lines

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
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 9 lines · Chris Wilson

Quoting Alex Deucher (2020-02-20 02:52:32)

Quoted 8 lines · Paul E. McKenney
Quoted 7 lines

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.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

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 <[email protected]>
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.

drivers/gpu/drm/drm_dp_mst_topology.c +1 -1
index 20cdaf3..b123f60 100644
@@ -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;
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to Paul E. McKenney
Quoted 7 lines · Paul E. McKenney

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?

[]

drivers/gpu/drm/drm_dp_mst_topology.c

Quoted 1 line
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0

[]

drivers/gpu/drm/drm_dp_mst_topology.c struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) · line 5399

Quoted 6 lines
drivers/gpu/drm/drm_dp_mst_topology.c +1 -1
@@ -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 = {};
#5 lore raw
In reply to Paul E. McKenney

drivers/gpu/drm/drm_dp_mst_topology.c struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) · line 5399

Quoted 2 lines · Paul E. McKenney
drivers/gpu/drm/drm_dp_mst_topology.c +1 -1
-	struct drm_dp_desc desc = { 0 };
+	struct drm_dp_desc desc = {{{ 0 }}};

Does:

	struct drm_dp_desc desc = { };

work for your geriatric compiler?