Page MenuHomeFreeBSD

sound: Move global variable initialization to sound_modevent()
ClosedPublic

Authored by christos on Sep 22 2024, 3:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 17, 3:23 AM
Unknown Object (File)
Sat, Nov 16, 4:35 PM
Unknown Object (File)
Sat, Nov 16, 2:27 PM
Unknown Object (File)
Thu, Nov 14, 1:12 AM
Unknown Object (File)
Fri, Nov 1, 10:23 AM
Unknown Object (File)
Fri, Nov 1, 12:23 AM
Unknown Object (File)
Thu, Oct 31, 11:27 PM
Unknown Object (File)
Oct 18 2024, 10:23 AM
Subscribers

Details

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 Not Applicable
Unit
Tests Not Applicable

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
892

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.Sep 29 2024, 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.

  • s/sound_glob_init()/sound_global_init()/
  • Move indendation fix to separate patch: D46856
This revision now requires review to proceed.Oct 1 2024, 1:53 AM
This revision is now accepted and ready to land.Oct 1 2024, 10:36 AM