Skip to content

Commit abe5cb4

Browse files
junjiemao1lijinxia
authored andcommitted
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 <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 3956ce1 commit abe5cb4

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

hypervisor/include/arch/x86/cpu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ write_xcr(int reg, uint64_t val)
462462
{
463463
uint32_t low, high;
464464

465-
low = val;
466-
high = val >> 32;
465+
low = (uint32_t)val;
466+
high = (uint32_t)(val >> 32);
467467
asm volatile("xsetbv" : : "c" (reg), "a" (low), "d" (high));
468468
}
469469
#else /* ASSEMBLER defined */

hypervisor/include/arch/x86/mmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ struct e820_entry {
373373
*/
374374
static inline void *mmu_pt_for_pde(uint32_t *pd, uint32_t vaddr)
375375
{
376-
return pd + ((vaddr >> 22) + 1) * 1024;
376+
return pd + ((vaddr >> 22U) + 1U) * 1024U;
377377
}
378378

379379
#define CACHE_FLUSH_INVALIDATE_ALL() \

hypervisor/include/lib/util.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@
1717

1818
#define offsetof(st, m) __builtin_offsetof(st, m)
1919

20-
/** Round an integer (x) up to a multiple of y */
21-
#define INT_ROUNDUP(x, y) (((x)+((y)-1))&-(y))
22-
23-
/** Round an integer up to a multiple of 4 */
24-
#define INT_ROUNDUP4(x) INT_ROUNDUP(x, 4)
25-
26-
/** Round an integer up to a multiple of 8 */
27-
#define INT_ROUNDUP8(x) INT_ROUNDUP(x, 8)
28-
29-
/** Round an integer up to a multiple of 8 */
30-
#define INT_ROUNDUP16(x) INT_ROUNDUP(x, 16)
31-
3220
/** Roundup (x/y) to ( x/y + (x%y) ? 1 : 0) **/
3321
#define INT_DIV_ROUNDUP(x, y) (((x)+(y)-1)/(y))
3422

0 commit comments

Comments
 (0)