Skip to contentSkip to conversation

kexec: remove redundant if-else

PATCH In review WANG Cong 2 participants 3 messages Jul 18, 2008 – Jul 19, 2008

Subsystems (3)
lore
Share & tools
lore

WANG Cong

author
#0 lore raw

PATCH 1/1 kexec: remove redundant if-else

These if-else's can be removed.

---

kernel/kexec.c +12 -18
index 1c5fcac..ea6fa9b 100644
@@ -203,13 +203,11 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
 			goto out;
 	}
 
-	result = 0;
-out:
-	if (result == 0)
-		*rimage = image;
-	else
-		kfree(image);
+	*rimage = image;
+	return 0;
 
+out:
+	kfree(image);
 	return result;
 
 }
@@ -242,13 +240,11 @@ static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry,
 		goto out;
 	}
 
-	result = 0;
- out:
-	if (result == 0)
-		*rimage = image;
-	else
-		kfree(image);
+	*rimage = image;
+	return 0;
 
+ out:
+	kfree(image);
 	return result;
 }
 
@@ -311,13 +307,11 @@ static int kimage_crash_alloc(struct kimage **rimage, unsigned long entry,
 		goto out;
 	}
 
-	result = 0;
-out:
-	if (result == 0)
-		*rimage = image;
-	else
-		kfree(image);
+	*rimage = image;
+	return 0;
 
+out:
+	kfree(image);
 	return result;
 }
 

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 1 line · WANG Cong

These if-else's can be removed.

Why? That appears to be pointless code style thrashing.

Converting code with a single return into code with multiple returns. Which arguably makes it harder to prove properties about.

Further if you want to use the style you suggest a label name like err is better than the name out.

But in this case where we have multiple results I don't like the proposed change in style at all. Especially with no rational.

Eric

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#2 lore raw
Quoted 5 lines · Eric W. Biederman
Quoted 1 line · WANG Cong

These if-else's can be removed.

Why? That appears to be pointless code style thrashing.

I don't think that is coding style fix. Because when we arrive the 'out' branch, 'result' is always properly set, thus checking it again is useless for me. :-)

Thanks.

Signature · 7 lines
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec