linux-brain/sound
Arnd Bergmann eadf95a680 ALSA: opti9xx: shut up gcc-10 range warning
commit 5ce00760a84848d008554c693ceb6286f4d9c509 upstream.

gcc-10 points out a few instances of suspicious integer arithmetic
leading to value truncation:

sound/isa/opti9xx/opti92x-ad1848.c: In function 'snd_opti9xx_configure':
sound/isa/opti9xx/opti92x-ad1848.c:322:43: error: overflow in conversion from 'int' to 'unsigned char' changes value from '(int)snd_opti9xx_read(chip, 3) & -256 | 240' to '240' [-Werror=overflow]
  322 |   (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
sound/isa/opti9xx/opti92x-ad1848.c:351:3: note: in expansion of macro 'snd_opti9xx_write_mask'
  351 |   snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff);
      |   ^~~~~~~~~~~~~~~~~~~~~~
sound/isa/opti9xx/miro.c: In function 'snd_miro_configure':
sound/isa/opti9xx/miro.c:873:40: error: overflow in conversion from 'int' to 'unsigned char' changes value from '(int)snd_miro_read(chip, 3) & -256 | 240' to '240' [-Werror=overflow]
  873 |   (snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask)))
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
sound/isa/opti9xx/miro.c:1010:3: note: in expansion of macro 'snd_miro_write_mask'
 1010 |   snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff);
      |   ^~~~~~~~~~~~~~~~~~~

These are all harmless here as only the low 8 bit are passed down
anyway. Change the macros to inline functions to make the code
more readable and also avoid the warning.

Strictly speaking those functions also need locking to make the
read/write pair atomic, but it seems unlikely that anyone would
still run into that issue.

Fixes: 1841f613fd ("[ALSA] Add snd-miro driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200429190216.85919-1-arnd@arndb.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-06 08:13:32 +02:00
..
ac97 ALSA: ac97: Fix double free of ac97_codec_device 2019-07-31 07:27:11 +02:00
aoa ALSA: aoa: onyx: always initialize register read value 2020-01-27 14:51:02 +01:00
arm ASoC: pxa2xx-pcm-lib: fix indenting 2018-06-29 12:05:05 +01:00
atmel ASoC: Updates for v4.14 2017-09-04 14:50:49 +02:00
core ALSA: pcm: oss: Place the plugin buffer overflow checks correctly 2020-05-06 08:13:28 +02:00
drivers ALSA: dummy: Fix PCM format loop in proc output 2020-02-11 04:33:56 -08:00
firewire ALSA: dice: fix fallback from protocol extension into limited functionality 2020-01-23 08:21:28 +01:00
hda ALSA: hda: do not override bus codec_mask in link_get() 2020-03-11 14:14:47 +01:00
i2c ALSA: i2c/cs8427: Fix int to char conversion 2019-12-01 09:16:36 +01:00
isa ALSA: opti9xx: shut up gcc-10 range warning 2020-05-06 08:13:32 +02:00
mips ALSA: pcm: Nuke snd_pcm_lib_mmap_vmalloc() 2018-07-18 08:24:29 +02:00
oss treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00
parisc License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci ALSA: hda/hdmi: fix without unlocked before return 2020-05-06 08:13:27 +02:00
pcmcia Merge branch 'for-linus' into topic/virmidi 2018-07-29 22:39:29 +02:00
ppc powerpc/ps3: Set driver coherent_dma_mask 2018-07-20 12:50:37 +10:00
sh ALSA: sh: Fix compile warning wrt const 2020-02-24 08:34:45 +01:00
soc ASoC: wm8960: Fix wrong clock after suspend & resume 2020-05-02 17:25:50 +02:00
sparc ALSA: sparc: Fix invalid snd_free_pages() at error path 2018-12-05 19:32:08 +01:00
spi License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
synth ALSA: emux: Fix potential Spectre v1 vulnerabilities 2019-01-09 17:38:36 +01:00
usb ALSA: usb-audio: Correct a typo of NuPrime DAC-10 USB ID 2020-05-06 08:13:27 +02:00
x86 ALSA: x86: Fix runtime PM for hdmi-lpe-audio 2019-03-27 14:14:41 +09:00
xen ALSA: xen: Use standard pcm_format_to_bits() for ALSA format bits 2018-07-27 09:05:34 +02:00
Kconfig ALSA: xen-front: Introduce Xen para-virtualized sound frontend driver 2018-05-16 12:58:36 +02:00
Makefile ALSA: xen-front: Introduce Xen para-virtualized sound frontend driver 2018-05-16 12:58:36 +02:00
ac97_bus.c
last.c
sound_core.c sound: fix a memory leak bug 2019-08-16 10:12:39 +02:00