[PATCH] watchdog: change "char *" string form to "char []"

Yu Zhe posted 1 patch 1 year, 10 months ago
drivers/watchdog/realtek_otto_wdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] watchdog: change "char *" string form to "char []"
Posted by Yu Zhe 1 year, 10 months ago
The string form of "char []" declares a single variable. It is better
than "char *" which creates two variables.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
---
 drivers/watchdog/realtek_otto_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/realtek_otto_wdt.c b/drivers/watchdog/realtek_otto_wdt.c
index 60058a0c3ec4..c653ec73a999 100644
--- a/drivers/watchdog/realtek_otto_wdt.c
+++ b/drivers/watchdog/realtek_otto_wdt.c
@@ -265,7 +265,7 @@ static int otto_wdt_probe_clk(struct otto_wdt_ctrl *ctrl)
 
 static int otto_wdt_probe_reset_mode(struct otto_wdt_ctrl *ctrl)
 {
-	static const char *mode_property = "realtek,reset-mode";
+	static const char mode_property[] = "realtek,reset-mode";
 	const struct fwnode_handle *node = ctrl->dev->fwnode;
 	int mode_count;
 	u32 mode;
-- 
2.25.1
Re: [PATCH] watchdog: change "char *" string form to "char []"
Posted by Guenter Roeck 1 year, 10 months ago
On Mon, May 23, 2022 at 05:33:35PM -0700, Yu Zhe wrote:
> The string form of "char []" declares a single variable. It is better
> than "char *" which creates two variables.
> 

Huh, what ? One is a character array, the other a pointer.
It is still a single variable.

I don't mind if you want to use [] in your own code, but please
stop making such changes in other people's code. 

Guenter

> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> ---
>  drivers/watchdog/realtek_otto_wdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/realtek_otto_wdt.c b/drivers/watchdog/realtek_otto_wdt.c
> index 60058a0c3ec4..c653ec73a999 100644
> --- a/drivers/watchdog/realtek_otto_wdt.c
> +++ b/drivers/watchdog/realtek_otto_wdt.c
> @@ -265,7 +265,7 @@ static int otto_wdt_probe_clk(struct otto_wdt_ctrl *ctrl)
>  
>  static int otto_wdt_probe_reset_mode(struct otto_wdt_ctrl *ctrl)
>  {
> -	static const char *mode_property = "realtek,reset-mode";
> +	static const char mode_property[] = "realtek,reset-mode";
>  	const struct fwnode_handle *node = ctrl->dev->fwnode;
>  	int mode_count;
>  	u32 mode;
> -- 
> 2.25.1
>