From: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
To: Linux-kernel <linux-kernel@vger.kernel.org>
Subject: [RFC][PATCH] Replace the goto-based loop by a do-while statement
Date: Tue, 13 Nov 2007 01:09:25 +0300 [thread overview]
Message-ID: <4738CF15.10707@gmail.com> (raw)
Hi list,
It looks like using the goto statement in constructs like
restart:
// DO SOMETHING
if (condition)
goto restart;
should be frowned upon and the loop
do {
// DO SOMETHING
} while (condition);
is more appropriate in such situation.
However, in the __do_softirq() routine located in `kernel/softirq.c' the goto construct was chosen in favor of the do-while loop.
The patch included below replaces the goto-based loop by the do-while statement.
If the goto is really necessary here, I would be very grateful if someone could explain why.
Signed-off-by: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
--
diff --git a/kernel/softirq.c b/kernel/softirq.c
index bd89bc4..b0d0431 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -219,28 +219,28 @@ asmlinkage void __do_softirq(void)
trace_softirq_enter();
cpu = smp_processor_id();
-restart:
- /* Reset the pending bitmask before enabling irqs */
- set_softirq_pending(0);
- local_irq_enable();
+ do {
+ /* Reset the pending bitmask before enabling irqs */
+ set_softirq_pending(0);
- h = softirq_vec;
+ local_irq_enable();
- do {
- if (pending & 1) {
- h->action(h);
- rcu_bh_qsctr_inc(cpu);
- }
- h++;
- pending >>= 1;
- } while (pending);
+ h = softirq_vec;
- local_irq_disable();
+ do {
+ if (pending & 1) {
+ h->action(h);
+ rcu_bh_qsctr_inc(cpu);
+ }
+ h++;
+ pending >>= 1;
+ } while (pending);
- pending = local_softirq_pending();
- if (pending && --max_restart)
- goto restart;
+ local_irq_disable();
+
+ pending = local_softirq_pending();
+ } while (pending && --max_restart);
if (pending)
wakeup_softirqd();
reply other threads:[~2007-11-12 22:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4738CF15.10707@gmail.com \
--to=dmitri.vorobiev@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.