Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Nov 2013 20:13:11 +0000 (UTC)
From:      Sergey Kandaurov <pluknet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r258069 - in head/sys: kern sys
Message-ID:  <201311122013.rACKDBTx090543@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pluknet
Date: Tue Nov 12 20:13:10 2013
New Revision: 258069
URL: http://svnweb.freebsd.org/changeset/base/258069

Log:
  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

Modified:
  head/sys/kern/subr_param.c
  head/sys/sys/systm.h

Modified: head/sys/kern/subr_param.c
==============================================================================
--- head/sys/kern/subr_param.c	Tue Nov 12 20:00:51 2013	(r258068)
+++ head/sys/kern/subr_param.c	Tue Nov 12 20:13:10 2013	(r258069)
@@ -156,6 +156,7 @@ static const char *const vm_guest_sysctl
 	"hv",
 	NULL
 };
+CTASSERT(nitems(vm_guest_sysctl_names) - 1 == VM_LAST);
 
 #ifndef XEN
 static const char *const vm_bnames[] = {

Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Tue Nov 12 20:00:51 2013	(r258068)
+++ head/sys/sys/systm.h	Tue Nov 12 20:13:10 2013	(r258069)
@@ -72,7 +72,8 @@ extern int vm_guest;		/* Running as virt
  * 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);



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