mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 12:12:16 +00:00
hv: lib: fix "Procedure has more than one exit point"
IEC 61508,ISO 26262 standards highly recommend single-exit rule. Reduce the count of the "return entries". Fix the violations which is comply with the cases list below: 1.Function has 2 return entries. 2.The first return entry is used to return the error code of checking variable whether is valid. Fix the violations in "if else" format. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
279808b202
commit
ba44417d96
@ -78,11 +78,12 @@ static inline uint16_t fls64(uint64_t value)
|
|||||||
{
|
{
|
||||||
uint64_t ret = 0UL;
|
uint64_t ret = 0UL;
|
||||||
if (value == 0UL) {
|
if (value == 0UL) {
|
||||||
return (INVALID_BIT_INDEX);
|
ret = (INVALID_BIT_INDEX);
|
||||||
}
|
} else {
|
||||||
asm volatile("bsrq %1,%0"
|
asm volatile("bsrq %1,%0"
|
||||||
: "=r" (ret)
|
: "=r" (ret)
|
||||||
: "rm" (value));
|
: "rm" (value));
|
||||||
|
}
|
||||||
return (uint16_t)ret;
|
return (uint16_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,26 +372,28 @@ void *memset(void *base, uint8_t v, size_t n)
|
|||||||
uint8_t *dest_p;
|
uint8_t *dest_p;
|
||||||
size_t n_q;
|
size_t n_q;
|
||||||
size_t count;
|
size_t count;
|
||||||
|
void *ret;
|
||||||
|
|
||||||
dest_p = (uint8_t *)base;
|
dest_p = (uint8_t *)base;
|
||||||
|
|
||||||
if ((dest_p == NULL) || (n == 0U)) {
|
if ((dest_p == NULL) || (n == 0U)) {
|
||||||
return NULL;
|
ret = NULL;
|
||||||
}
|
} else {
|
||||||
|
/* do the few bytes to get uint64_t alignment */
|
||||||
|
count = n;
|
||||||
|
for (; (count != 0U) && (((uint64_t)dest_p & 7UL) != 0UL); count--) {
|
||||||
|
*dest_p = v;
|
||||||
|
dest_p++;
|
||||||
|
}
|
||||||
|
|
||||||
/* do the few bytes to get uint64_t alignment */
|
/* 64-bit mode */
|
||||||
count = n;
|
n_q = count >> 3U;
|
||||||
for (; (count != 0U) && (((uint64_t)dest_p & 7UL) != 0UL); count--) {
|
asm volatile("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb"
|
||||||
*dest_p = v;
|
: "+c"(n_q), "+D"(dest_p)
|
||||||
dest_p++;
|
: "a" (v * 0x0101010101010101U),
|
||||||
}
|
"r"((unsigned int)count & 7U));
|
||||||
|
ret = (void *)dest_p;
|
||||||
|
}
|
||||||
|
|
||||||
/* 64-bit mode */
|
return ret;
|
||||||
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 & 7U));
|
|
||||||
|
|
||||||
return (void *)dest_p;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user