ALSA: pcm: use "do {} while (0)" for empty macro
PATCH 1/2 ALSA: pcm: use "do {} while (0)" for empty macro
Recent compilers produce a harmless warning for the new pcm_call_notify() macro when CONFIG_SND_PCM_OSS is disabled:
sound/core/pcm.c: In function 'snd_pcm_free':sound/core/pcm.c:905:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
This turns the empty macro into a 'do {} while (0)' statement to avoid the warning.
--- sound/core/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/pcm.c +1 -1
@@ -894,7 +894,7 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) _notify->call (pcm); \ } while (0) #else -#define pcm_call_notify (pcm, call)/* NOP */ +#define pcm_call_notify (pcm, call) do {} while (0)#endif static int snd_pcm_free (struct snd_pcm *pcm)
Signature · 1 line
2.9.0
PATCH 2/2 ALSA: pcm/oss: mark snd_pcm_plug_slave_format arg as const
Only one of the two declarations has the const modifier in the argument list, so we get a warning when CONFIG_SND_PCM_OSS_PLUGINS is disabled:
sound/core/oss/pcm_oss.c: In function 'snd_pcm_oss_change_params':sound/core/oss/pcm_oss.c:898:47: error: passing argument 2 of 'snd_pcm_plug_slave_format' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
This makes the two declarations match again.
--- sound/core/oss/pcm_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/oss/pcm_plugin.h +1 -1
@@ -172,7 +172,7 @@ snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,static inline snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t drv_size) {return drv_size; }static inline snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t clt_size) {return clt_size; } -static inline int snd_pcm_plug_slave_format (int format,struct snd_mask *format_mask) {return format; } +static inline int snd_pcm_plug_slave_format (int format,const struct snd_mask *format_mask) {return format; }#endif
Signature · 1 line
2.9.0
Re: [PATCH 2/2] ALSA: pcm/oss: mark snd_pcm_plug_slave_format arg as const
Hi,
Quoted 7 lines · Arnd Bergmann
Only one of the two declarations has the const modifier in the argument list, so we get a warning when
CONFIG_SND_PCM_OSS_PLUGINSis disabled:
sound/core/oss/pcm_oss.c: In function 'snd_pcm_oss_change_params':sound/core/oss/pcm_oss.c:898:47: error: passing argument 2 of 'snd_pcm_plug_slave_format' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
Quoted 7 lines
This makes the two declarations match again.
Fixes e76bf3c4b4e4 ("ALSA: pcm/oss: refer to parameters instead of copying to reduce usage of kernel stack")Signed-off-by Arnd Bergmann <[email protected]>--- sound/core/oss/pcm_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Indeed. I overlooked that it's conditional...
sound/core/oss/pcm_plugin.h snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, · line 177
Quoted 12 lines
sound/core/oss/pcm_plugin.h +1
-1@@ -172,7 +172,7 @@ snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,static inline snd_pcm_sframes_t snd_pcm_plug_client_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t drv_size) {return drv_size; }static inline snd_pcm_sframes_t snd_pcm_plug_slave_size (struct snd_pcm_substream *handle,snd_pcm_uframes_t clt_size) {return clt_size; } -static inline int snd_pcm_plug_slave_format (int format,struct snd_mask *format_mask) {return format; } +static inline int snd_pcm_plug_slave_format (int format,const struct snd_mask *format_mask) {return format; }#endif
Thanks :D
Takashi Sakamoto
Takashi Iwai
AppliedQuoted 4 lines · Arnd Bergmann
Recent compilers produce a harmless warning for the new
pcm_call_notify()macro whenCONFIG_SND_PCM_OSSis disabled:
Quoted 8 lines
sound/core/pcm.c: In function 'snd_pcm_free':sound/core/pcm.c:905:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]This turns the empty macro into a 'do {} while (0)' statement to avoid the warning.
Fixes 58f30d650c7f ("ALSA: pcm: Build pcm notifier code conditionally")Signed-off-by Arnd Bergmann <[email protected]>
Thanks, applied both patches now.
Takashi
Quoted 21 lines
--- sound/core/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sound/core/pcm.c +1
-1@@ -894,7 +894,7 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) _notify->call (pcm); \ } while (0) #else -#define pcm_call_notify (pcm, call)/* NOP */ +#define pcm_call_notify (pcm, call) do {} while (0)#endif static int snd_pcm_free (struct snd_pcm *pcm)Signature · 1 line
2.9.0