hv: treewide: convert some MACROs to inline functions

MISRA-C requires that each parameter in the MACRO shall be in brackets.

In some cases, adding brackets for all of the parameters may not be a
perfect solution.
For example, it may affect the code readability when there are many
parameters used in the MACRO.
And duplicated brackets will appear when one MACRO called another MACRO
which is using same parameters.

This patch convert some MACROs to inline functions to avoid such cases.

v1 -> v2:
 * Remove the unnecessary changes in hypervisor/bsp/uefi/efi/boot.h

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Shiqing Gao
2018-09-03 16:24:20 +08:00
committed by lijinxia
parent 37fd3871b7
commit 67038794af
6 changed files with 116 additions and 76 deletions

View File

@@ -23,8 +23,11 @@ uint64_t get_microcode_version(void)
* According to SDM vol 3 Table 9-7. If data_size field of uCode
* header is zero, the ucode length is 2000
*/
#define UCODE_GET_DATA_SIZE(uhdr) \
((uhdr.data_size != 0U) ? uhdr.data_size : 2000U)
static inline size_t get_ucode_data_size(struct ucode_header *uhdr)
{
return ((uhdr->data_size != 0U) ? uhdr->data_size : 2000U);
}
void acrn_update_ucode(struct vcpu *vcpu, uint64_t v)
{
uint64_t gva, fault_addr;
@@ -47,7 +50,7 @@ void acrn_update_ucode(struct vcpu *vcpu, uint64_t v)
return;
}
data_size = UCODE_GET_DATA_SIZE(uhdr) + sizeof(struct ucode_header);
data_size = get_ucode_data_size(&uhdr) + sizeof(struct ucode_header);
data_page_num =
((data_size + CPU_PAGE_SIZE) - 1U) >> CPU_PAGE_SHIFT;