Skip to contentSkip to conversation

initrd: Remove unnecessary goto label 'successful_load'

PATCH In review Thorsten Blum 2 participants 3 messages Sep 13, 2025 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 initrd: Remove unnecessary goto label 'successful_load'

The goto label 'successful_load' isn't really necessary. Set 'res = 1' immediately and let 'goto done' handle the rest.

No functional changes.

---
 init/do_mounts_rd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
init/do_mounts_rd.c +1 -3
index ac021ae6e6fa..97ddcdaba893 100644
@@ -210,7 +210,7 @@ int __init rd_load_image(char *from)
 
 	if (nblocks == 0) {
 		if (crd_load(decompressor) == 0)
-			goto successful_load;
+			res = 1; /* load successful */
 		goto done;
 	}
 
@@ -264,8 +264,6 @@ int __init rd_load_image(char *from)
 	}
 	pr_cont("done.\n");
 
-successful_load:
-	res = 1;
 done:
 	fput(in_file);
 noclose_input:
Signature · 1 line
2.51.0
#1 lore raw

Hi,

Quoted 15 lines · Thorsten Blum

The goto label 'successful_load' isn't really necessary. Set 'res = 1' immediately and let 'goto done' handle the rest.

No functional changes.

---
 init/do_mounts_rd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
init/do_mounts_rd.c +0 -0
index ac021ae6e6fa..97ddcdaba893 100644

init/do_mounts_rd.c int __init rd_load_image(char *from) · line 216

Quoted 8 lines
init/do_mounts_rd.c +1 -1
@@ -210,7 +210,7 @@ int __init rd_load_image(char *from)
 
 
 	if (nblocks == 0) {
 		if (crd_load(decompressor) == 0)
-			goto successful_load;
+			res = 1; /* load successful */
 		goto done;
 	}

This is now the only place where res will be set to 1.

init/do_mounts_rd.c int __init rd_load_image(char *from) · line 269

Quoted 8 lines
init/do_mounts_rd.c +0 -2
@@ -264,8 +264,6 @@ int __init rd_load_image(char *from)
 	}
 	pr_cont("done.\n");
 
 
-successful_load:
-	res = 1;

This does not seem correct? After this patch res is not updated to 1 anymore if execution reaches here without taking another goto, i.e. the return value is changed by this patch.

Regards,
Klara Modin

Quoted 6 lines
init/do_mounts_rd.c +0 -0
 done:
 	fput(in_file);

noclose_input:

Signature · 1 line
2.51.0
#2 lore raw
Quoted 11 lines · Klara Modin
Quoted 8 lines · Thorsten Blum

The goto label 'successful_load' isn't really necessary. Set 'res = 1' immediately and let 'goto done' handle the rest.

No functional changes.

---
...

This is now the only place where res will be set to 1.

Sorry my bad.

Quoted 3 lines

This does not seem correct? After this patch res is not updated to 1 anymore if execution reaches here without taking another goto, i.e. the return value is changed by this patch.

Thanks, I agree that it doesn't make sense. I only intended to delete the label, not the 'res = 1'.

Please ignore this patch (unless someone thinks removing the goto label is worth a v2) and sorry for the noise.

Thanks,
Thorsten