mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kevin Winchester <kjwinchester@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
To: Ingo Molnar <mingo@elte.hu>
Cc: Kevin Winchester <kjwinchester@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] Fix uninitialized variable warning in do_one_initcall
Date: Sat,  3 Jul 2010 20:26:28 -0300	[thread overview]
Message-ID: <1278199588-3273-1-git-send-email-kjwinchester@gmail.com> (raw)

The warning is corrected by extracting the debug path out into
its own function.  This does en up duplicating one line of code
between the debug and regular code paths (i.e. the actual call
of the initcall function), but it seems worthwhile for the
cleaner build.

Signed-off-by: Kevin Winchester <kjwinchester@gmail.com>
---
 init/main.c |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/init/main.c b/init/main.c
index a42fdf4..21def42 100644
--- a/init/main.c
+++ b/init/main.c
@@ -728,30 +728,38 @@ static char msgbuf[64];
 static struct boot_trace_call call;
 static struct boot_trace_ret ret;
 
+static inline int do_one_initcall_debug(initcall_t fn)
+{
+	ktime_t calltime, rettime, delta;
+	int result;
+
+	call.caller = task_pid_nr(current);
+	printk(KERN_DEBUG "calling  %pF @ %i\n", fn, call.caller);
+	calltime = ktime_get();
+	trace_boot_call(&call, fn);
+	enable_boot_trace();
+
+	result = fn();
+
+	disable_boot_trace();
+	rettime = ktime_get();
+	delta = ktime_sub(rettime, calltime);
+	ret.duration = (unsigned long long) ktime_to_ns(delta) >> 10;
+	trace_boot_ret(&ret, fn);
+	printk(KERN_DEBUG "initcall %pF returned %d after %lld usecs\n", fn,
+		ret.result, ret.duration);
+
+	return result;
+}
+
 int do_one_initcall(initcall_t fn)
 {
 	int count = preempt_count();
-	ktime_t calltime, delta, rettime;
-
-	if (initcall_debug) {
-		call.caller = task_pid_nr(current);
-		printk("calling  %pF @ %i\n", fn, call.caller);
-		calltime = ktime_get();
-		trace_boot_call(&call, fn);
-		enable_boot_trace();
-	}
 
-	ret.result = fn();
-
-	if (initcall_debug) {
-		disable_boot_trace();
-		rettime = ktime_get();
-		delta = ktime_sub(rettime, calltime);
-		ret.duration = (unsigned long long) ktime_to_ns(delta) >> 10;
-		trace_boot_ret(&ret, fn);
-		printk("initcall %pF returned %d after %Ld usecs\n", fn,
-			ret.result, ret.duration);
-	}
+	if (initcall_debug)
+		ret.result = do_one_initcall_debug(fn);
+	else
+		ret.result = fn();
 
 	msgbuf[0] = 0;
 
@@ -773,7 +781,6 @@ int do_one_initcall(initcall_t fn)
 	return ret.result;
 }
 
-
 extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];
 
 static void __init do_initcalls(void)
-- 
1.7.1


             reply	other threads:[~2010-07-03 23:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-03 23:26 Kevin Winchester [this message]
2010-07-07 22:26 ` Andrew Morton
2010-07-08  0:09   ` [PATCH 1/2] Fix warning: 'calltime.tv64' may be used uninitialized in this function in init/main.c Kevin Winchester
2010-07-08  0:09   ` [PATCH 2/2] Mark do_one_initcall* as __init_or_module Kevin Winchester

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=1278199588-3273-1-git-send-email-kjwinchester@gmail.com \
    --to=kjwinchester@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome