Page MenuHomeFreeBSD

sound: Move global variable initialization to sound_modevent()
AcceptedPublic

Authored by christos on Sun, Sep 22, 3:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 29, 1:11 PM
Unknown Object (File)
Sun, Sep 29, 7:08 AM
Unknown Object (File)
Sat, Sep 28, 11:34 AM
Unknown Object (File)
Wed, Sep 25, 1:25 AM
Unknown Object (File)
Tue, Sep 24, 10:41 PM
Unknown Object (File)
Tue, Sep 24, 4:27 PM
Subscribers

Details

Reviewers
markj
emaste
zlei
Summary

There is no reason to initialize global variables in feeder_register(),
as these variables are unrelated to what the function does. Instead,
initialize them during sound(4) load.

While here, fix the switch statement indentation in sound_modevent().

Sponsored by: The FreeBSD Foundation
MFC after: 2 days

Diff Detail

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

Event Timeline

zlei added inline comments.
sys/dev/sound/pcm/feeder.c
66

This can also be moved to event handler of MOD_LOAD IMHO.

69

For the initialization of root feeder, it is special, I guess it deserves a dedicated function, aka feeder_register_root(). Then change the SYSINIT accordingly,

-SYSINIT(feeder_root, SI_SUB_DRIVERS, SI_ORDER_FIRST, feeder_register, &feeder_root_class);
+SYSINIT(feeder_root, SI_SUB_DRIVERS, SI_ORDER_FIRST, feeder_register_root, &feeder_root_class);
sys/dev/sound/pcm/sound.c
895

I'd support you move the initialization of those global variables into a dedicated function. It will be much clear IMHO.

christos added inline comments.
sys/dev/sound/pcm/feeder.c
66

This list is internal to feeder.c, so I will just move it to the new feeder_register_root() function.

69
christos marked 2 inline comments as done.

Move to separate function.

This revision is now accepted and ready to land.Sun, Sep 29, 3:02 AM

I'd probably use the full word global rather than glob, as glob has an existing meaning (even if not related to this context) and it's only two extra letters.

The whitespace fixup should be a separate commit, that can go first.

I'd probably use the full word global rather than glob, as glob has an existing meaning (even if not related to this context) and it's only two extra letters.

The whitespace fixup should be a separate commit, that can go first.

+1 for global.