Add VM_LAST, a special last element in enum VM_GUEST and use it in CTASSERT

to ensure that vm_guest range is covered by vm_guest_sysctl_names.

Suggested by:	mjg
This commit is contained in:
Sergey Kandaurov 2013-11-12 20:13:10 +00:00
parent 21d1f635ee
commit 903093ecec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=258069
2 changed files with 3 additions and 1 deletions

View File

@ -156,6 +156,7 @@ static const char *const vm_guest_sysctl_names[] = {
"hv",
NULL
};
CTASSERT(nitems(vm_guest_sysctl_names) - 1 == VM_LAST);
#ifndef XEN
static const char *const vm_bnames[] = {

View File

@ -72,7 +72,8 @@ extern int vm_guest; /* Running as virtual machine guest? */
* ever implemented (e.g. vendor-specific paravirtualization features).
* Keep in sync with vm_guest_sysctl_names[].
*/
enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV };
enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV,
VM_LAST };
#if defined(WITNESS) || defined(INVARIANTS)
void kassert_panic(const char *fmt, ...) __printflike(1, 2);