linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: main: Remove unnecessary ‘NULL’ initialization from last_failed_step_show()
@ 2023-10-20  8:37 ZhouJie
  2023-12-11 20:58 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: ZhouJie @ 2023-10-20  8:37 UTC (permalink / raw)
  To: rafael, pavel, len.brown; +Cc: linux-pm, linux-kernel, ZhouJie

Declaring char *last_failed_step; is reasonable because you can later
assign the function's return value to last_failed_step without
explicitly assigning an initial value.

Signed-off-by: ZhouJie <zhoujie@nfschina.com>
---
 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index f6425ae3e8b05..24c675f6ab862 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -410,7 +410,7 @@ static ssize_t last_failed_step_show(struct kobject *kobj,
 {
 	int index;
 	enum suspend_stat_step step;
-	char *last_failed_step = NULL;
+	char *last_failed_step;
 
 	index = suspend_stats.last_failed_step + REC_FAILED_NUM - 1;
 	index %= REC_FAILED_NUM;
-- 
2.18.2


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

* Re: [PATCH] power: main: Remove unnecessary ‘NULL’ initialization from last_failed_step_show()
  2023-10-20  8:37 [PATCH] power: main: Remove unnecessary ‘NULL’ initialization from last_failed_step_show() ZhouJie
@ 2023-12-11 20:58 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2023-12-11 20:58 UTC (permalink / raw)
  To: ZhouJie; +Cc: rafael, pavel, len.brown, linux-pm, linux-kernel

On Fri, Oct 20, 2023 at 10:38 AM ZhouJie <zhoujie@nfschina.com> wrote:
>
> Declaring char *last_failed_step; is reasonable because you can later
> assign the function's return value to last_failed_step without
> explicitly assigning an initial value.

Did you want to say something like "it is not necessary to initialize
last_failed_step to NULL, because it is never read before being
assigned a value" ?

Also, to my eyes, last_failed_step is redundant and can be dropped
from that function entirely.

> Signed-off-by: ZhouJie <zhoujie@nfschina.com>
> ---
>  kernel/power/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/power/main.c b/kernel/power/main.c
> index f6425ae3e8b05..24c675f6ab862 100644
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -410,7 +410,7 @@ static ssize_t last_failed_step_show(struct kobject *kobj,
>  {
>         int index;
>         enum suspend_stat_step step;
> -       char *last_failed_step = NULL;
> +       char *last_failed_step;
>
>         index = suspend_stats.last_failed_step + REC_FAILED_NUM - 1;
>         index %= REC_FAILED_NUM;
> --
> 2.18.2
>

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

end of thread, other threads:[~2023-12-11 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20  8:37 [PATCH] power: main: Remove unnecessary ‘NULL’ initialization from last_failed_step_show() ZhouJie
2023-12-11 20:58 ` Rafael J. Wysocki

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