hv: treewide: fix multiple MISRAC violations

MISARC has requirements about  Marco redefinition, usage of ++ or -- and
assignment operator in boolean expression. This patch is used to solve
these violations.

The modifications are summarized as following:
1.The HC_VM_SET_MEMORY_REGION, HC_VM_GPA2HPA, HC_VM_SET_MEMORY_REGIONS are
redefined twice in acrn_hv_des.h, so delete them to solve the macro
redefinition violations.

2.The macro BUS_LOCK are redefined in bits.h and atomic.h, then delete
the declaration in both two files, add a new declaration in cpu.h and
include the header file.

3.modify the code to solve the improper usage of -- operators in string.c.

4.modify the while loop to for loop to avoid assignment operator in
boolean expression in vlapic.c.

v1 -> v2:
 *Modify the format of commit logs and signed-off name.

 *Modify the code format from 'd = d-1;' to 'd--;' to be better.

Signed-off-by: Junjun Shan <junjun.shan@intel.com>
This commit is contained in:
Junjun Shan 2018-08-14 09:42:34 +08:00 committed by lijinxia
parent 0292e14ff9
commit ca83c09b9f
6 changed files with 10 additions and 10 deletions

View File

@ -1137,7 +1137,8 @@ vlapic_icrlo_write_handler(struct acrn_vlapic *vlapic)
break; break;
} }
while ((vcpu_id = ffs64(dmask)) != INVALID_BIT_INDEX) { for (vcpu_id = ffs64(dmask); vcpu_id != INVALID_BIT_INDEX;
vcpu_id = ffs64(dmask)) {
bitmap_clear_lock(vcpu_id, &dmask); bitmap_clear_lock(vcpu_id, &dmask);
target_vcpu = vcpu_from_vid(vlapic->vm, vcpu_id); target_vcpu = vcpu_from_vid(vlapic->vm, vcpu_id);
if (target_vcpu == NULL) { if (target_vcpu == NULL) {

View File

@ -152,6 +152,8 @@
#ifndef ASSEMBLER #ifndef ASSEMBLER
#define BUS_LOCK "lock ; "
/** /**
* *
* Identifiers for architecturally defined registers. * Identifiers for architecturally defined registers.

View File

@ -29,8 +29,7 @@
#ifndef ATOMIC_H #ifndef ATOMIC_H
#define ATOMIC_H #define ATOMIC_H
#include <cpu.h>
#define BUS_LOCK "lock ; "
#define build_atomic_load(name, size, type, ptr) \ #define build_atomic_load(name, size, type, ptr) \
static inline type name(const volatile type *ptr) \ static inline type name(const volatile type *ptr) \

View File

@ -29,8 +29,7 @@
#ifndef BITS_H #ifndef BITS_H
#define BITS_H #define BITS_H
#include <cpu.h>
#define BUS_LOCK "lock ; "
/** /**
* *
* INVALID_BIT_INDEX means when input paramter is zero, * INVALID_BIT_INDEX means when input paramter is zero,

View File

@ -55,9 +55,6 @@
#define HC_VM_GPA2HPA BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x01UL) #define HC_VM_GPA2HPA BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x01UL)
#define HC_VM_SET_MEMORY_REGIONS BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x02UL) #define HC_VM_SET_MEMORY_REGIONS BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x02UL)
#define HC_VM_WRITE_PROTECT_PAGE BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x03UL) #define HC_VM_WRITE_PROTECT_PAGE BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x03UL)
#define HC_VM_SET_MEMORY_REGION BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x00UL)
#define HC_VM_GPA2HPA BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x01UL)
#define HC_VM_SET_MEMORY_REGIONS BASE_HC_ID(HC_ID, HC_ID_MEM_BASE + 0x02UL)
/* PCI assignment*/ /* PCI assignment*/
#define HC_ID_PCI_BASE 0x50UL #define HC_ID_PCI_BASE 0x50UL

View File

@ -210,7 +210,8 @@ char *strcpy_s(char *d_arg, size_t dmax, const char *s_arg)
while (dest_avail > 0U) { while (dest_avail > 0U) {
if (overlap_guard == 0U) { if (overlap_guard == 0U) {
pr_err("%s: overlap happened.", __func__); pr_err("%s: overlap happened.", __func__);
*(--d) = '\0'; d--;
*d = '\0';
return NULL; return NULL;
} }
@ -293,7 +294,8 @@ char *strncpy_s(char *d_arg, size_t dmax, const char *s_arg, size_t slen_arg)
while (dest_avail > 0U) { while (dest_avail > 0U) {
if (overlap_guard == 0U) { if (overlap_guard == 0U) {
pr_err("%s: overlap happened.", __func__); pr_err("%s: overlap happened.", __func__);
*(--d) = '\0'; d--;
*d = '\0';
return NULL; return NULL;
} }