From 8b4aff3eaca2e1379e93c41bdf515e44e26649b9 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 27 Jun 2018 18:47:32 -0400 Subject: [PATCH] freebsd11_network: Enable INVARIANTS at KDEBUG_LEVEL_2. They were already enabled for the net80211 code (and thus all the Wi-Fi drivers) unconditionally; now we enable them conditionally based on KDEBUG_LEVEL_2 for the freebsd11_network core code also. Includes fixes to the build, since there were some issues with INVARIANTS otherwise. --- .../compat/freebsd11_network/compat/sys/systm.h | 6 ++++++ src/libs/compat/freebsd11_network/if.c | 2 +- src/libs/compat/freebsd11_network/taskqueue.c | 2 +- src/libs/compat/freebsd11_network/unit.c | 13 +++++++------ .../freebsd11_wlan/net80211/ieee80211_haiku.h | 2 -- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/libs/compat/freebsd11_network/compat/sys/systm.h b/src/libs/compat/freebsd11_network/compat/sys/systm.h index 299a774575..b0bea94e55 100644 --- a/src/libs/compat/freebsd11_network/compat/sys/systm.h +++ b/src/libs/compat/freebsd11_network/compat/sys/systm.h @@ -28,7 +28,13 @@ int printf(const char *format, ...) __printflike(1, 2); #define ovbcopy(f, t, l) bcopy((f), (t), (l)) +#if KDEBUG_LEVEL_2 +#define INVARIANTS +#endif + +#if KDEBUG_LEVEL_1 #define bootverbose 1 +#endif #ifdef INVARIANTS #define KASSERT(cond,msg) do { \ diff --git a/src/libs/compat/freebsd11_network/if.c b/src/libs/compat/freebsd11_network/if.c index b9f6fe200f..3a23dbcf53 100644 --- a/src/libs/compat/freebsd11_network/if.c +++ b/src/libs/compat/freebsd11_network/if.c @@ -679,7 +679,7 @@ if_delmulti(struct ifnet *ifp, struct sockaddr *sa) { struct ifmultiaddr *ifma; int lastref; -#ifdef INVARIANTS +#if 0 /* def INVARIANTS */ struct ifnet *oifp; IFNET_RLOCK_NOSLEEP(); diff --git a/src/libs/compat/freebsd11_network/taskqueue.c b/src/libs/compat/freebsd11_network/taskqueue.c index 4574ca50f5..94b78a6641 100644 --- a/src/libs/compat/freebsd11_network/taskqueue.c +++ b/src/libs/compat/freebsd11_network/taskqueue.c @@ -327,7 +327,7 @@ taskqueue_enqueue_timeout(struct taskqueue *queue, cpu_status status; tq_lock(queue, &status); - KASSERT(timeout_task->q == NULL || timeout_task->q == queue, + KASSERT(ttask->q == NULL || ttask->q == queue, ("Migrated queue")); ttask->q = queue; res = ttask->t.ta_pending; diff --git a/src/libs/compat/freebsd11_network/unit.c b/src/libs/compat/freebsd11_network/unit.c index 0053875eef..1bfe8b90b1 100644 --- a/src/libs/compat/freebsd11_network/unit.c +++ b/src/libs/compat/freebsd11_network/unit.c @@ -13,6 +13,7 @@ #include #include +#include extern struct mtx gIdStoreLock; @@ -50,12 +51,12 @@ new_unrhdr(int low, int high, struct mtx* mutex) void delete_unrhdr(struct unrhdr* idStore) { - KASSERT(uh != NULL, + KASSERT(idStore != NULL, ("ID-Store: %s: NULL pointer as argument.", __func__)); mtx_lock(idStore->storeMutex); - KASSERT(uh->idBuffer->root_size == 0, + KASSERT(idStore->idBuffer->root_size == 0, ("ID-Store: %s: some ids are still in use..", __func__)); _delete_unrhdr_buffer_locked(idStore); @@ -71,7 +72,7 @@ alloc_unr(struct unrhdr* idStore) { int id; - KASSERT(uh != NULL, + KASSERT(idStore != NULL, ("ID-Store: %s: NULL pointer as argument.", __func__)); mtx_lock(idStore->storeMutex); @@ -85,13 +86,13 @@ alloc_unr(struct unrhdr* idStore) void free_unr(struct unrhdr* idStore, u_int identity) { - KASSERT(uh != NULL, + KASSERT(idStore != NULL, ("ID-Store: %s: NULL pointer as argument.", __func__)); mtx_lock(idStore->storeMutex); - KASSERT((int32)item - uh->idBias >= 0, ("ID-Store: %s(%p, %u): second " - + "parameter is not in interval.", __func__, uh, item)); + KASSERT((int32)identity - idStore->idBias >= 0, ("ID-Store: %s(%p, %u): second " + "parameter is not in interval.", __func__, idStore, identity)); _free_unr_locked(idStore, identity); diff --git a/src/libs/compat/freebsd11_wlan/net80211/ieee80211_haiku.h b/src/libs/compat/freebsd11_wlan/net80211/ieee80211_haiku.h index 023ca91097..4e8b3437aa 100644 --- a/src/libs/compat/freebsd11_wlan/net80211/ieee80211_haiku.h +++ b/src/libs/compat/freebsd11_wlan/net80211/ieee80211_haiku.h @@ -40,8 +40,6 @@ extern "C" { # endif -#define INVARIANTS 1 - #include #include #include