On Sat, 21 Dec 2024, Adrian Chadd wrote:
hi!
i've started on the bare minimum to start cleaning up the way we handle
channels in net80211. The first part - no matter what direction we
eventually DO go - is to try and remove all of the direct pointer
comparisons and dereferences that are going on.
So along this topic, i've created a diff to demonstrate a couple of those
cases:
https://reviews.freebsd.org/D48172
Specifically:
* IEEE80211_IS_CHAN_DEFINED() returns true if the channel isn't null; and
I am sceptical about this one; see further below.
* IEEE80211_IS_CHAN_ANYC() returns true if the channel is the "any channel"
channel (ie IEEE80211_CHAN_ANYC).
I would suggest to keep the IEEE80211_CHAN_ prefix and insert the IS
after that: IEEE80211_CHAN_IS_ANYC()
There are a bunch of places in net80211 and sys/dev that manually check if
the channel is NULL / the channel is/isn't ANYC. My proposal is we go
through, find them all and convert them to these macros.
From looking through the code I would hypothesize that if NULL checks
are not for local state most of them are either a result of copy&paste
in multi-OS-ported drivers or there as a result of crashes due to race
conditions/insufficient locking in net80211 and most should simply never
occur. Plasting them behind a IEEE80211_CHAN_IS_DEFINED (or IS_VALID
whatever you'd name it) is likely not helpful to fix the underlying
issues upfront. I would wonder if most could go away or should me made
sure to have a valid state (often coming along with the ANYC check
anyway?).
There are also plain "ANY" (no C) cases which should also be covered but
they fit even less into this scheme.
I'd appreciate feedback! If everyone's ok with this and it gets landed,
then this can be a nice mini-project for someone to go get dirty in the
net80211 stack / wireless drivers and participate a bit in the general
cleanup.
Thanks,
-adrian
--
Bjoern A. Zeeb r15:7