summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-07-06 16:02:15 +0000
committerngie <ngie@FreeBSD.org>2016-07-06 16:02:15 +0000
commitb64ddb3c60b79359e9b0a27448021c6d5236f132 (patch)
tree30e081d3cc60beea0b41cc8887a4d8a256918bc5 /usr.sbin
parent89d01c24d15d07f044ec78b4f662e6df23069c91 (diff)
downloadFreeBSD-src-b64ddb3c60b79359e9b0a27448021c6d5236f132.zip
FreeBSD-src-b64ddb3c60b79359e9b0a27448021c6d5236f132.tar.gz
Fix CTASSERT issue in a more clean way
- Replace all CTASSERT macro instances with static_assert's. - Remove the WRAPPED_CTASSERT macro; it's now an unnecessary obfuscation. - Localize all static_assert's to the structures being tested. - Sort some headers per-style(9). Approved by: re (hrs) Differential Revision: https://reviews.freebsd.org/D7130 MFC after: 1 week X-MFC with: r302364 Reviewed by: ed, grehan (maintainer) Submitted by: ed Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bhyve/bhyverun.h6
-rw-r--r--usr.sbin/bhyve/pci_emul.c12
-rw-r--r--usr.sbin/bhyve/pci_emul.h3
-rw-r--r--usr.sbin/bhyve/task_switch.c6
4 files changed, 7 insertions, 20 deletions
diff --git a/usr.sbin/bhyve/bhyverun.h b/usr.sbin/bhyve/bhyverun.h
index c51bf48..39e115d 100644
--- a/usr.sbin/bhyve/bhyverun.h
+++ b/usr.sbin/bhyve/bhyverun.h
@@ -29,12 +29,6 @@
#ifndef _FBSDRUN_H_
#define _FBSDRUN_H_
-#ifndef CTASSERT /* Allow lint to override */
-#define CTASSERT(x) _CTASSERT(x, __LINE__)
-#define _CTASSERT(x, y) __CTASSERT(x, y)
-#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
-#endif
-
#define VMEXIT_CONTINUE (0)
#define VMEXIT_ABORT (-1)
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c
index 45253e8..4767915 100644
--- a/usr.sbin/bhyve/pci_emul.c
+++ b/usr.sbin/bhyve/pci_emul.c
@@ -31,9 +31,9 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/linker_set.h>
-#include <sys/errno.h>
#include <ctype.h>
+#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
@@ -755,16 +755,6 @@ pci_emul_init(struct vmctx *ctx, struct pci_devemu *pde, int bus, int slot,
return (err);
}
-#ifdef __GNU_C__
-#define WRAPPED_CTASSERT(x) CTASSERT(x) __unused
-#else
-#define WRAPPED_CTASSERT(x) CTASSERT(x)
-#endif
-
-WRAPPED_CTASSERT(sizeof(struct msicap) == 14);
-WRAPPED_CTASSERT(sizeof(struct msixcap) == 12);
-WRAPPED_CTASSERT(sizeof(struct pciecap) == 60);
-
void
pci_populate_msicap(struct msicap *msicap, int msgnum, int nextptr)
{
diff --git a/usr.sbin/bhyve/pci_emul.h b/usr.sbin/bhyve/pci_emul.h
index d6e5490..d74950b 100644
--- a/usr.sbin/bhyve/pci_emul.h
+++ b/usr.sbin/bhyve/pci_emul.h
@@ -160,6 +160,7 @@ struct msicap {
uint32_t addrhi;
uint16_t msgdata;
} __packed;
+static_assert(sizeof(struct msicap) == 14, "compile-time assertion failed");
struct msixcap {
uint8_t capid;
@@ -168,6 +169,7 @@ struct msixcap {
uint32_t table_info; /* bar index and offset within it */
uint32_t pba_info; /* bar index and offset within it */
} __packed;
+static_assert(sizeof(struct msixcap) == 12, "compile-time assertion failed");
struct pciecap {
uint8_t capid;
@@ -202,6 +204,7 @@ struct pciecap {
uint16_t slot_control2;
uint16_t slot_status2;
} __packed;
+static_assert(sizeof(struct pciecap) == 60, "compile-time assertion failed");
typedef void (*pci_lintr_cb)(int b, int s, int pin, int pirq_pin,
int ioapic_irq, void *arg);
diff --git a/usr.sbin/bhyve/task_switch.c b/usr.sbin/bhyve/task_switch.c
index 69dfaae..6138bcd 100644
--- a/usr.sbin/bhyve/task_switch.c
+++ b/usr.sbin/bhyve/task_switch.c
@@ -37,11 +37,11 @@ __FBSDID("$FreeBSD$");
#include <machine/vmm.h>
#include <machine/vmm_instruction_emul.h>
+#include <assert.h>
+#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <assert.h>
-#include <errno.h>
#include <vmmapi.h>
@@ -91,7 +91,7 @@ struct tss32 {
uint16_t tss_trap;
uint16_t tss_iomap;
};
-CTASSERT(sizeof(struct tss32) == 104);
+static_assert(sizeof(struct tss32) == 104, "compile-time assertion failed");
#define SEL_START(sel) (((sel) & ~0x7))
#define SEL_LIMIT(sel) (((sel) | 0x7))
OpenPOWER on IntegriCloud