diff mbox series

power: swap: Remove unnecessary ‘0’ values from ret

Message ID 20231027021303.26187-1-kunyu@nfschina.com
State New
Headers show
Series power: swap: Remove unnecessary ‘0’ values from ret | expand

Commit Message

Li kunyu Oct. 27, 2023, 2:13 a.m. UTC
'ret 'is first assigned a value and then used, it does not need to be
assigned at definition time.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 kernel/power/swap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Rafael J. Wysocki Dec. 11, 2023, 9:14 p.m. UTC | #1
On Fri, Oct 27, 2023 at 4:13 AM Li kunyu <kunyu@nfschina.com> wrote:
>
> 'ret 'is first assigned a value and then used, it does not need to be
> assigned at definition time.

But the compiler may be confused, at least in the first case.

> Signed-off-by: Li kunyu <kunyu@nfschina.com>
> ---
>  kernel/power/swap.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index 90bb583c57bf7..32e8cb6ceaea4 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -679,7 +679,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
>                            unsigned int nr_to_write)
>  {
>         unsigned int m;
> -       int ret = 0;
> +       int ret;

It is better to leave the code as is here as the compiler may still
complain about the initialization of ret.

>         int nr_pages;
>         int err2;
>         struct hib_bio_batch hb;
> @@ -1060,7 +1060,7 @@ static int load_image(struct swap_map_handle *handle,
>                        unsigned int nr_to_read)
>  {
>         unsigned int m;
> -       int ret = 0;
> +       int ret;
>         ktime_t start;
>         ktime_t stop;
>         struct hib_bio_batch hb;
> @@ -1166,7 +1166,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
>                            unsigned int nr_to_read)
>  {
>         unsigned int m;
> -       int ret = 0;
> +       int ret;
>         int eof = 0;
>         struct hib_bio_batch hb;
>         ktime_t start;
> --
> 2.18.2
>
diff mbox series

Patch

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 90bb583c57bf7..32e8cb6ceaea4 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -679,7 +679,7 @@  static int save_image_lzo(struct swap_map_handle *handle,
                           unsigned int nr_to_write)
 {
 	unsigned int m;
-	int ret = 0;
+	int ret;
 	int nr_pages;
 	int err2;
 	struct hib_bio_batch hb;
@@ -1060,7 +1060,7 @@  static int load_image(struct swap_map_handle *handle,
                       unsigned int nr_to_read)
 {
 	unsigned int m;
-	int ret = 0;
+	int ret;
 	ktime_t start;
 	ktime_t stop;
 	struct hib_bio_batch hb;
@@ -1166,7 +1166,7 @@  static int load_image_lzo(struct swap_map_handle *handle,
                           unsigned int nr_to_read)
 {
 	unsigned int m;
-	int ret = 0;
+	int ret;
 	int eof = 0;
 	struct hib_bio_batch hb;
 	ktime_t start;