From: Peter Dinda Date: Tue, 1 Sep 2015 20:21:34 +0000 (-0500) Subject: Cleanup and sanity-checking of switch issues, negative array indexes, operand indepen... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=9e70ba8a6d2bae61d62c99cbab56753cf1440716;p=palacios.git Cleanup and sanity-checking of switch issues, negative array indexes, operand independence (Coverity static analysis) --- diff --git a/linux_module/iface-pwrstat.c b/linux_module/iface-pwrstat.c index a823946..98ea8c0 100644 --- a/linux_module/iface-pwrstat.c +++ b/linux_module/iface-pwrstat.c @@ -109,7 +109,7 @@ static int rapl_check_unit (void) power_unit_divisor = 1 << value; /* time unit: 1/time_unit_divisor Seconds */ - value =(output & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET; + value = (output & TIME_UNIT_MASK) >> TIME_UNIT_OFFSET; time_unit_divisor = 1 << value; return 0; diff --git a/linux_module/iface-pwrstat.h b/linux_module/iface-pwrstat.h index 6d64cc1..eb22df3 100644 --- a/linux_module/iface-pwrstat.h +++ b/linux_module/iface-pwrstat.h @@ -41,6 +41,6 @@ #define ENERGY_UNIT_MASK 0x1F00 #define TIME_UNIT_OFFSET 0x10 -#define TIME_UNIT_MASK 0xF000 +#define TIME_UNIT_MASK 0xF0000 #endif diff --git a/palacios/src/devices/generic.c b/palacios/src/devices/generic.c index 23f00ce..1e06a80 100644 --- a/palacios/src/devices/generic.c +++ b/palacios/src/devices/generic.c @@ -194,14 +194,19 @@ static int generic_read_port_print_and_passthrough(struct guest_info * core, uin rc=generic_read_port_passthrough(core,port,src,length,priv_data); - PrintDebug(core->vm_info, core, " done ... read 0x"); - - for (i = 0; i < rc; i++) { - PrintDebug(core->vm_info, core, "%x", ((uint8_t *)src)[i]); + if (rc<0) { + PrintError(core->vm_info, core, "FAILED\n"); + return rc; + } else { + PrintDebug(core->vm_info, core, " done ... read 0x"); + + for (i = 0; i < rc; i++) { + PrintDebug(core->vm_info, core, "%x", ((uint8_t *)src)[i]); + } + + PrintDebug(core->vm_info, core, "\n"); } - - PrintDebug(core->vm_info, core, "\n"); - + return rc; } diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 6ecdb12..d78a1dc 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -1239,7 +1239,7 @@ int v3_is_svm_capable() { PrintDebug(VM_NONE, VCORE_NONE, "SVM_VM_CR_MSR = 0x%x 0x%x\n", vm_cr_high, vm_cr_low); - if ((vm_cr_low & SVM_VM_CR_MSR_svmdis) == 1) { + if (vm_cr_low & SVM_VM_CR_MSR_svmdis) { V3_Print(VM_NONE, VCORE_NONE, "SVM is available but is disabled.\n"); v3_cpuid(CPUID_SVM_REV_AND_FEATURE_IDS, &eax, &ebx, &ecx, &edx); diff --git a/palacios/src/palacios/vmm_paging.c b/palacios/src/palacios/vmm_paging.c index 03a158a..6fc880f 100644 --- a/palacios/src/palacios/vmm_paging.c +++ b/palacios/src/palacios/vmm_paging.c @@ -1043,6 +1043,7 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t { case PT_ENTRY_NOT_PRESENT: return -1; + break; case PT_ENTRY_PAGE: { pde32pae_t * guest_pde = NULL; @@ -1062,6 +1063,7 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t { case PT_ENTRY_NOT_PRESENT: return -1; + break; case PT_ENTRY_LARGE_PAGE: { addr_t large_page_pa = (addr_t)guest_pte_pa; @@ -1076,6 +1078,7 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t } return 0; } + break; case PT_ENTRY_PAGE: { pte32pae_t * guest_pte = NULL; @@ -1106,8 +1109,10 @@ int v3_drill_guest_pt_32pae(struct guest_info * info, v3_reg_t guest_cr3, addr_t return 0; } } + break; } } + break; default: PrintError(info->vm_info, info, "Invalid page type for PD32PAE\n"); return -1; diff --git a/palacios/src/palacios/vmm_perftune.c b/palacios/src/palacios/vmm_perftune.c index cef9831..0519ce1 100644 --- a/palacios/src/palacios/vmm_perftune.c +++ b/palacios/src/palacios/vmm_perftune.c @@ -37,6 +37,7 @@ void v3_strategy_driven_yield(struct guest_info *core, uint64_t time_since_l } else { v3_yield(core,-1); } + break; default: PrintError(core->vm_info, core, "Unknown yield strategy (%d) using GREEDY\n",core->vm_info->perf_options.yield_strategy.strategy); v3_yield(core,-1);