common/initcall: extern linker symbols with correct types
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 28 Oct 2013 10:58:44 +0000 (11:58 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 28 Oct 2013 10:58:44 +0000 (11:58 +0100)
Coverity IDs 10549561054957

Coverity pointed out that we applying array operations based on an expression
which yielded singleton pointers.  The problem is actually that the externs
were typed incorrectly.

Correct the extern declaration to prevent straying into undefined behaviour,
and relying on the lenience of GCC to work.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/common/kernel.c

index b8707d90a14bf206da4d4d7e712d41ddfa0887b4..4ca50c4d92d1154f3ef932cc60739a3d1ab2badc 100644 (file)
@@ -196,19 +196,20 @@ void add_taint(unsigned flag)
     tainted |= flag;
 }
 
-extern initcall_t __initcall_start, __presmp_initcall_end, __initcall_end;
+extern const initcall_t __initcall_start[], __presmp_initcall_end[],
+    __initcall_end[];
 
 void __init do_presmp_initcalls(void)
 {
-    initcall_t *call;
-    for ( call = &__initcall_start; call < &__presmp_initcall_end; call++ )
+    const initcall_t *call;
+    for ( call = __initcall_start; call < __presmp_initcall_end; call++ )
         (*call)();
 }
 
 void __init do_initcalls(void)
 {
-    initcall_t *call;
-    for ( call = &__presmp_initcall_end; call < &__initcall_end; call++ )
+    const initcall_t *call;
+    for ( call = __presmp_initcall_end; call < __initcall_end; call++ )
         (*call)();
 }