From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [Patch v2] common/initcall: Extern linker symbols with correct types. Date: Tue, 22 Oct 2013 17:34:09 +0100 Message-ID: <5266A901.2070904@citrix.com> References: <5261004F.9000304@citrix.com> <1382105177-390-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1382105177-390-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Keir Fraser , Jan Beulich , Xen-devel List-Id: xen-devel@lists.xenproject.org On 18/10/13 15:06, Andrew Cooper wrote: > 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. > > Signed-off-by: Andrew Cooper > CC: Keir Fraser > CC: Jan Beulich Ping? > > --- > > Changes in v2: apply const correctness as well. > --- > xen/common/kernel.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/xen/common/kernel.c b/xen/common/kernel.c > index b8707d9..4ca50c4 100644 > --- a/xen/common/kernel.c > +++ b/xen/common/kernel.c > @@ -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)(); > } >