mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-04 23:24:56 +00:00
HV:treewide:Update return type of function ffs64 and ffz64
To reduce type conversion in HV:
Update return type of function ffs64 and ffz64 as uint16;
For ffs64, when the input is zero, INVALID_BIT_INDEX is returned;
Update temporary variable type and return value check of caller
when it call ffs64 or ffz64;
Note: In the allocate_mem, there is no return value checking for
calling ffz64, this will be updated latter.
V1-->V2:
INVALID_BIT_INDEX instead of INVALID_NUMBER
Coding style fixing;
INVALID_CPU_ID instead of INVALID_PCPU_ID or INVALID_VCPU_ID;
"%hu" is used to print vcpu id (uint16_t);
Add "U/UL" for constant value as needed.
V2-->V3:
ffs64 return INVALID_BIT_INDEX directly when
the input value is zero;
Remove excess "%hu" updates.
V3-->V4:
Clean up the comments of ffs64;
Add "U" for constant value as needed.
Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -58,9 +58,10 @@ struct mem_pool Paging_Memory_Pool = {
|
||||
static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
|
||||
{
|
||||
|
||||
void *memory = NULL;
|
||||
uint32_t idx, bit_idx;
|
||||
uint32_t requested_buffs;
|
||||
void *memory = NULL;
|
||||
uint32_t idx;
|
||||
uint16_t bit_idx;
|
||||
uint32_t requested_buffs;
|
||||
|
||||
/* Check if provided memory pool exists */
|
||||
if (pool == NULL)
|
||||
@@ -85,9 +86,9 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
|
||||
/* Declare temporary variables to be used locally in
|
||||
* this block
|
||||
*/
|
||||
uint32_t i;
|
||||
uint32_t tmp_bit_idx = bit_idx;
|
||||
uint32_t tmp_idx = idx;
|
||||
uint32_t i;
|
||||
uint16_t tmp_bit_idx = bit_idx;
|
||||
uint32_t tmp_idx = idx;
|
||||
|
||||
/* Check requested_buffs number of buffers availability
|
||||
* in memory-pool right after selected buffer
|
||||
@@ -101,7 +102,7 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
|
||||
if (++tmp_idx == pool->bmp_size)
|
||||
break;
|
||||
/* Reset tmp_bit_idx */
|
||||
tmp_bit_idx = 0;
|
||||
tmp_bit_idx = 0U;
|
||||
}
|
||||
|
||||
/* Break if selected buffer is not free */
|
||||
|
||||
Reference in New Issue
Block a user