devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: unneed to initialise statics to 0 or NULL
@ 2021-12-12  7:14 Jason Wang
  2021-12-15 20:07 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Wang @ 2021-12-12  7:14 UTC (permalink / raw)
  To: frowand.list; +Cc: robh+dt, devicetree, linux-kernel, Jason Wang

Static variables do not need to be initialised to 0 or NULL,
because compilers will initialise all uninitialised statics
to 0 or NULL. Thus, remove the unneeded initializations.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
---
 drivers/of/pdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
index 7eda43c66c91..37d02fcb81d0 100644
--- a/drivers/of/pdt.c
+++ b/drivers/of/pdt.c
@@ -40,7 +40,7 @@ static inline void irq_trans_init(struct device_node *dp) { }
 
 static char * __init of_pdt_build_full_name(struct device_node *dp)
 {
-	static int failsafe_id = 0; /* for generating unique names on failure */
+	static int failsafe_id; /* for generating unique names on failure */
 	const char *name;
 	char path[256];
 	char *buf;
@@ -67,7 +67,7 @@ static struct property * __init of_pdt_build_one_prop(phandle node, char *prev,
 					       void *special_val,
 					       int special_len)
 {
-	static struct property *tmp = NULL;
+	static struct property *tmp;
 	struct property *p;
 	int err;
 
-- 
2.34.1


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

* Re: [PATCH] of: unneed to initialise statics to 0 or NULL
  2021-12-12  7:14 [PATCH] of: unneed to initialise statics to 0 or NULL Jason Wang
@ 2021-12-15 20:07 ` Rob Herring
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2021-12-15 20:07 UTC (permalink / raw)
  To: Jason Wang; +Cc: frowand.list, devicetree, linux-kernel

On Sun, Dec 12, 2021 at 03:14:54PM +0800, Jason Wang wrote:
> Static variables do not need to be initialised to 0 or NULL,
> because compilers will initialise all uninitialised statics
> to 0 or NULL. Thus, remove the unneeded initializations.
> 

Not required, but I think it helps statics stand out more as-is.

> Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
> ---
>  drivers/of/pdt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
> index 7eda43c66c91..37d02fcb81d0 100644
> --- a/drivers/of/pdt.c
> +++ b/drivers/of/pdt.c
> @@ -40,7 +40,7 @@ static inline void irq_trans_init(struct device_node *dp) { }
>  
>  static char * __init of_pdt_build_full_name(struct device_node *dp)
>  {
> -	static int failsafe_id = 0; /* for generating unique names on failure */
> +	static int failsafe_id; /* for generating unique names on failure */
>  	const char *name;
>  	char path[256];
>  	char *buf;
> @@ -67,7 +67,7 @@ static struct property * __init of_pdt_build_one_prop(phandle node, char *prev,
>  					       void *special_val,
>  					       int special_len)
>  {
> -	static struct property *tmp = NULL;
> +	static struct property *tmp;
>  	struct property *p;
>  	int err;
>  
> -- 
> 2.34.1
> 
> 

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

end of thread, other threads:[~2021-12-15 20:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-12  7:14 [PATCH] of: unneed to initialise statics to 0 or NULL Jason Wang
2021-12-15 20:07 ` Rob Herring

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