From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH 13/34] xen/arm: gic: Introduce GIC_SGI_MAX Date: Tue, 25 Mar 2014 16:55:20 +0000 Message-ID: <1395766541-23979-14-git-send-email-julien.grall@linaro.org> References: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WSUe9-0008SG-6K for xen-devel@lists.xenproject.org; Tue, 25 Mar 2014 16:56:17 +0000 Received: by mail-ee0-f51.google.com with SMTP id c13so684260eek.24 for ; Tue, 25 Mar 2014 09:56:15 -0700 (PDT) In-Reply-To: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org All the functions that send an SGI takes an enum. Therefore checking everytime if the value is in the range is not correct. Introduce GIC_SGI_MAX to check the enum will never reach more than 16 values. This is fix the compilation with Clang 3.5: gic.c:515:15: error: comparison of constant 16 with expression of type 'enum gic_sgi' is always true [-Werror,-Wtautological-constant-out-of-range-compare] ASSERT(sgi < 16); /* There are only 16 SGIs */ ~~~ ^ ~~ xen/xen/include/xen/lib.h:43:26: note: expanded from macro 'ASSERT' do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0) ^ xen/xen/include/xen/compiler.h:11:41: note: expanded from macro 'unlikely' #define unlikely(x) __builtin_expect((x),0) Signed-off-by: Julien Grall Cc: Ian Campbell Cc: Stefano Stabellini Cc: Tim Deegan --- xen/arch/arm/gic.c | 7 ++++--- xen/include/asm-arm/gic.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 0095b97..41142a5 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -481,7 +481,8 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) unsigned int mask = 0; cpumask_t online_mask; - ASSERT(sgi < 16); /* There are only 16 SGIs */ + BUILD_BUG_ON(GIC_SGI_MAX >= 16); + ASSERT(sgi != GIC_SGI_MAX); cpumask_and(&online_mask, cpumask, &cpu_online_map); mask = gic_cpu_mask(&online_mask); @@ -501,7 +502,7 @@ void send_SGI_one(unsigned int cpu, enum gic_sgi sgi) void send_SGI_self(enum gic_sgi sgi) { - ASSERT(sgi < 16); /* There are only 16 SGIs */ + ASSERT(sgi != GIC_SGI_MAX); dsb(sy); @@ -511,7 +512,7 @@ void send_SGI_self(enum gic_sgi sgi) void send_SGI_allbutself(enum gic_sgi sgi) { - ASSERT(sgi < 16); /* There are only 16 SGIs */ + ASSERT(sgi != GIC_SGI_MAX); dsb(sy); diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 071280b..968125d 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -205,6 +205,8 @@ enum gic_sgi { GIC_SGI_EVENT_CHECK = 0, GIC_SGI_DUMP_STATE = 1, GIC_SGI_CALL_FUNCTION = 2, + /* GIC_SGI_MAX must be the last type of the enum */ + GIC_SGI_MAX, }; extern void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi); extern void send_SGI_one(unsigned int cpu, enum gic_sgi sgi); -- 1.7.10.4