Sound: pci: Fix unused variable warning in patch_sigmatel.c
Subsystems (2)
PATCH 1/1 Sound: pci: Fix unused variable warning in patch_sigmatel.c
Fix the following build warnings
sound/pci/hda/patch_sigmatel.c: In function ‘stac92hd71bxx_fixup_hp’:sound/pci/hda/patch_sigmatel.c:2434:24: warning: unused variable ‘spec’ [-Wunused-variable]
--- sound/pci/hda/patch_sigmatel.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
sound/pci/hda/patch_sigmatel.c +5 -9
@@ -2365,7 +2365,6 @@ static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,static void stac92hd71bxx_fixup_hp_m4 (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -struct sigmatel_spec *spec = codec->spec;struct hda_jack_tbl *jack;if (action !=HDA_FIXUP_ACT_PRE_PROBE )
@@ -2381,7 +2380,7 @@ static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,if (jack) jack->private_data =0x02 ; - spec->gpio_mask |=0x02 ; + ((struct sigmatel_spec *)codec->spec)->gpio_mask |=0x02 ;/* enable internal microphone */ snd_hda_codec_set_pincfg (codec,0x0e ,0x01813040 );
@@ -2420,19 +2419,15 @@ static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,static void stac92hd71bxx_fixup_hp_hdx (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -struct sigmatel_spec *spec = codec->spec; -if (action !=HDA_FIXUP_ACT_PRE_PROBE )return ; - spec->gpio_led =0x08 ; + ((struct sigmatel_spec *)codec->spec)->gpio_led =0x08 ; }static void stac92hd71bxx_fixup_hp (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -struct sigmatel_spec *spec = codec->spec; -if (action !=HDA_FIXUP_ACT_PRE_PROBE )return ;
@@ -2456,8 +2451,9 @@ static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,if (find_mute_led_cfg (codec,1 ))snd_printd ("mute LED gpio %d polarity %d\n" , - spec->gpio_led, - spec->gpio_led_polarity); + ((struct sigmatel_spec *)codec->spec)->gpio_led, + ((struct sigmatel_spec *)codec->spec)-> + gpio_led_polarity); }
Signature · 1 line
1.8.1
At Fri, 25 Jan 2013 00:38:06 +0200,
Quoted 5 lines · Stratos Karafotis
Fix the following build warnings
sound/pci/hda/patch_sigmatel.c: In function ‘stac92hd71bxx_fixup_hp’:sound/pci/hda/patch_sigmatel.c:2434:24: warning: unused variable ‘spec’ [-Wunused-variable]
Thanks for catching. But such temporal cast like your patch makes the code readability much worse. The code readability (thus its maintainability) is a more important factor.
I'm going to fix the definition of snd_printd() itself for fixing this kind of warnings. We can use inline functions instead of empty macros to achieve the same but without triggering compiler warnings.
Takashi
Quoted 63 lines
Signed-off-by Stratos Karafotis <[email protected]>--- sound/pci/hda/patch_sigmatel.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)sound/pci/hda/patch_sigmatel.c +5
-9@@ -2365,7 +2365,6 @@ static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,static void stac92hd71bxx_fixup_hp_m4 (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -struct sigmatel_spec *spec = codec->spec;struct hda_jack_tbl *jack;if (action !=HDA_FIXUP_ACT_PRE_PROBE )@@ -2381,7 +2380,7 @@ static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,if (jack) jack->private_data =0x02 ; - spec->gpio_mask |=0x02 ; + ((struct sigmatel_spec *)codec->spec)->gpio_mask |=0x02 ;/* enable internal microphone */ snd_hda_codec_set_pincfg (codec,0x0e ,0x01813040 );@@ -2420,19 +2419,15 @@ static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,static void stac92hd71bxx_fixup_hp_hdx (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -struct sigmatel_spec *spec = codec->spec; -if (action !=HDA_FIXUP_ACT_PRE_PROBE )return ; - spec->gpio_led =0x08 ; + ((struct sigmatel_spec *)codec->spec)->gpio_led =0x08 ; }static void stac92hd71bxx_fixup_hp (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -struct sigmatel_spec *spec = codec->spec; -if (action !=HDA_FIXUP_ACT_PRE_PROBE )return ;@@ -2456,8 +2451,9 @@ static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,if (find_mute_led_cfg (codec,1 ))snd_printd ("mute LED gpio %d polarity %d\n" , - spec->gpio_led, - spec->gpio_led_polarity); + ((struct sigmatel_spec *)codec->spec)->gpio_led, + ((struct sigmatel_spec *)codec->spec)-> + gpio_led_polarity); }Signature · 1 line
1.8.1
Quoted 5 lines · Takashi Iwai
At Fri, 25 Jan 2013 00:38:06 +0200,
Quoted 3 lines · Stratos Karafotis
Fix the following build warnings
sound/pci/hda/patch_sigmatel.c: In function ‘stac92hd71bxx_fixup_hp’:sound/pci/hda/patch_sigmatel.c:2434:24: warning: unused variable ‘spec’ [-Wunused-variable]
[]
Quoted 3 lines
I'm going to fix the definition of
snd_printd()itself for fixing this kind of warnings. We can use inline functions instead of empty macros to achieve the same but without triggering compiler warnings.
It's probably better to use a macro like:
do { \
if (0) \
printk(fmt, ##__VA_ARGS__); \
} while (0)to allow the compiler to avoid any argument evaluation while still doing fmt/arg matching.
Something like:
include/sound/core.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
include/sound/core.h +11 -2
@@ -394,8 +394,17 @@ void __snd_printk(unsigned int level, const char *file, int line,#else /* !CONFIG_SND_DEBUG */ -#define snd_printd(fmt, args...) do { } while (0) -#define _snd_printd(level, fmt, args...) do { } while (0) +#define snd_printd (fmt, ...) \ +do { \ + if (0) \ + __snd_printk(1, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \ +} while (0) +#define _snd_printd (level, fmt, ...) \ +do { \ + if (0) \ + __snd_printk(level, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \ +} while (0) +#define snd_BUG () do { } while (0)static inline int __snd_bug_on (int cond) {
At Fri, 25 Jan 2013 02:03:16 -0800,
Quoted 14 lines · Joe Perches
Quoted 5 lines · Takashi Iwai
At Fri, 25 Jan 2013 00:38:06 +0200,
Quoted 3 lines · Stratos Karafotis
Fix the following build warnings
sound/pci/hda/patch_sigmatel.c: In function ‘stac92hd71bxx_fixup_hp’:sound/pci/hda/patch_sigmatel.c:2434:24: warning: unused variable ‘spec’ [-Wunused-variable][]
Quoted 3 lines
I'm going to fix the definition of
snd_printd()itself for fixing this kind of warnings. We can use inline functions instead of empty macros to achieve the same but without triggering compiler warnings.It's probably better to use a macro like:
Quoted 7 lines
do { \ if (0) \ printk(fmt, ##__VA_ARGS__); \ } while (0)to allow the compiler to avoid any argument evaluation while still doing fmt/arg matching.
Hm, this would work, too.
FWIW, the patch below is the patch I mentioned in the above. I don't mind whether it's macro with if (0) or an empty inline function...
Takashi
---
From: Takashi Iwai <[email protected]>
Subject: [PATCH] ALSA: Make snd_printd() and snd_printdd() inline
Because currently snd_printd() and snd_printdd() macros are expanded
to empty when CONFIG_SND_DEBUG=n, a compile warning like below
appears sometimes, and we had to covert it by ugly ifdefs:
sound/pci/hda/patch_sigmatel.c: In function ‘stac92hd71bxx_fixup_hp’:
sound/pci/hda/patch_sigmatel.c:2434:24: warning: unused variable ‘spec’ [-Wunused-variable]
For "fixing" these issues better, this patch replaces snd_printd() and snd_printdd() definitions with empty inline functions instead of macros. This should have the same effect but shut up warnings like above.
But since we had already put ifdefs, changing to inline functions would trigger compile errors. So, such ifdefs is removed in this patch.
In addition, snd_pci_quirk name field is defined only when CONFIG_SND_DEBUG_VERBOSE is set, and the reference to it in snd_printdd() argument triggers the build errors, too. For avoiding these errors, introduce a new macro snd_pci_quirk_name() that is defined no matter how the debug option is set.
--- include/sound/core.h | 12 +++++++++--- sound/drivers/vx/vx_core.c | 3 +-- sound/pci/atiixp.c | 5 +++-- sound/pci/hda/hda_auto_parser.c | 2 -- sound/pci/hda/hda_generic.c | 2 -- sound/pci/intel8x0.c | 10 ++++++---- sound/pci/maestro3.c | 10 ++++++---- sound/pci/nm256/nm256.c | 3 ++- sound/pci/pcxhr/pcxhr_core.c | 3 +-- sound/pci/via82xx.c | 2 +- sound/usb/pcm.c | 2 -- 11 files changed, 29 insertions(+), 25 deletions(-)
include/sound/core.h +9 -3
@@ -394,8 +394,11 @@ void __snd_printk(unsigned int level, const char *file, int line,#else /* !CONFIG_SND_DEBUG */ -#define snd_printd(fmt, args...) do { } while (0) -#define _snd_printd(level, fmt, args...) do { } while (0) +__printf(1, 2) +static inline void snd_printd (const char *format, ...) {} +__printf(2, 3) +static inline void _snd_printd (int level,const char *format, ...) {} +#define snd_BUG () do { } while (0)static inline int __snd_bug_on (int cond) {
@@ -416,7 +419,8 @@ static inline int __snd_bug_on(int cond) #define snd_printdd(format, args...) \ __snd_printk(2, __FILE__, __LINE__, format, ##args)#else -#define snd_printdd(format, args...) do { } while (0) +__printf(1, 2) +static inline void snd_printdd (const char *format, ...) {}#endif
@@ -454,6 +458,7 @@ struct snd_pci_quirk {#define SND_PCI_QUIRK_MASK (vend, mask, dev, xname, val) \ {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), \ .value = (val), .name = (xname)} +#define snd_pci_quirk_name (q) ((q)->name)#else #define SND_PCI_QUIRK (vend,dev,xname,val) \ {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)}
@@ -461,6 +466,7 @@ struct snd_pci_quirk { {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), .value = (val)}#define SND_PCI_QUIRK_VENDOR (vend, xname, val) \ {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val)} +#define snd_pci_quirk_name (q) NULL#endif const struct snd_pci_quirk *
sound/drivers/vx/vx_core.c +1 -2
@@ -52,7 +52,6 @@ MODULE_LICENSE("GPL");int snd_vx_check_reg_bit (struct vx_core *chip,int reg,int mask,int bit,int time) {unsigned long end_time = jiffies + (time *HZ +999 ) /1000 ; -#ifdef CONFIG_SND_DEBUG static char *reg_names[VX_REG_MAX ] = {"ICR" ,"CVR" ,"ISR" ,"IVR" ,"RXH" ,"RXM" ,"RXL" ,"DMA" ,"CDSP" ,"RFREQ" ,"RUER/V2" ,"DATA" ,"MEMIRQ" ,
@@ -60,7 +59,7 @@ int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int t"MIC3" ,"INTCSR" ,"CNTRL" ,"GPIOC" ,"LOFREQ" ,"HIFREQ" ,"CSUER" ,"RUER" }; -#endif + do { if ((snd_vx_inb(chip, reg) & mask) == bit) return 0;
sound/pci/atiixp.c +3 -2
@@ -567,8 +567,9 @@ static int ac97_probing_bugs(struct pci_dev *pci) q =snd_pci_quirk_lookup (pci, atiixp_quirks);if (q) { -snd_printdd (KERN_INFO "Atiixp quirk for %s. " -"Forcing codec %d\n" , q->name, q->value); +snd_printdd (KERN_INFO +"Atiixp quirk for %s. Forcing codec %d\n" , +snd_pci_quirk_name (q), q->value);return q->value; }/* this hardware doesn't need workarounds. Probe for codec */
sound/pci/hda/hda_auto_parser.c +0 -2
@@ -698,9 +698,7 @@ static void set_pin_targets(struct hda_codec *codec,static void apply_fixup (struct hda_codec *codec,int id,int action,int depth) { -#ifdef CONFIG_SND_DEBUG_VERBOSE const char *modelname = codec->fixup_name; -#endif while (id >=0 ) {const struct hda_fixup *fix = codec->fixup_list + id;
sound/pci/hda/hda_generic.c +0 -2
@@ -1579,9 +1579,7 @@ static void debug_show_configs(struct hda_codec *codec, struct auto_pin_cfg *cfg) {struct hda_gen_spec *spec = codec->spec; -#ifdef CONFIG_SND_DEBUG_VERBOSE static const char *const lo_type[3 ] = {"LO" ,"SP" ,"HP" }; -#endif int i; debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x (type %s)\n",
sound/pci/intel8x0.c +6 -4
@@ -3266,11 +3266,13 @@ static int check_default_spdif_aclink(struct pci_dev *pci) w =snd_pci_quirk_lookup (pci, spdif_aclink_defaults);if (w) {if (w->value) -snd_printdd (KERN_INFO "intel8x0: Using SPDIF over " -"AC-Link for %s\n" , w->name); +snd_printdd (KERN_INFO +"intel8x0: Using SPDIF over AC-Link for %s\n" , +snd_pci_quirk_name (w));else -snd_printdd (KERN_INFO "intel8x0: Using integrated " -"SPDIF DMA for %s\n" , w->name); +snd_printdd (KERN_INFO +"intel8x0: Using integrated SPDIF DMA for %s\n" , +snd_pci_quirk_name (w));return w->value; }return 0 ;
sound/pci/maestro3.c +6 -4
@@ -2586,8 +2586,9 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,else { quirk =snd_pci_quirk_lookup (pci, m3_amp_quirk_list);if (quirk) { -snd_printdd (KERN_INFO "maestro3: set amp-gpio " -"for '%s'\n" , quirk->name); +snd_printdd (KERN_INFO +"maestro3: set amp-gpio for '%s'\n" , +snd_pci_quirk_name (quirk)); chip->amp_gpio = quirk->value; }else if (chip->allegro_flag) chip->amp_gpio =GPO_EXT_AMP_ALLEGRO ;
@@ -2597,8 +2598,9 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, quirk =snd_pci_quirk_lookup (pci, m3_irda_quirk_list);if (quirk) { -snd_printdd (KERN_INFO "maestro3: enabled irda workaround " -"for '%s'\n" , quirk->name); +snd_printdd (KERN_INFO +"maestro3: enabled irda workaround for '%s'\n" , +snd_pci_quirk_name (quirk)); chip->irda_workaround =1 ; } quirk =snd_pci_quirk_lookup (pci, m3_hv_quirk_list);
sound/pci/nm256/nm256.c +2 -1
@@ -1660,7 +1660,8 @@ static int snd_nm256_probe(struct pci_dev *pci, q =snd_pci_quirk_lookup (pci, nm256_quirks);if (q) { -snd_printdd (KERN_INFO "nm256: Enabled quirk for %s.\n" , q->name); +snd_printdd (KERN_INFO "nm256: Enabled quirk for %s.\n" , +snd_pci_quirk_name (q));switch (q->value) {case NM_BLACKLISTED : printk(KERN_INFO "nm256: The device is blacklisted. "
sound/pci/pcxhr/pcxhr_core.c +1 -2
@@ -1012,13 +1012,12 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err, enum pcxhr_async_err_src err_src, int pipe, int is_capture) { -#ifdef CONFIG_SND_DEBUG_VERBOSE static char* err_src_name[] = { [PCXHR_ERR_PIPE ] ="Pipe" , [PCXHR_ERR_STREAM ] ="Stream" , [PCXHR_ERR_AUDIO ] ="Audio" }; -#endif +if (err &0xfff ) err &=0xfff ;else
sound/pci/via82xx.c +1 -1
@@ -2517,7 +2517,7 @@ static int check_dxs_list(struct pci_dev *pci, int revision) w =snd_pci_quirk_lookup (pci, dxs_whitelist);if (w) {snd_printdd (KERN_INFO "via82xx: DXS white list for %s found\n" , - w->name); +snd_pci_quirk_name (w));return w->value; }
sound/usb/pcm.c +0 -2
@@ -1179,9 +1179,7 @@ static void retire_capture_urb(struct snd_usb_substream *subs,if (!subs->txfr_quirk) bytes = frames * stride;if (bytes % (runtime->sample_bits >>3 ) !=0 ) { -#ifdef CONFIG_SND_DEBUG_VERBOSE int oldbytes = bytes; -#endif bytes = frames * stride;snd_printdd (KERN_ERR "Corrected urb data len. %d->%d\n" , oldbytes, bytes);
Signature · 1 line
1.8.1.1