Page MenuHomeFreeBSD

sound: Remove redundant KASSERTs from unit.c
AbandonedPublic

Authored by christos on Thu, Apr 18, 2:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 9, 2:33 PM
Unknown Object (File)
Sat, Apr 27, 1:00 PM
Unknown Object (File)
Fri, Apr 26, 11:31 AM
Unknown Object (File)
Sat, Apr 20, 6:00 PM
Subscribers

Details

Reviewers
markj
emaste
Summary

All functions in unit.c have a KASSERT testing whether snd_unit has been
initialized (i.e snd_unit_init() has been called). However,
snd_unit_init() is called unconditionally upon sound(4) load in
dsp_sysinit(), so the KASSERTs will never fail.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 57171
Build 54059: arc lint + arc unit

Event Timeline

sys/dev/sound/unit.c
163–164

We'd first need to make sure this case cannot happen (e.g. turning this into a KASSERT that we're not called twice)

christos marked an inline comment as done.

Address Ed's comment.

sys/dev/sound/unit.c
163–164

Although it should most likely not be a problem to remove this check, I will keep it for now to make sure nothing has went off my radar.

However, snd_unit_init() is called unconditionally upon sound(4) load in dsp_sysinit(), so the KASSERTs will never fail.

But the sound module can have multiple sysinits, and some of them might run before dsp_sysinit(). If that happens and they use these accessors, you'll end up with a confusing bug.

I don't object to the change, but the argument for making the change isn't really correct as I understand it. As a middle ground you could at least simplify the macro and just use a plain KASSERT everywhere, I think that's good enough. It's up to you.

Abandoning since I will be submitting a patch which eventually gets rid of unit.* completely.