linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: aw2: avoid casting function pointers
@ 2024-02-13 10:13 Arnd Bergmann
  2024-02-13 13:25 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2024-02-13 10:13 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Cedric Bregardis,
	Jean-Christian Hassler, linux-sound, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

clang-16 started warning about incompatible function pointers here:

sound/pci/aw2/aw2-alsa.c:363:11: error: cast from 'void (*)(struct snd_pcm_substream *)' to 'snd_aw2_saa7146_it_cb' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  363 |                                                     (snd_aw2_saa7146_it_cb)
      |                                                     ^~~~~~~~~~~~~~~~~~~~~~~
  364 |                                                     snd_pcm_period_elapsed,
      |                                                     ~~~~~~~~~~~~~~~~~~~~~~
sound/pci/aw2/aw2-alsa.c:392:10: error: cast from 'void (*)(struct snd_pcm_substream *)' to 'snd_aw2_saa7146_it_cb' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  392 |                                                    (snd_aw2_saa7146_it_cb)
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~
  393 |                                                    snd_pcm_period_elapsed,
      |                                                    ~~~~~~~~~~~~~~~~~~~~~~

Add a forward declaration for struct snd_pcm_substrea to allow it to just
use the correct prototype.

Fixes: 98f2a97f207a ("[ALSA] Emagic Audiowerk 2 ALSA driver.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/pci/aw2/aw2-saa7146.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/pci/aw2/aw2-saa7146.h b/sound/pci/aw2/aw2-saa7146.h
index b5c5a71c0ac3..3a3de56b9b07 100644
--- a/sound/pci/aw2/aw2-saa7146.h
+++ b/sound/pci/aw2/aw2-saa7146.h
@@ -19,11 +19,12 @@
 
 #define NUM_STREAM_CAPTURE_ANA 0
 
-typedef void (*snd_aw2_saa7146_it_cb) (void *);
+struct snd_pcm_substream;
+typedef void (*snd_aw2_saa7146_it_cb) (struct snd_pcm_substream *);
 
 struct snd_aw2_saa7146_cb_param {
 	snd_aw2_saa7146_it_cb p_it_callback;
-	void *p_callback_param;
+	struct snd_pcm_substream *p_callback_param;
 };
 
 /* definition of the chip-specific record */
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: aw2: avoid casting function pointers
  2024-02-13 10:13 [PATCH] ALSA: aw2: avoid casting function pointers Arnd Bergmann
@ 2024-02-13 13:25 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2024-02-13 13:25 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jaroslav Kysela, Takashi Iwai, Arnd Bergmann, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Cedric Bregardis,
	Jean-Christian Hassler, linux-sound, linux-kernel, llvm

On Tue, 13 Feb 2024 11:13:19 +0100,
Arnd Bergmann wrote:
> 
> From: Arnd Bergmann <arnd@arndb.de>
> 
> clang-16 started warning about incompatible function pointers here:
> 
> sound/pci/aw2/aw2-alsa.c:363:11: error: cast from 'void (*)(struct snd_pcm_substream *)' to 'snd_aw2_saa7146_it_cb' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>   363 |                                                     (snd_aw2_saa7146_it_cb)
>       |                                                     ^~~~~~~~~~~~~~~~~~~~~~~
>   364 |                                                     snd_pcm_period_elapsed,
>       |                                                     ~~~~~~~~~~~~~~~~~~~~~~
> sound/pci/aw2/aw2-alsa.c:392:10: error: cast from 'void (*)(struct snd_pcm_substream *)' to 'snd_aw2_saa7146_it_cb' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>   392 |                                                    (snd_aw2_saa7146_it_cb)
>       |                                                    ^~~~~~~~~~~~~~~~~~~~~~~
>   393 |                                                    snd_pcm_period_elapsed,
>       |                                                    ~~~~~~~~~~~~~~~~~~~~~~
> 
> Add a forward declaration for struct snd_pcm_substrea to allow it to just
> use the correct prototype.
> 
> Fixes: 98f2a97f207a ("[ALSA] Emagic Audiowerk 2 ALSA driver.")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks, applied.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-13 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 10:13 [PATCH] ALSA: aw2: avoid casting function pointers Arnd Bergmann
2024-02-13 13:25 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).