HV: Bracket for the same level of precendence

The plus and minor have the same level of precedence. The Misra-C
considers it as a violation. Added brackets in between addition and
substraction oprators.

Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Yang, Yu-chu 2018-07-18 18:16:56 -07:00 committed by lijinxia
parent 91337da5a1
commit da0f28c6de
7 changed files with 13 additions and 12 deletions

View File

@ -649,7 +649,7 @@ uint64_t e820_alloc_low_memory(uint32_t size)
struct e820_entry *entry, *new_entry;
/* We want memory in page boundary and integral multiple of pages */
size = ((size + CPU_PAGE_SIZE - 1U) >> CPU_PAGE_SHIFT)
size = (((size + CPU_PAGE_SIZE) - 1U) >> CPU_PAGE_SHIFT)
<< CPU_PAGE_SHIFT;
for (i = 0U; i < e820_entries; i++) {
@ -682,8 +682,8 @@ uint64_t e820_alloc_low_memory(uint32_t size)
new_entry = &e820[e820_entries];
new_entry->type = E820_TYPE_RESERVED;
new_entry->baseaddr = end - size;
new_entry->length = entry->baseaddr +
entry->length - new_entry->baseaddr;
new_entry->length = (entry->baseaddr +
entry->length) - new_entry->baseaddr;
/* Shrink the existing entry and total available memory */
entry->length -= new_entry->length;

View File

@ -48,7 +48,7 @@ void acrn_update_ucode(struct vcpu *vcpu, uint64_t v)
data_size = UCODE_GET_DATA_SIZE(uhdr) + sizeof(struct ucode_header);
data_page_num =
(data_size + CPU_PAGE_SIZE - 1U) >> CPU_PAGE_SHIFT;
((data_size + CPU_PAGE_SIZE) - 1U) >> CPU_PAGE_SHIFT;
ucode_ptr = alloc_pages(data_page_num);
if (ucode_ptr == NULL) {

View File

@ -481,7 +481,7 @@ bool initialize_trusty(struct vcpu *vcpu, uint64_t param)
/* init secure world environment */
if (init_secure_world_env(vcpu,
trusty_entry_gpa - trusty_base_gpa + TRUSTY_EPT_REBASE_GPA,
(trusty_entry_gpa - trusty_base_gpa) + TRUSTY_EPT_REBASE_GPA,
trusty_base_hpa, trusty_mem_size)) {
/* switch to Secure World */

View File

@ -210,7 +210,8 @@
#define MMU_MEM_ATTR_TYPE_MASK \
(IA32E_PDPTE_PAT_BIT | IA32E_COMM_PCD_BIT | IA32E_COMM_PWT_BIT)
#define ROUND_PAGE_UP(addr) (((addr) + (uint64_t)CPU_PAGE_SIZE - 1UL) & CPU_PAGE_MASK)
#define ROUND_PAGE_UP(addr) \
((((addr) + (uint64_t)CPU_PAGE_SIZE) - 1UL) & CPU_PAGE_MASK)
#define ROUND_PAGE_DOWN(addr) ((addr) & CPU_PAGE_MASK)
enum _page_table_type {

View File

@ -18,7 +18,7 @@
#define offsetof(st, m) __builtin_offsetof(st, m)
/** Roundup (x/y) to ( x/y + (x%y) ? 1 : 0) **/
#define INT_DIV_ROUNDUP(x, y) (((x)+(y)-1)/(y))
#define INT_DIV_ROUNDUP(x, y) ((((x)+(y))-1)/(y))
#define min(x, y) ((x) < (y)) ? (x) : (y)

View File

@ -245,7 +245,7 @@ void *malloc(unsigned int num_bytes)
memory = allocate_mem(&Memory_Pool, num_bytes);
} else {
uint32_t page_num =
(num_bytes + CPU_PAGE_SIZE - 1U) >> CPU_PAGE_SHIFT;
((num_bytes + CPU_PAGE_SIZE) - 1U) >> CPU_PAGE_SHIFT;
/* Request memory allocation through alloc_page */
memory = alloc_pages(page_num);
}
@ -361,8 +361,8 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen)
ASSERT(false);
}
if (((d > s) && (d <= (s + slen - 1U)))
|| ((d < s) && (s <= (d + dmax - 1U)))) {
if (((d > s) && (d <= ((s + slen) - 1U)))
|| ((d < s) && (s <= ((d + dmax) - 1U)))) {
ASSERT(false);
}

View File

@ -335,7 +335,7 @@ static int print_pow2(struct print_param *param,
/* assign parameter and apply width and precision */
param->vars.value = pos;
param->vars.valuelen = digitbuff + sizeof(digitbuff) - pos;
param->vars.valuelen = (digitbuff + sizeof(digitbuff)) - pos;
ret = format_number(param);
@ -408,7 +408,7 @@ static int print_decimal(struct print_param *param, int64_t value)
/* assign parameter and apply width and precision */
param->vars.value = pos;
param->vars.valuelen = digitbuff + sizeof(digitbuff) - pos;
param->vars.valuelen = (digitbuff + sizeof(digitbuff)) - pos;
ret = format_number(param);