* [Patch] kexec: remove redundant if-else
@ 2008-07-18 15:04 WANG Cong
2008-07-18 20:07 ` Eric W. Biederman
0 siblings, 1 reply; 3+ messages in thread
From: WANG Cong @ 2008-07-18 15:04 UTC (permalink / raw)
To: LKML; +Cc: ebiederm, kexec
These if-else's can be removed.
Signed-off-by: WANG Cong <wangcong@zeuux.org>
Cc: ebiederm@xmission.com
---
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 1c5fcac..ea6fa9b 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] kexec: remove redundant if-else
2008-07-18 15:04 [Patch] kexec: remove redundant if-else WANG Cong
@ 2008-07-18 20:07 ` Eric W. Biederman
2008-07-19 10:16 ` WANG Cong
0 siblings, 1 reply; 3+ messages in thread
From: Eric W. Biederman @ 2008-07-18 20:07 UTC (permalink / raw)
To: WANG Cong; +Cc: LKML, kexec
WANG Cong <xiyou.wangcong@gmail.com> writes:
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] kexec: remove redundant if-else
2008-07-18 20:07 ` Eric W. Biederman
@ 2008-07-19 10:16 ` WANG Cong
0 siblings, 0 replies; 3+ messages in thread
From: WANG Cong @ 2008-07-19 10:16 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: LKML, kexec
On Fri, Jul 18, 2008 at 01:07:58PM -0700, Eric W. Biederman wrote:
>WANG Cong <xiyou.wangcong@gmail.com> writes:
>
>> 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.
--
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-19 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-18 15:04 [Patch] kexec: remove redundant if-else WANG Cong
2008-07-18 20:07 ` Eric W. Biederman
2008-07-19 10:16 ` WANG Cong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®