common/initcall: Extern linker symbols with correct types.
PATCH 1/1 common/initcall: Extern linker symbols with correct types.
Coverity IDs 1054956, 1054957
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.
--- xen/common/kernel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
xen/common/kernel.c +3 -3
@@ -196,19 +196,19 @@ void add_taint(unsigned flag) tainted |= flag; } -extern initcall_t __initcall_start, __presmp_initcall_end, __initcall_end; +extern 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++ ) +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++ ) +for ( call = __presmp_initcall_end; call < __initcall_end; call++ ) (*call)(); }
Signature · 1 line
1.7.10.4
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Coverity IDs 1054956, 1054957
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.
Fine by me, but if you already touch this I would have really liked to see you also make the declarations const-correct.
Jan
Quoted 37 lines
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>--- xen/common/kernel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)xen/common/kernel.c +3
-3@@ -196,19 +196,19 @@ void add_taint(unsigned flag) tainted |= flag; } -extern initcall_t __initcall_start, __presmp_initcall_end, __initcall_end; +extern 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++ ) +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++ ) +for ( call = __presmp_initcall_end; call < __initcall_end; call++ ) (*call)(); }Signature · 2 lines
-- 1.7.10.4
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Coverity IDs 1054956, 1054957
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.
Quoted 6 lines
Quoted 2 lines
Correct the extern declaration to prevent straying into undefined behaviour, and relying on the lenience of GCC to work.
Fine by me, but if you already touch this I would have really liked to see you also make the declarations const-correct.
Jan
Very good point - I shall submit v2 in due course.
~Andrew
Quoted 40 lines
Quoted 38 lines
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>--- xen/common/kernel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)xen/common/kernel.c +3
-3@@ -196,19 +196,19 @@ void add_taint(unsigned flag) tainted |= flag; } -extern initcall_t __initcall_start, __presmp_initcall_end, __initcall_end; +extern 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++ ) +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++ ) +for ( call = __presmp_initcall_end; call < __initcall_end; call++ ) (*call)(); }Signature · 2 lines
-- 1.7.10.4
PATCH v2 1/1 common/initcall: Extern linker symbols with correct types.
Coverity IDs 1054956, 1054957
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.
---
Changes in v2: apply const correctness as well.
--- xen/common/kernel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
xen/common/kernel.c +6 -5
@@ -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)(); }
Signature · 1 line
1.7.10.4
Quoted 6 lines · Andrew Cooper
Coverity IDs 1054956, 1054957
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.
Quoted 6 lines
Correct the extern declaration to prevent straying into undefined behaviour, and relying on the lenience of GCC to work.
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>
Ping?
Quoted 38 lines
---
Changes in v2: apply const correctness as well.
--- xen/common/kernel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)xen/common/kernel.c +6
-5@@ -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)(); }
Keir Fraser
Acked-byQuoted 7 lines · Andrew Cooper
Quoted 6 lines · Andrew Cooper
Coverity IDs 1054956, 1054957
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.
Quoted 8 lines
Quoted 6 lines
Correct the extern declaration to prevent straying into undefined behaviour, and relying on the lenience of GCC to work.
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>Ping?
Quoted 39 lines
Quoted 38 lines
---
Changes in v2: apply const correctness as well.
--- xen/common/kernel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)xen/common/kernel.c +6
-5@@ -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)(); }