From abe5cb4afebc7ba6cdd1213f27fef89c359bfac5 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Mon, 9 Jul 2018 21:42:30 +0800 Subject: [PATCH] HV: include: integral type cleanup This patch cleans up the integral type violations to MISRA C rules, mostly related to signed constants that should be unsigned but also spelling out two integer narrowing and dropping some macros negating unsigned integers. v1 -> v2: * Drop INT_ROUNDUPx macros since they are never used. Signed-off-by: Junjie Mao Acked-by: Eddie Dong --- hypervisor/include/arch/x86/cpu.h | 4 ++-- hypervisor/include/arch/x86/mmu.h | 2 +- hypervisor/include/lib/util.h | 12 ------------ 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/hypervisor/include/arch/x86/cpu.h b/hypervisor/include/arch/x86/cpu.h index b25b404aa..ab1f6078e 100644 --- a/hypervisor/include/arch/x86/cpu.h +++ b/hypervisor/include/arch/x86/cpu.h @@ -462,8 +462,8 @@ write_xcr(int reg, uint64_t val) { uint32_t low, high; - low = val; - high = val >> 32; + low = (uint32_t)val; + high = (uint32_t)(val >> 32); asm volatile("xsetbv" : : "c" (reg), "a" (low), "d" (high)); } #else /* ASSEMBLER defined */ diff --git a/hypervisor/include/arch/x86/mmu.h b/hypervisor/include/arch/x86/mmu.h index 266781831..0ac3092b4 100644 --- a/hypervisor/include/arch/x86/mmu.h +++ b/hypervisor/include/arch/x86/mmu.h @@ -373,7 +373,7 @@ struct e820_entry { */ static inline void *mmu_pt_for_pde(uint32_t *pd, uint32_t vaddr) { - return pd + ((vaddr >> 22) + 1) * 1024; + return pd + ((vaddr >> 22U) + 1U) * 1024U; } #define CACHE_FLUSH_INVALIDATE_ALL() \ diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h index 6fb46ae12..e42cf009c 100644 --- a/hypervisor/include/lib/util.h +++ b/hypervisor/include/lib/util.h @@ -17,18 +17,6 @@ #define offsetof(st, m) __builtin_offsetof(st, m) -/** Round an integer (x) up to a multiple of y */ -#define INT_ROUNDUP(x, y) (((x)+((y)-1))&-(y)) - -/** Round an integer up to a multiple of 4 */ -#define INT_ROUNDUP4(x) INT_ROUNDUP(x, 4) - -/** Round an integer up to a multiple of 8 */ -#define INT_ROUNDUP8(x) INT_ROUNDUP(x, 8) - -/** Round an integer up to a multiple of 8 */ -#define INT_ROUNDUP16(x) INT_ROUNDUP(x, 16) - /** Roundup (x/y) to ( x/y + (x%y) ? 1 : 0) **/ #define INT_DIV_ROUNDUP(x, y) (((x)+(y)-1)/(y))