]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
init/main.c: fix warning: 'calltime.tv64' may be used uninitialized
authorKevin Winchester <kjwinchester@gmail.com>
Tue, 10 Aug 2010 00:20:32 +0000 (17:20 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Aug 2010 03:45:06 +0000 (20:45 -0700)
Using:

gcc (GCC) 4.5.0 20100610 (prerelease)

The following warning appears:

init/main.c: In function `do_one_initcall':
init/main.c:730:10: warning: `calltime.tv64' may be used uninitialized in this function

This warning is actually correct, as the global initcall_debug could
arguably be changed by the initcall.

Correct this warning by extracting a new function, do_one_initcall_debug,
that performs the initcall for the debug case.

Signed-off-by: Kevin Winchester <kjwinchester@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
init/main.c

index b8b6effe9ff49b362b3608ff125ee19ccb58f720..dbee132923c5aa35b4093c63259ad6577486e9b8 100644 (file)
@@ -721,27 +721,33 @@ core_param(initcall_debug, initcall_debug, bool, 0644);
 
 static char msgbuf[64];
 
-int do_one_initcall(initcall_t fn)
+static int do_one_initcall_debug(initcall_t fn)
 {
-       int count = preempt_count();
        ktime_t calltime, delta, rettime;
        unsigned long long duration;
        int ret;
 
-       if (initcall_debug) {
-               printk("calling  %pF @ %i\n", fn, task_pid_nr(current));
-               calltime = ktime_get();
-       }
-
+       printk(KERN_DEBUG "calling  %pF @ %i\n", fn, task_pid_nr(current));
+       calltime = ktime_get();
        ret = fn();
+       rettime = ktime_get();
+       delta = ktime_sub(rettime, calltime);
+       duration = (unsigned long long) ktime_to_ns(delta) >> 10;
+       printk(KERN_DEBUG "initcall %pF returned %d after %lld usecs\n", fn,
+               ret, duration);
 
-       if (initcall_debug) {
-               rettime = ktime_get();
-               delta = ktime_sub(rettime, calltime);
-               duration = (unsigned long long) ktime_to_ns(delta) >> 10;
-               printk("initcall %pF returned %d after %lld usecs\n", fn,
-                       ret, duration);
-       }
+       return ret;
+}
+
+int do_one_initcall(initcall_t fn)
+{
+       int count = preempt_count();
+       int ret;
+
+       if (initcall_debug)
+               ret = do_one_initcall_debug(fn);
+       else
+               ret = fn();
 
        msgbuf[0] = 0;