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.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2016-07-06 05:02:59 +00:00
parent f94fd843f4
commit edb603345b

View File

@ -755,13 +755,21 @@ 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)
{
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 +794,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 +944,6 @@ pci_emul_add_pciecap(struct pci_devinst *pi, int type)
int err;
struct pciecap pciecap;
CTASSERT(sizeof(struct pciecap) == 60);
if (type != PCIEM_TYPE_ROOT_PORT)
return (-1);