HV:lib:add suffix U to the numeric constant

Add suffix U to the numeric constant

Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Huihuang Shi 2018-07-04 16:04:54 +08:00 committed by lijinxia
parent d3bd514e58
commit d3ad411c91
3 changed files with 29 additions and 28 deletions

View File

@ -22,7 +22,7 @@ static uint32_t Malloc_Heap_Contiguity_Bitmap[MALLOC_HEAP_BITMAP_SIZE];
struct mem_pool Memory_Pool = {
.start_addr = Malloc_Heap,
.spinlock = {.head = 0, .tail = 0},
.spinlock = {.head = 0U, .tail = 0U},
.size = CONFIG_HEAP_SIZE,
.buff_size = MALLOC_HEAP_BUFF_SIZE,
.total_buffs = MALLOC_HEAP_TOTAL_BUFF,
@ -46,7 +46,7 @@ static uint32_t Paging_Heap_Contiguity_Bitmap[MALLOC_HEAP_BITMAP_SIZE];
struct mem_pool Paging_Memory_Pool = {
.start_addr = Paging_Heap,
.spinlock = {.head = 0, .tail = 0},
.spinlock = {.head = 0U, .tail = 0U},
.size = CONFIG_NUM_ALLOC_PAGES * CPU_PAGE_SIZE,
.buff_size = PAGING_HEAP_BUFF_SIZE,
.total_buffs = PAGING_HEAP_TOTAL_BUFF,
@ -73,7 +73,7 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
/* Calculate number of buffers to be allocated from memory pool */
requested_buffs = INT_DIV_ROUNDUP(num_bytes, pool->buff_size);
for (idx = 0; idx < pool->bmp_size; idx++) {
for (idx = 0U; idx < pool->bmp_size; idx++) {
/* Find the first occurrence of requested_buffs number of free
* buffers. The 0th bit in bitmap represents a free buffer.
*/
@ -125,7 +125,7 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
/* Update allocation bitmaps information for
* selected buffers
*/
for (i = 0; i < requested_buffs; i++) {
for (i = 0U; i < requested_buffs; i++) {
/* Set allocation bit in bitmap for
* this buffer
*/
@ -157,7 +157,7 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
/* Increment idx */
idx++;
/* Reset bit_idx */
bit_idx = 0;
bit_idx = 0U;
}
}
@ -343,7 +343,7 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen)
uint8_t *dest8;
uint8_t *src8;
if (slen == 0 || dmax == 0 || dmax < slen) {
if (slen == 0U || dmax == 0U || dmax < slen) {
pr_err("%s: invalid src, dest buffer or length.", __func__);
return NULL;
}
@ -362,7 +362,7 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen)
src8 = (uint8_t *)s;
/*small data block*/
if (slen < 8) {
if (slen < 8U) {
while (slen != 0U) {
*dest8++ = *src8++;
slen--;
@ -378,7 +378,7 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen)
}
/*copy main data blocks, with rep prefix*/
if (slen > 8) {
if (slen > 8U) {
uint32_t ecx;
asm volatile ("cld; rep; movsq"
@ -386,7 +386,7 @@ void *memcpy_s(void *d, size_t dmax, const void *s, size_t slen)
: "0" (slen / 8), "1" (dest8), "2" (src8)
: "memory");
slen = slen % 8;
slen = slen % 8U;
}
/*tail bytes*/
@ -406,7 +406,7 @@ void *memset(void *base, uint8_t v, size_t n)
dest_p = (uint8_t *)base;
if ((dest_p == NULL) || (n == 0))
if ((dest_p == NULL) || (n == 0U))
return NULL;
/*do the few bytes to get uint64_t alignment*/
@ -415,11 +415,11 @@ void *memset(void *base, uint8_t v, size_t n)
*dest_p++ = v;
/*64-bit mode*/
n_q = count >> 3;
n_q = count >> 3U;
asm volatile("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb"
: "+c"(n_q), "+D"(dest_p)
: "a" (v * 0x0101010101010101U),
"r"((unsigned int)count & 7));
"r"((unsigned int)count & 7U));
return (void *)dest_p;
}

View File

@ -180,7 +180,8 @@ static int format_number(struct print_param *param)
int res;
/* initialize variables */
p = w = 0;
p = 0U;
w = 0U;
res = 0;
width = param->vars.valuelen + param->vars.prefixlen;
@ -215,7 +216,7 @@ static int format_number(struct print_param *param)
/* invalidate prefix */
param->vars.prefix = NULL;
param->vars.prefixlen = 0;
param->vars.prefixlen = 0U;
}
/* fill the width with the padding character, return early if
@ -273,7 +274,7 @@ static int print_pow2(struct print_param *param,
int ret;
/* calculate mask */
mask = (1UL << shift) - 1;
mask = (1UL << shift) - 1UL;
/* determine digit translation table */
digits = ((param->vars.flags & PRINT_FLAG_UPPER) != 0) ?
@ -283,13 +284,13 @@ static int print_pow2(struct print_param *param,
v &= param->vars.mask;
/* determine prefix for alternate form */
if ((v == 0) && ((param->vars.flags & PRINT_FLAG_ALTERNATE_FORM) != 0)) {
if ((v == 0UL) && ((param->vars.flags & PRINT_FLAG_ALTERNATE_FORM) != 0)) {
prefix[0] = '0';
param->vars.prefix = prefix;
param->vars.prefixlen = 1;
param->vars.prefixlen = 1U;
if (shift == 4) {
param->vars.prefixlen = 2;
if (shift == 4U) {
param->vars.prefixlen = 2U;
prefix[1] = digits[16];
}
}
@ -297,7 +298,7 @@ static int print_pow2(struct print_param *param,
/* determine digits from right to left */
do {
*--pos = digits[(v & mask)];
} while ((v >>= shift) != 0);
} while ((v >>= shift) != 0UL);
/* assign parameter and apply width and precision */
param->vars.value = pos;
@ -306,7 +307,7 @@ static int print_pow2(struct print_param *param,
ret = format_number(param);
param->vars.value = NULL;
param->vars.valuelen = 0;
param->vars.valuelen = 0U;
return ret;
}
@ -350,7 +351,7 @@ static int print_decimal(struct print_param *param, int64_t value)
}
/* process 64 bit value as long as needed */
while (v.dwords.high != 0) {
while (v.dwords.high != 0U) {
/* determine digits from right to left */
udiv64(v.qword, 10, &d);
*--pos = d.r.dwords.low + '0';
@ -374,7 +375,7 @@ static int print_decimal(struct print_param *param, int64_t value)
ret = format_number(param);
param->vars.value = NULL;
param->vars.valuelen = 0;
param->vars.valuelen = 0U;
return ret;
}
@ -390,7 +391,7 @@ static int print_string(struct print_param *param, const char *s)
/* the last result of the emit function */
int res;
w = 0;
w = 0U;
len = -1;
/* we need the length of the string if either width or precision is

View File

@ -262,7 +262,7 @@ char *strncpy_s(char *d, size_t dmax, const char *s, size_t slen)
return NULL;
}
if (dmax == 0 || slen == 0) {
if (dmax == 0U || slen == 0U) {
pr_err("%s: invlaid length of src or dest buffer", __func__);
return NULL;
}
@ -282,7 +282,7 @@ char *strncpy_s(char *d, size_t dmax, const char *s, size_t slen)
return NULL;
}
if (slen == 0) {
if (slen == 0U) {
*d = '\0';
return dest_base;
}
@ -333,9 +333,9 @@ size_t strnlen_s(const char *str, size_t maxlen)
if (str == NULL)
return 0;
count = 0;
count = 0U;
while ((*str) != 0) {
if (maxlen == 0)
if (maxlen == 0U)
break;
count++;