ALSA: echoaudio: simplify get_audio_levels
PATCH 1/1 ALSA: echoaudio: simplify get_audio_levels
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]
--- sound/pci/echoaudio/echoaudio_dsp.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
sound/pci/echoaudio/echoaudio_dsp.c +7 -13
@@ -635,36 +635,30 @@ This function assumes there are no more than 16 in/out busses or pipesMeters 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 ; }
Signature · 1 line
2.11.0
Quoted 17 lines · 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]
Quoted 1 line
Signed-off-by Olof Johansson <[email protected]>
Applied now, thanks.
Takashi