From 539dccdcd169abe65e136a4da8b657a57a7556f7 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 20 Jul 2024 01:39:07 -0400 Subject: [PATCH] Simplify sound_card_init() by using a loop --- src/sound/sound.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/sound/sound.c b/src/sound/sound.c index 4820c45f9..254e529ca 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -221,14 +221,9 @@ sound_card_get_from_internal_name(const char *s) void sound_card_init(void) { - if ((sound_card_current[0] > SOUND_INTERNAL) && (sound_cards[sound_card_current[0]].device)) - device_add_inst(sound_cards[sound_card_current[0]].device, 1); - if ((sound_card_current[1] > SOUND_INTERNAL) && (sound_cards[sound_card_current[1]].device)) - device_add_inst(sound_cards[sound_card_current[1]].device, 2); - if ((sound_card_current[2] > SOUND_INTERNAL) && (sound_cards[sound_card_current[2]].device)) - device_add_inst(sound_cards[sound_card_current[2]].device, 3); - if ((sound_card_current[3] > SOUND_INTERNAL) && (sound_cards[sound_card_current[3]].device)) - device_add_inst(sound_cards[sound_card_current[3]].device, 4); + for (uint8_t i = 0; i < SOUND_CARD_MAX; i++) + if ((sound_card_current[i] > SOUND_INTERNAL) && (sound_cards[sound_card_current[i]].device)) + device_add_inst(sound_cards[sound_card_current[i]].device, i + 1); } void