Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Nov 2023 15:39:27 GMT
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 733a66841d70 - main - Fix up the vm_guest_sysctl_names size assert.
Message-ID:  <202311061539.3A6FdR1r042141@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=733a66841d70c6934f073d227db10678d6ef5226

commit 733a66841d70c6934f073d227db10678d6ef5226
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-11-06 15:38:06 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-11-06 15:39:17 +0000

    Fix up the vm_guest_sysctl_names size assert.
    
    As VM_LAST was included in the array, the size check had to always pass.
    
    While here modernize the assert itself.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/kern/subr_param.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
index b7dbf606f492..933bc8d645be 100644
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -158,9 +158,9 @@ static const char *const vm_guest_sysctl_names[] = {
 	[VM_GUEST_BHYVE] = "bhyve",
 	[VM_GUEST_VBOX] = "vbox",
 	[VM_GUEST_PARALLELS] = "parallels",
-	[VM_LAST] = NULL
 };
-CTASSERT(nitems(vm_guest_sysctl_names) - 1 == VM_LAST);
+_Static_assert(nitems(vm_guest_sysctl_names) == VM_LAST,
+    "new vm guest type not added to vm_guest_sysctl_names");
 
 /*
  * Boot time overrides that are not scaled against main memory



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311061539.3A6FdR1r042141>