linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/komeda: Use memset to initialize config_id
@ 2019-04-25  6:27 Nathan Chancellor
  2019-04-25 17:25 ` Nick Desaulniers
  2019-04-26 10:10 ` Liviu Dudau
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-04-25  6:27 UTC (permalink / raw)
  To: James (Qian) Wang, Liviu Dudau, Brian Starkey
  Cc: malidp, dri-devel, linux-kernel, Nick Desaulniers,
	clang-built-linux, Nathan Chancellor

Clang warns:

drivers/gpu/drm/arm/display/komeda/komeda_dev.c:76:38: warning: suggest
braces around initialization of subobject [-Wmissing-braces]
        union komeda_config_id config_id = {0,};
                                            ^
                                            {}
1 warning generated.

One way to fix these warnings is to add additional braces like Clang
suggests; however, there has been a bit of push back from some
maintainers, who just prefer memset as it is unambiguous, doesn't
depend on a particular compiler version, and properly initializes all
subobjects [1][2]. Do that here so there are no more warnings.

[1]: https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
[2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/

Fixes: 4cc734cb79a8 ("drm/komeda: Add sysfs attribute: core_id and config_id")
Link: https://github.com/ClangBuiltLinux/linux/issues/457
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
index 9d6c31cca875..e605a518f59a 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
@@ -73,9 +73,10 @@ config_id_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct komeda_dev *mdev = dev_to_mdev(dev);
 	struct komeda_pipeline *pipe = mdev->pipelines[0];
-	union komeda_config_id config_id = {0,};
+	union komeda_config_id config_id;
 	int i;
 
+	memset(&config_id, 0, sizeof(config_id));
 	config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
 	config_id.n_pipelines = mdev->n_pipelines;
 	config_id.n_scalers = pipe->n_scalers;
-- 
2.21.0


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

* Re: [PATCH] drm/komeda: Use memset to initialize config_id
  2019-04-25  6:27 [PATCH] drm/komeda: Use memset to initialize config_id Nathan Chancellor
@ 2019-04-25 17:25 ` Nick Desaulniers
  2019-04-26 10:10 ` Liviu Dudau
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2019-04-25 17:25 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: James (Qian) Wang, Liviu Dudau, Brian Starkey, malidp, dri-devel,
	LKML, clang-built-linux

On Wed, Apr 24, 2019 at 11:27 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/gpu/drm/arm/display/komeda/komeda_dev.c:76:38: warning: suggest
> braces around initialization of subobject [-Wmissing-braces]
>         union komeda_config_id config_id = {0,};
>                                             ^
>                                             {}
> 1 warning generated.
>
> One way to fix these warnings is to add additional braces like Clang
> suggests; however, there has been a bit of push back from some
> maintainers, who just prefer memset as it is unambiguous, doesn't
> depend on a particular compiler version, and properly initializes all
> subobjects [1][2]. Do that here so there are no more warnings.
>
> [1]: https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
> [2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/
>
> Fixes: 4cc734cb79a8 ("drm/komeda: Add sysfs attribute: core_id and config_id")
> Link: https://github.com/ClangBuiltLinux/linux/issues/457
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 9d6c31cca875..e605a518f59a 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -73,9 +73,10 @@ config_id_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>         struct komeda_dev *mdev = dev_to_mdev(dev);
>         struct komeda_pipeline *pipe = mdev->pipelines[0];
> -       union komeda_config_id config_id = {0,};

Haven't seen a trailing comma too often.  Thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> +       union komeda_config_id config_id;
>         int i;
>
> +       memset(&config_id, 0, sizeof(config_id));
>         config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
>         config_id.n_pipelines = mdev->n_pipelines;
>         config_id.n_scalers = pipe->n_scalers;
> --
> 2.21.0
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] drm/komeda: Use memset to initialize config_id
  2019-04-25  6:27 [PATCH] drm/komeda: Use memset to initialize config_id Nathan Chancellor
  2019-04-25 17:25 ` Nick Desaulniers
@ 2019-04-26 10:10 ` Liviu Dudau
  1 sibling, 0 replies; 3+ messages in thread
From: Liviu Dudau @ 2019-04-26 10:10 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: James (Qian) Wang, Brian Starkey, malidp, dri-devel,
	linux-kernel, Nick Desaulniers, clang-built-linux

On Wed, Apr 24, 2019 at 11:27:20PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/gpu/drm/arm/display/komeda/komeda_dev.c:76:38: warning: suggest
> braces around initialization of subobject [-Wmissing-braces]
>         union komeda_config_id config_id = {0,};
>                                             ^
>                                             {}
> 1 warning generated.
> 
> One way to fix these warnings is to add additional braces like Clang
> suggests; however, there has been a bit of push back from some
> maintainers, who just prefer memset as it is unambiguous, doesn't
> depend on a particular compiler version, and properly initializes all
> subobjects [1][2]. Do that here so there are no more warnings.
> 
> [1]: https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
> [2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/
> 
> Fixes: 4cc734cb79a8 ("drm/komeda: Add sysfs attribute: core_id and config_id")
> Link: https://github.com/ClangBuiltLinux/linux/issues/457
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Acked-by: Liviu Dudau <liviu.dudau@arm.com>

I'll pull the patch into my tree today.

Best regards,
Liviu

> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 9d6c31cca875..e605a518f59a 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -73,9 +73,10 @@ config_id_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct komeda_dev *mdev = dev_to_mdev(dev);
>  	struct komeda_pipeline *pipe = mdev->pipelines[0];
> -	union komeda_config_id config_id = {0,};
> +	union komeda_config_id config_id;
>  	int i;
>  
> +	memset(&config_id, 0, sizeof(config_id));
>  	config_id.max_line_sz = pipe->layers[0]->hsize_in.end;
>  	config_id.n_pipelines = mdev->n_pipelines;
>  	config_id.n_scalers = pipe->n_scalers;
> -- 
> 2.21.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

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

end of thread, other threads:[~2019-04-26 10:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25  6:27 [PATCH] drm/komeda: Use memset to initialize config_id Nathan Chancellor
2019-04-25 17:25 ` Nick Desaulniers
2019-04-26 10:10 ` Liviu Dudau

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).