Message ID | 1395766541-23979-13-git-send-email-julien.grall@linaro.org |
---|---|
State | Deferred, archived |
Headers | show |
On Tue, 2014-03-25 at 16:55 +0000, Julien Grall wrote: > vcpuid is unsigned int, therefore the value will never be negative. > > It fixes compilation with clang 3.5: > vpsci.c:29:18: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare] > if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) ) > ~~~~~~ ^ ~ These sorts of compiler warnings annoy me because one thing the existing check protects against is someone who changes the type of the variable to a signed type (and vcpuid is often held in a signed type inside Xen I think), at which point the condition can become true. But any way, I expect I'm in the minority here, and in this specific case the type of vcpuid is mandated by the PSCI standard (I think) so: > Signed-off-by: Julien Grall <julien.grall@linaro.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> Ian.
diff --git a/xen/arch/arm/vpsci.c b/xen/arch/arm/vpsci.c index 1ceb8cb..abd3ade 100644 --- a/xen/arch/arm/vpsci.c +++ b/xen/arch/arm/vpsci.c @@ -26,7 +26,7 @@ int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point) int rc; int is_thumb = entry_point & 1; - if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) ) + if ( vcpuid >= MAX_VIRT_CPUS ) return PSCI_EINVAL; if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
vcpuid is unsigned int, therefore the value will never be negative. It fixes compilation with clang 3.5: vpsci.c:29:18: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare] if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) ) ~~~~~~ ^ ~ Signed-off-by: Julien Grall <julien.grall@linaro.org> Cc: Ian Campbell <ian.campbell@citrix.com> Cc: Stefano Stabellini <stefano.stabellini@citrix.com> Cc: Tim Deegan <tim@xen.org> --- xen/arch/arm/vpsci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)