Skip to content

Commit 98aa74b

Browse files
shiqingglijinxia
authored andcommitted
hv: treewide: fix 'No default case in switch statement'
MISRAC requires that a switch statement shall contain a default clause. This patch add the default clause and some comments for the ones violated the rule. Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 2a65681 commit 98aa74b

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

hypervisor/arch/x86/guest/instr_emul.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,19 @@ static int decode_sib(struct instr_emul_vie *vie)
18931893
case VIE_MOD_INDIRECT_DISP32:
18941894
vie->disp_bytes = 4U;
18951895
break;
1896+
default:
1897+
/*
1898+
* All possible values of 'vie->mod':
1899+
* 1. VIE_MOD_DIRECT
1900+
* has been handled at the start of this function
1901+
* 2. VIE_MOD_INDIRECT_DISP8
1902+
* has been handled in prior case clauses
1903+
* 3. VIE_MOD_INDIRECT_DISP32
1904+
* has been handled in prior case clauses
1905+
* 4. VIE_MOD_INDIRECT
1906+
* will be handled later after this switch statement
1907+
*/
1908+
break;
18961909
}
18971910

18981911
if (vie->mod == VIE_MOD_INDIRECT &&

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,12 @@ vlapic_icrlo_write_handler(struct acrn_vlapic *vlapic)
11271127
dmask = vm_active_cpus(vlapic->vm);
11281128
bitmap_clear_lock(vlapic->vcpu->vcpu_id, &dmask);
11291129
break;
1130+
default:
1131+
/*
1132+
* All possible values of 'shorthand' has been handled in prior
1133+
* case clauses.
1134+
*/
1135+
break;
11301136
}
11311137

11321138
while ((vcpu_id = ffs64(dmask)) != INVALID_BIT_INDEX) {

hypervisor/arch/x86/guest/vpic.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,18 @@ int vpic_set_irq_trigger(struct vm *vm, uint32_t irq, enum vpic_trigger trigger)
579579
case 8U:
580580
case 13U:
581581
return -EINVAL;
582+
default:
583+
/*
584+
* The IRQs handled earlier are the ones that could only
585+
* support edge trigger, while the input parameter
586+
* 'trigger' is set as LEVEL_TRIGGER. So, an error code
587+
* (-EINVAL) shall be returned due to the invalid
588+
* operation.
589+
*
590+
* All the other IRQs will be handled properly after
591+
* this switch statement.
592+
*/
593+
break;
582594
}
583595
}
584596

0 commit comments

Comments
 (0)