hv: fix 'No brackets to then/else'

- add missing brackets for 'if/else' statements based on MISRA-C
  requirements

v1 -> v2:
 * add brackets for each conditions in 'if' statements to improve
   the readability
 * modify 'ptdev_init' to make the logic clearer

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
This commit is contained in:
Shiqing Gao
2018-09-30 14:04:18 +08:00
committed by wenlingz
parent 71927f3c5b
commit 0317cfb2b6
23 changed files with 131 additions and 72 deletions

View File

@@ -128,8 +128,9 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
va_end(args);
/* Check if flags specify to output to NPK */
if (do_npk_log)
if (do_npk_log) {
npk_log_write(buffer, strnlen_s(buffer, LOG_MESSAGE_MAX_SIZE));
}
/* Check if flags specify to output to stdout */
if (do_console_log) {

View File

@@ -38,23 +38,28 @@ void npk_log_setup(struct hv_npk_log_param *param)
param->mmio_addr);
param->res = HV_NPK_LOG_RES_KO;
if (atomic_inc_return(&npk_log_setup_ref) > 1)
if (atomic_inc_return(&npk_log_setup_ref) > 1) {
goto out;
}
switch (param->cmd) {
case HV_NPK_LOG_CMD_CONF:
if ((param->mmio_addr != 0UL) || (param->loglevel != 0xffffU))
if ((param->mmio_addr != 0UL) || (param->loglevel != 0xffffU)) {
param->res = HV_NPK_LOG_RES_OK;
}
/* falls through */
case HV_NPK_LOG_CMD_ENABLE:
if (param->mmio_addr != 0UL)
if (param->mmio_addr != 0UL) {
base = param->mmio_addr;
if (param->loglevel != 0xffffU)
}
if (param->loglevel != 0xffffU) {
npk_loglevel = param->loglevel;
}
if ((base != 0UL) && (param->cmd == HV_NPK_LOG_CMD_ENABLE)) {
if (!npk_log_enabled)
if (!npk_log_enabled) {
for (i = 0; i < phys_cpu_num; i++)
per_cpu(npk_log_ref, i) = 0;
}
param->res = HV_NPK_LOG_RES_OK;
npk_log_enabled = 1;
}
@@ -88,8 +93,9 @@ void npk_log_write(const char *buf, size_t buf_len)
uint32_t ref;
uint16_t len;
if (!npk_log_enabled || (channel == NULL))
if (!npk_log_enabled || (channel == NULL)) {
return;
}
/* calculate the channel offset based on cpu_id and npk_log_ref */
ref = (atomic_inc_return((int32_t *)&per_cpu(npk_log_ref, cpu_id)) - 1)

View File

@@ -661,9 +661,9 @@ static int shell_vcpu_dumpreg(int argc, char **argv)
dump.vcpu = vcpu;
dump.str = shell_log_buf;
dump.str_max = CPU_PAGE_SIZE;
if (vcpu->pcpu_id == get_cpu_id())
if (vcpu->pcpu_id == get_cpu_id()) {
vcpu_dumpreg(&dump);
else {
} else {
bitmap_set_nolock(vcpu->pcpu_id, &mask);
smp_call_function(mask, vcpu_dumpreg, &dump);
}