hv: fix build warning with gcc-11.2

dm/vrtc.c:565:33: error: 'current' may be used uninitialized in this
function.[-Werror=maybe-uninitialized]

Move the local variable definition into one code block to avoid warning.

Tracked-on: #7511
Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@linux.intel.com>
This commit is contained in:
Yuanyuan Zhao 2022-05-19 13:29:53 +08:00 committed by acrnsi-robot
parent eac0e335a8
commit 3062aa409f
1 changed files with 4 additions and 6 deletions

View File

@ -548,21 +548,19 @@ static bool vrtc_write(struct acrn_vcpu *vcpu, uint16_t addr, size_t width,
time_t current, after;
struct acrn_vrtc *vrtc = &vcpu->vm->vrtc;
struct acrn_vrtc temp_vrtc;
bool is_time_register;
uint8_t mask = 0xFFU;
if ((width == 1U) && (addr == CMOS_ADDR_PORT)) {
vrtc->addr = (uint8_t)(value & 0x7FU);
} else {
if (is_service_vm(vcpu->vm)) {
is_time_register = vrtc_is_time_register(vrtc->addr);
if (is_time_register) {
if (vrtc_is_time_register(vrtc->addr)) {
current = vrtc_get_physical_rtc_time(&temp_vrtc);
}
cmos_set_reg_val(vcpu->vm->vrtc.addr, (uint8_t)(value & 0xFFU));
if (is_time_register) {
after = vrtc_get_physical_rtc_time(&temp_vrtc);
vrtc_update_basetime(after, current - after);
} else {
cmos_set_reg_val(vcpu->vm->vrtc.addr, (uint8_t)(value & 0xFFU));
}
} else {
switch (vrtc->addr) {