Re: [PATCH 6/9] drm: use c99 initializers in structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 23, 2014 at 01:20:28PM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@xxxxxxx>
> 
> Use c99 initializers for structures.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @decl@
> identifier i1,fld;
> type T;
> field list[n] fs;
> @@
> 
> struct i1 {
>  fs
>  T fld;
>  ...};
> 
> @bad@
> identifier decl.i1,i2;
> expression e;
> initializer list[decl.n] is;
> @@
> 
> struct i1 i2 = { is,
> + .fld = e
> - e
>  ,...};
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@xxxxxxx>

For this patch, I think it would make sense to drop
initializations of preferred/quirks/modes to 0, since a designated
initializer may skip fields to leave them initialized to 0.

With that change:
Reviewed-by: Josh Triplett <josh@xxxxxxxxxxxxxxxx>

> 
>  drivers/gpu/drm/sti/sti_vtac.c |   12 ++++++++++--
>  drivers/gpu/drm/drm_edid.c     |   34 +++++++++++++++++++++++++---------
>  2 files changed, 35 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sti/sti_vtac.c b/drivers/gpu/drm/sti/sti_vtac.c
> index 82a51d4..4576536 100644
> --- a/drivers/gpu/drm/sti/sti_vtac.c
> +++ b/drivers/gpu/drm/sti/sti_vtac.c
> @@ -56,8 +56,16 @@ struct sti_vtac_mode {
>  	u32 phyts_per_pixel;
>  };
>  
> -static const struct sti_vtac_mode vtac_mode_main = {0x2, 0x2, VTAC_5_PPP};
> -static const struct sti_vtac_mode vtac_mode_aux = {0x1, 0x0, VTAC_17_PPP};
> +static const struct sti_vtac_mode vtac_mode_main = {
> +	.vid_in_width = 0x2,
> +	.phyts_width = 0x2,
> +	.phyts_per_pixel = VTAC_5_PPP
> +};
> +static const struct sti_vtac_mode vtac_mode_aux = {
> +	.vid_in_width = 0x1,
> +	.phyts_width = 0x0,
> +	.phyts_per_pixel = VTAC_17_PPP
> +};
>  
>  /**
>   * VTAC structure
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 1dbf3bc..a28c330 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2103,7 +2103,11 @@ static int
>  add_inferred_modes(struct drm_connector *connector, struct edid *edid)
>  {
>  	struct detailed_mode_closure closure = {
> -		connector, edid, 0, 0, 0
> +		.connector = connector,
> +		.edid = edid,
> +		.preferred = 0,
> +		.quirks = 0,
> +		.modes = 0
>  	};
>  
>  	if (version_greater(edid, 1, 0))
> @@ -2169,7 +2173,11 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
>  		((edid->established_timings.mfg_rsvd & 0x80) << 9);
>  	int i, modes = 0;
>  	struct detailed_mode_closure closure = {
> -		connector, edid, 0, 0, 0
> +		.connector = connector,
> +		.edid = edid,
> +		.preferred = 0,
> +		.quirks = 0,
> +		.modes = 0
>  	};
>  
>  	for (i = 0; i <= EDID_EST_TIMINGS; i++) {
> @@ -2227,7 +2235,11 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
>  {
>  	int i, modes = 0;
>  	struct detailed_mode_closure closure = {
> -		connector, edid, 0, 0, 0
> +		.connector = connector,
> +		.edid = edid,
> +		.preferred = 0,
> +		.quirks = 0,
> +		.modes = 0
>  	};
>  
>  	for (i = 0; i < EDID_STD_TIMINGS; i++) {
> @@ -2313,7 +2325,11 @@ static int
>  add_cvt_modes(struct drm_connector *connector, struct edid *edid)
>  {	
>  	struct detailed_mode_closure closure = {
> -		connector, edid, 0, 0, 0
> +		.connector = connector,
> +		.edid = edid,
> +		.preferred = 0,
> +		.quirks = 0,
> +		.modes = 0
>  	};
>  
>  	if (version_greater(edid, 1, 2))
> @@ -2357,11 +2373,11 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
>  		   u32 quirks)
>  {
>  	struct detailed_mode_closure closure = {
> -		connector,
> -		edid,
> -		1,
> -		quirks,
> -		0
> +		.connector = connector,
> +		.edid = edid,
> +		.preferred = 1,
> +		.quirks = quirks,
> +		.modes = 0
>  	};
>  
>  	if (closure.preferred && !version_greater(edid, 1, 3))
> 
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux