hv: coding style: refine the remaining functions to one exit point

Refine the remaining functions in the head file to one exit point

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1 2018-12-21 20:09:52 +08:00 committed by wenlingz
parent 36dcb0f605
commit cf47f6cff8
2 changed files with 14 additions and 18 deletions

View File

@ -216,29 +216,31 @@ static inline struct acrn_vcpu *vcpu_from_vid(struct acrn_vm *vm, uint16_t vcpu_
static inline struct acrn_vcpu *vcpu_from_pid(struct acrn_vm *vm, uint16_t pcpu_id) static inline struct acrn_vcpu *vcpu_from_pid(struct acrn_vm *vm, uint16_t pcpu_id)
{ {
uint16_t i; uint16_t i;
struct acrn_vcpu *vcpu; struct acrn_vcpu *vcpu, *target_vcpu = NULL;
foreach_vcpu(i, vm, vcpu) { foreach_vcpu(i, vm, vcpu) {
if (vcpu->pcpu_id == pcpu_id) { if (vcpu->pcpu_id == pcpu_id) {
return vcpu; target_vcpu = vcpu;
break;
} }
} }
return NULL; return target_vcpu;
} }
static inline struct acrn_vcpu *get_primary_vcpu(struct acrn_vm *vm) static inline struct acrn_vcpu *get_primary_vcpu(struct acrn_vm *vm)
{ {
uint16_t i; uint16_t i;
struct acrn_vcpu *vcpu; struct acrn_vcpu *vcpu, *target_vcpu = NULL;
foreach_vcpu(i, vm, vcpu) { foreach_vcpu(i, vm, vcpu) {
if (is_vcpu_bsp(vcpu)) { if (is_vcpu_bsp(vcpu)) {
return vcpu; target_vcpu = vcpu;
break;
} }
} }
return NULL; return target_vcpu;
} }
static inline struct acrn_vuart* static inline struct acrn_vuart*

View File

@ -133,15 +133,17 @@ static inline uint16_t ffz64(uint64_t value)
*/ */
static inline uint64_t ffz64_ex(const uint64_t *addr, uint64_t size) static inline uint64_t ffz64_ex(const uint64_t *addr, uint64_t size)
{ {
uint64_t ret = size;
uint64_t idx; uint64_t idx;
for (idx = 0UL; (idx << 6U) < size; idx++) { for (idx = 0UL; (idx << 6U) < size; idx++) {
if (addr[idx] != ~0UL) { if (addr[idx] != ~0UL) {
return (idx << 6U) + ffz64(addr[idx]); ret = (idx << 6U) + ffz64(addr[idx]);
break;
} }
} }
return size; return ret;
} }
/* /*
* Counts leading zeros. * Counts leading zeros.
@ -160,11 +162,7 @@ static inline uint64_t ffz64_ex(const uint64_t *addr, uint64_t size)
*/ */
static inline uint16_t clz(uint32_t value) static inline uint16_t clz(uint32_t value)
{ {
if (value == 0U) { return ((value != 0U) ? (31U - fls32(value)) : 32U);
return 32U;
} else {
return (31U - fls32(value));
}
} }
/* /*
@ -176,11 +174,7 @@ static inline uint16_t clz(uint32_t value)
*/ */
static inline uint16_t clz64(uint64_t value) static inline uint16_t clz64(uint64_t value)
{ {
if (value == 0UL) { return ((value != 0UL) ? (63U - fls64(value)) : 64U);
return 64U;
} else {
return (63U - fls64(value));
}
} }
/* /*