Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jul 2016 06:09:34 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r302705 - stable/10/usr.sbin/bhyve
Message-ID:  <201607130609.u6D69YxD012753@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Wed Jul 13 06:09:34 2016
New Revision: 302705
URL: https://svnweb.freebsd.org/changeset/base/302705

Log:
  MFC r302362,r302363,r302364,r302365,r302373:
  
  r302362:
  
  Fix gcc warnings
  
  - Remove -Wunused-but-set-variable (newcpu)
  - Always return VMEXIT_CONTINUE as the code always set retval to that value.
  
  r302363:
  
  Fix gcc warnings
  
  Put cfl/prdt under AHCI_DEBUG #defines as they are only used in
  those cases.
  
  r302364:
  
  Fix gcc warnings
  
  Add `WRAPPED_CTASSERT` macro by annotating CTASSERTs with __unused
  to deal with -Wunused-local-typedefs warnings from gcc 4.8+.
  All other compilers (clang, etc) use CTASSERT as-is. A more generic
  solution for this issue will be proposed after ^/stable/11 is forked.
  
  Consolidate all CTASSERTs under one block instead of inlining them in
  functions.
  
  r302365:
  
  Fix gcc warnings
  
  Remove -Wunused-but-set-variable (`error`). Cast calls with
  `(void)` to note that the return value is explicitly ignored.
  
  r302373:
  
  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).

Modified:
  stable/10/usr.sbin/bhyve/bhyverun.c
  stable/10/usr.sbin/bhyve/bhyverun.h
  stable/10/usr.sbin/bhyve/pci_ahci.c
  stable/10/usr.sbin/bhyve/pci_emul.c
  stable/10/usr.sbin/bhyve/pci_emul.h
  stable/10/usr.sbin/bhyve/pci_passthru.c
  stable/10/usr.sbin/bhyve/task_switch.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- stable/10/usr.sbin/bhyve/bhyverun.c	Wed Jul 13 05:58:46 2016	(r302704)
+++ stable/10/usr.sbin/bhyve/bhyverun.c	Wed Jul 13 06:09:34 2016	(r302705)
@@ -387,13 +387,11 @@ vmexit_wrmsr(struct vmctx *ctx, struct v
 static int
 vmexit_spinup_ap(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
 {
-	int newcpu;
-	int retval = VMEXIT_CONTINUE;
 
-	newcpu = spinup_ap(ctx, *pvcpu,
-			   vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip);
+	(void)spinup_ap(ctx, *pvcpu,
+		    vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip);
 
-	return (retval);
+	return (VMEXIT_CONTINUE);
 }
 
 #define	DEBUG_EPT_MISCONFIG

Modified: stable/10/usr.sbin/bhyve/bhyverun.h
==============================================================================
--- stable/10/usr.sbin/bhyve/bhyverun.h	Wed Jul 13 05:58:46 2016	(r302704)
+++ stable/10/usr.sbin/bhyve/bhyverun.h	Wed Jul 13 06:09:34 2016	(r302705)
@@ -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)
 

Modified: stable/10/usr.sbin/bhyve/pci_ahci.c
==============================================================================
--- stable/10/usr.sbin/bhyve/pci_ahci.c	Wed Jul 13 05:58:46 2016	(r302704)
+++ stable/10/usr.sbin/bhyve/pci_ahci.c	Wed Jul 13 06:09:34 2016	(r302705)
@@ -1724,19 +1724,25 @@ static void
 ahci_handle_slot(struct ahci_port *p, int slot)
 {
 	struct ahci_cmd_hdr *hdr;
+#ifdef AHCI_DEBUG
 	struct ahci_prdt_entry *prdt;
+#endif
 	struct pci_ahci_softc *sc;
 	uint8_t *cfis;
+#ifdef AHCI_DEBUG
 	int cfl;
+#endif
 
 	sc = p->pr_sc;
 	hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE);
+#ifdef AHCI_DEBUG
 	cfl = (hdr->flags & 0x1f) * 4;
+#endif
 	cfis = paddr_guest2host(ahci_ctx(sc), hdr->ctba,
 			0x80 + hdr->prdtl * sizeof(struct ahci_prdt_entry));
+#ifdef AHCI_DEBUG
 	prdt = (struct ahci_prdt_entry *)(cfis + 0x80);
 
-#ifdef AHCI_DEBUG
 	DPRINTF("\ncfis:");
 	for (i = 0; i < cfl; i++) {
 		if (i % 10 == 0)

Modified: stable/10/usr.sbin/bhyve/pci_emul.c
==============================================================================
--- stable/10/usr.sbin/bhyve/pci_emul.c	Wed Jul 13 05:58:46 2016	(r302704)
+++ stable/10/usr.sbin/bhyve/pci_emul.c	Wed Jul 13 06:09:34 2016	(r302705)
@@ -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>
@@ -760,8 +760,6 @@ pci_populate_msicap(struct msicap *msica
 {
 	int mmc;
 
-	CTASSERT(sizeof(struct msicap) == 14);
-
 	/* Number of msi messages must be a power of 2 between 1 and 32 */
 	assert((msgnum & (msgnum - 1)) == 0 && msgnum >= 1 && msgnum <= 32);
 	mmc = ffs(msgnum) - 1;
@@ -786,7 +784,6 @@ static void
 pci_populate_msixcap(struct msixcap *msixcap, int msgnum, int barnum,
 		     uint32_t msix_tab_size)
 {
-	CTASSERT(sizeof(struct msixcap) == 12);
 
 	assert(msix_tab_size % 4096 == 0);
 
@@ -937,8 +934,6 @@ pci_emul_add_pciecap(struct pci_devinst 
 	int err;
 	struct pciecap pciecap;
 
-	CTASSERT(sizeof(struct pciecap) == 60);
-
 	if (type != PCIEM_TYPE_ROOT_PORT)
 		return (-1);
 

Modified: stable/10/usr.sbin/bhyve/pci_emul.h
==============================================================================
--- stable/10/usr.sbin/bhyve/pci_emul.h	Wed Jul 13 05:58:46 2016	(r302704)
+++ stable/10/usr.sbin/bhyve/pci_emul.h	Wed Jul 13 06:09:34 2016	(r302705)
@@ -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);

Modified: stable/10/usr.sbin/bhyve/pci_passthru.c
==============================================================================
--- stable/10/usr.sbin/bhyve/pci_passthru.c	Wed Jul 13 05:58:46 2016	(r302704)
+++ stable/10/usr.sbin/bhyve/pci_passthru.c	Wed Jul 13 06:09:34 2016	(r302705)
@@ -361,7 +361,7 @@ msix_table_write(struct vmctx *ctx, int 
 	uint64_t *dest64;
 	size_t entry_offset;
 	uint32_t vector_control;
-	int error, index;
+	int index;
 
 	pi = sc->psc_pi;
 	if (offset >= pi->pi_msix.pba_offset &&
@@ -416,8 +416,8 @@ msix_table_write(struct vmctx *ctx, int 
 		/* If the entry is masked, don't set it up */
 		if ((entry->vector_control & PCIM_MSIX_VCTRL_MASK) == 0 ||
 		    (vector_control & PCIM_MSIX_VCTRL_MASK) == 0) {
-			error = vm_setup_pptdev_msix(ctx, vcpu,
-			    sc->psc_sel.pc_bus, sc->psc_sel.pc_dev, 
+			(void)vm_setup_pptdev_msix(ctx, vcpu,
+			    sc->psc_sel.pc_bus, sc->psc_sel.pc_dev,
 			    sc->psc_sel.pc_func, index, entry->addr,
 			    entry->msg_data, entry->vector_control);
 		}

Modified: stable/10/usr.sbin/bhyve/task_switch.c
==============================================================================
--- stable/10/usr.sbin/bhyve/task_switch.c	Wed Jul 13 05:58:46 2016	(r302704)
+++ stable/10/usr.sbin/bhyve/task_switch.c	Wed Jul 13 06:09:34 2016	(r302705)
@@ -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))



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