Skip to contentSkip to conversation

ALSA: hda: fix unused variable warning

PATCH Superseded Anders Roxell 2 participants 5 messages Sep 11, 2018 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda: fix unused variable warning

When CONFIG_X86=n function azx_snoop doesn't use the variable chip it only returns true.

sound/pci/hda/hda_intel.c: In function ‘dma_alloc_pages’:
sound/pci/hda/hda_intel.c:2002:14: warning: unused variable ‘chip’ [-Wunused-variable]

  struct azx *chip = bus_to_azx(bus);
              ^~~~

Create a inline function of azx_snoop.

Fixes a41d122449be ("ALSA: hda - Embed bus into controller object")
---
 sound/pci/hda/hda_controller.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
sound/pci/hda/hda_controller.h +4 -5
index 0053b704ddc4..aa20048742d0 100644
@@ -170,11 +170,10 @@ struct azx {
 #define azx_bus(chip)	(&(chip)->bus.core)
 #define bus_to_azx(_bus)	container_of(_bus, struct azx, bus.core)
 
-#ifdef CONFIG_X86
-#define azx_snoop(chip)		((chip)->snoop)
-#else
-#define azx_snoop(chip)		true
-#endif
+static inline bool azx_snoop(struct azx *chip)
+{
+	return IS_ENABLED(CONFIG_X86) || (chip->snoop);
+}
 
 /*
  * macros for easy use
Signature · 1 line
2.18.0
#1 lore raw
Quoted 24 lines · Anders Roxell

When CONFIG_X86=n function azx_snoop doesn't use the variable chip it only returns true.

sound/pci/hda/hda_intel.c: In function ‘dma_alloc_pages’:
sound/pci/hda/hda_intel.c:2002:14: warning: unused variable ‘chip’ [-Wunused-variable]

  struct azx *chip = bus_to_azx(bus);
              ^~~~

Create a inline function of azx_snoop.

Fixes a41d122449be ("ALSA: hda - Embed bus into controller object")
---
 sound/pci/hda/hda_controller.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
sound/pci/hda/hda_controller.h +0 -0
index 0053b704ddc4..aa20048742d0 100644
@@ -170,11 +170,10 @@ struct azx {
 #define azx_bus(chip)	(&(chip)->bus.core)
 #define bus_to_azx(_bus)	container_of(_bus, struct azx, bus.core)

sound/pci/hda/hda_controller.h struct azx { · line 176

Quoted 10 lines
sound/pci/hda/hda_controller.h +4 -5
 
-#ifdef CONFIG_X86
-#define azx_snoop(chip)		((chip)->snoop)
-#else
-#define azx_snoop(chip)		true
-#endif
+static inline bool azx_snoop(struct azx *chip)
+{
+	return IS_ENABLED(CONFIG_X86) || (chip->snoop);
+}

The idea is good, but the patch is obviously wrong; it should be !IS_ENABLED() :)

Also, please remove the parentheses around chip->snoop.

thanks,

Takashi

#2 lore raw
Quoted 28 lines · Takashi Iwai
Quoted 25 lines · Anders Roxell

When CONFIG_X86=n function azx_snoop doesn't use the variable chip it only returns true.

sound/pci/hda/hda_intel.c: In function ‘dma_alloc_pages’:
sound/pci/hda/hda_intel.c:2002:14: warning: unused variable ‘chip’ [-Wunused-variable]

  struct azx *chip = bus_to_azx(bus);
              ^~~~

Create a inline function of azx_snoop.

Fixes a41d122449be ("ALSA: hda - Embed bus into controller object")
---
 sound/pci/hda/hda_controller.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
sound/pci/hda/hda_controller.h +0 -0
index 0053b704ddc4..aa20048742d0 100644
@@ -170,11 +170,10 @@ struct azx {
 #define azx_bus(chip)        (&(chip)->bus.core)
 #define bus_to_azx(_bus)     container_of(_bus, struct azx, bus.core)
 
Quoted 12 lines

sound/pci/hda/hda_controller.h struct azx { · line 176

Quoted 9 lines
sound/pci/hda/hda_controller.h +4 -5
-#ifdef CONFIG_X86
-#define azx_snoop(chip)              ((chip)->snoop)
-#else
-#define azx_snoop(chip)              true
-#endif
+static inline bool azx_snoop(struct azx *chip)
+{
+     return IS_ENABLED(CONFIG_X86) || (chip->snoop);
+}

The idea is good, but the patch is obviously wrong; it should be !IS_ENABLED() :)

oops, right.

Quoted 2 lines

Also, please remove the parentheses around chip->snoop.

OK.

Sending v2 shortly.

Cheers,
Anders

#3 lore raw

PATCH v2 1/1 ALSA: hda: fix unused variable warning

In reply to Takashi Iwai

When CONFIG_X86=n function azx_snoop doesn't use the variable chip it only returns true.

sound/pci/hda/hda_intel.c: In function ‘dma_alloc_pages’:
sound/pci/hda/hda_intel.c:2002:14: warning: unused variable ‘chip’ [-Wunused-variable]

  struct azx *chip = bus_to_azx(bus);
              ^~~~

Create a inline function of azx_snoop.

Fixes a41d122449be ("ALSA: hda - Embed bus into controller object")
---
 sound/pci/hda/hda_controller.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
sound/pci/hda/hda_controller.h +4 -5
index 0053b704ddc4..c95097bb5a0c 100644
@@ -170,11 +170,10 @@ struct azx {
 #define azx_bus(chip)	(&(chip)->bus.core)
 #define bus_to_azx(_bus)	container_of(_bus, struct azx, bus.core)
 
-#ifdef CONFIG_X86
-#define azx_snoop(chip)		((chip)->snoop)
-#else
-#define azx_snoop(chip)		true
-#endif
+static inline bool azx_snoop(struct azx *chip)
+{
+	return !IS_ENABLED(CONFIG_X86) || chip->snoop;
+}
 
 /*
  * macros for easy use
Signature · 1 line
2.18.0
Applied
#4 lore raw
Quoted 6 lines · Anders Roxell

When CONFIG_X86=n function azx_snoop doesn't use the variable chip it only returns true.

sound/pci/hda/hda_intel.c: In function ‘dma_alloc_pages’:
sound/pci/hda/hda_intel.c:2002:14: warning: unused variable ‘chip’ [-Wunused-variable]

Quoted 7 lines
  struct azx *chip = bus_to_azx(bus);
              ^~~~

Create a inline function of azx_snoop.

Fixes a41d122449be ("ALSA: hda - Embed bus into controller object")

Applied, thanks.

Takashi