HV: logical and high level precedence expression needs brackets

Added brackets for expression to make it easy to understand and
reduce the mistake of precedence. The rule is applied to the
mixed same level of prevedence opeartors, high level presedence
operators and logical expression.

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 12:49:28 -07:00
committed by lijinxia
parent 7aec6799a1
commit 91337da5a1
22 changed files with 76 additions and 74 deletions

View File

@@ -109,7 +109,7 @@ int udiv64(uint64_t dividend, uint64_t divisor, struct udiv_result *res)
}
divisor >>= 1UL;
mask >>= 1UL;
} while ((bits-- != 0UL) && (dividend != 0UL));
} while (((bits--) != 0UL) && (dividend != 0UL));
res->r.qword = dividend;
return 0;

View File

@@ -126,9 +126,9 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
* memory pool
*/
memory = (char *)pool->start_addr +
pool->buff_size *
(idx * BITMAP_WORD_SIZE +
bit_idx);
(pool->buff_size *
((idx * BITMAP_WORD_SIZE) +
bit_idx));
/* Update allocation bitmaps information for
* selected buffers
@@ -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 - 1)
|| (d < s && s <= d + dmax - 1)) {
if (((d > s) && (d <= (s + slen - 1U)))
|| ((d < s) && (s <= (d + dmax - 1U)))) {
ASSERT(false);
}

View File

@@ -96,7 +96,7 @@ static const char *get_int(const char *s, int *x)
/* parse uint32_teger */
while ((*s >= '0') && (*s <= '9')) {
*x = *x * 10 + (*s - '0');
*x = (*x * 10) + (*s - '0');
s++;
}
@@ -648,7 +648,7 @@ static int charmem(int cmd, const char *s, int sz, void *hnd)
if (cmd == PRINT_CMD_COPY) {
if (sz < 0) {
while ((*s) != '\0') {
if (n < param->sz - param->wrtn) {
if (n < (param->sz - param->wrtn)) {
*p = *s;
}
p++;
@@ -658,7 +658,7 @@ static int charmem(int cmd, const char *s, int sz, void *hnd)
} else if (sz > 0) {
while (((*s) != '\0') && n < sz) {
if (n < param->sz - param->wrtn) {
if (n < (param->sz - param->wrtn)) {
*p = *s;
}
p++;
@@ -674,7 +674,7 @@ static int charmem(int cmd, const char *s, int sz, void *hnd)
}
/* fill mode */
else {
n = (sz < param->sz - param->wrtn) ? sz : 0;
n = (sz < (param->sz - param->wrtn)) ? sz : 0;
param->wrtn += sz;
(void)memset(p, *s, n);
}