* [PATCH] ALSA: echoaudio: simplify get_audio_levels
@ 2019-12-07 22:49 Olof Johansson
2019-12-08 8:48 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Olof Johansson @ 2019-12-07 22:49 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai; +Cc: alsa-devel, linux-kernel, Olof Johansson
The loop optimizer seems to go astray here, and produces some warnings
that don't seem valid.
Still, the code can be simplified -- just clear the whole array at the
beginning, and fill in whatever values are valid on the platform.
Warnings before this change (GCC 8.2.0 ARM allmodconfig):
In file included from ../sound/pci/echoaudio/gina24.c:115:
../sound/pci/echoaudio/echoaudio.c: In function 'snd_echo_vumeters_get':
../sound/pci/echoaudio/echoaudio_dsp.c:647:9: warning: iteration 1073741824 invokes undefined behavior [-Waggressive-loop-optimizations]
In file included from ../sound/pci/echoaudio/layla24.c:112:
../sound/pci/echoaudio/echoaudio.c: In function 'snd_echo_vumeters_get':
../sound/pci/echoaudio/echoaudio_dsp.c:658:9: warning: iteration 1073741824 invokes undefined behavior [-Waggressive-loop-optimizations]
../sound/pci/echoaudio/echoaudio_dsp.c:647:9: warning: iteration 1073741824 invokes undefined behavior [-Waggressive-loop-optimizations]
Signed-off-by: Olof Johansson <olof@lixom.net>
---
sound/pci/echoaudio/echoaudio_dsp.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c
index 50d4a87a6bb34..f02f5b1568dee 100644
--- a/sound/pci/echoaudio/echoaudio_dsp.c
+++ b/sound/pci/echoaudio/echoaudio_dsp.c
@@ -635,36 +635,30 @@ This function assumes there are no more than 16 in/out busses or pipes
Meters is an array [3][16][2] of long. */
static void get_audio_meters(struct echoaudio *chip, long *meters)
{
- int i, m, n;
+ unsigned int i, m, n;
- m = 0;
- n = 0;
- for (i = 0; i < num_busses_out(chip); i++, m++) {
+ for (i = 0 ; i < 96; i++)
+ meters[i] = 0;
+
+ for (m = 0, n = 0, i = 0; i < num_busses_out(chip); i++, m++) {
meters[n++] = chip->comm_page->vu_meter[m];
meters[n++] = chip->comm_page->peak_meter[m];
}
- for (; n < 32; n++)
- meters[n] = 0;
#ifdef ECHOCARD_ECHO3G
m = E3G_MAX_OUTPUTS; /* Skip unused meters */
#endif
- for (i = 0; i < num_busses_in(chip); i++, m++) {
+ for (n = 32, i = 0; i < num_busses_in(chip); i++, m++) {
meters[n++] = chip->comm_page->vu_meter[m];
meters[n++] = chip->comm_page->peak_meter[m];
}
- for (; n < 64; n++)
- meters[n] = 0;
-
#ifdef ECHOCARD_HAS_VMIXER
- for (i = 0; i < num_pipes_out(chip); i++, m++) {
+ for (n = 64, i = 0; i < num_pipes_out(chip); i++, m++) {
meters[n++] = chip->comm_page->vu_meter[m];
meters[n++] = chip->comm_page->peak_meter[m];
}
#endif
- for (; n < 96; n++)
- meters[n] = 0;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: echoaudio: simplify get_audio_levels
2019-12-07 22:49 [PATCH] ALSA: echoaudio: simplify get_audio_levels Olof Johansson
@ 2019-12-08 8:48 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2019-12-08 8:48 UTC (permalink / raw)
To: Olof Johansson; +Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel
On Sat, 07 Dec 2019 23:49:53 +0100,
Olof Johansson wrote:
>
> The loop optimizer seems to go astray here, and produces some warnings
> that don't seem valid.
>
> Still, the code can be simplified -- just clear the whole array at the
> beginning, and fill in whatever values are valid on the platform.
>
> Warnings before this change (GCC 8.2.0 ARM allmodconfig):
>
> In file included from ../sound/pci/echoaudio/gina24.c:115:
> ../sound/pci/echoaudio/echoaudio.c: In function 'snd_echo_vumeters_get':
> ../sound/pci/echoaudio/echoaudio_dsp.c:647:9: warning: iteration 1073741824 invokes undefined behavior [-Waggressive-loop-optimizations]
> In file included from ../sound/pci/echoaudio/layla24.c:112:
> ../sound/pci/echoaudio/echoaudio.c: In function 'snd_echo_vumeters_get':
> ../sound/pci/echoaudio/echoaudio_dsp.c:658:9: warning: iteration 1073741824 invokes undefined behavior [-Waggressive-loop-optimizations]
> ../sound/pci/echoaudio/echoaudio_dsp.c:647:9: warning: iteration 1073741824 invokes undefined behavior [-Waggressive-loop-optimizations]
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
Applied now, thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-08 8:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-07 22:49 [PATCH] ALSA: echoaudio: simplify get_audio_levels Olof Johansson
2019-12-08 8:48 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox