Skip to contentSkip to conversation

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

PATCH In review Li kunyu 2 participants 2 messages Oct 27, 2023 – Dec 11, 2023

Subsystems (2)
lore
Share & tools
lore

Li kunyu

author
#0 lore raw

PATCH 1/1 power: swap: Remove unnecessary ‘0’ values from ret

'ret 'is first assigned a value and then used, it does not need to be assigned at definition time.

---
 kernel/power/swap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/power/swap.c +3 -3
index 90bb583c57bf7..32e8cb6ceaea4 100644
@@ -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;
Signature · 1 line
2.18.2
#1 lore raw
Quoted 3 lines · Li kunyu

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

Quoted 10 lines
---
 kernel/power/swap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/power/swap.c +0 -0
index 90bb583c57bf7..32e8cb6ceaea4 100644

kernel/power/swap.c static int save_image_lzo(struct swap_map_handle *handle, · line 682

Quoted 5 lines
kernel/power/swap.c +1 -1
@@ -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.

Quoted 24 lines
kernel/power/swap.c +2 -3
        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