Re: [PATCH] ALSA: ctxfi: avoid casting function pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tue, 13 Feb 2024 11:12:46 +0100,
Arnd Bergmann wrote:
> 
> From: Arnd Bergmann <arnd@xxxxxxxx>
> 
> This driver creates an abstraction for different components by casting function
> pointers to slightly incompatible types for each one to get the correct
> argument even when the caller does not know those types. This is a
> bit unreliable and not allowed in combination with control flow integrity
> (KCFI):
> 
> sound/pci/ctxfi/ctatc.c:115:25: error: cast from 'int (*)(struct hw *, struct src_mgr **)' to 'create_t' (aka 'int (*)(struct hw *, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>   115 |         [SRC]           = { .create     = (create_t)src_mgr_create,
>       |                                           ^~~~~~~~~~~~~~~~~~~~~~~~
> sound/pci/ctxfi/ctatc.c:116:20: error: cast from 'int (*)(struct src_mgr *)' to 'destroy_t' (aka 'int (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>   116 |                             .destroy    = (destroy_t)src_mgr_destroy    },
>       |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
> sound/pci/ctxfi/ctatc.c:117:27: error: cast from 'int (*)(struct hw *, struct srcimp_mgr **)' to 'create_t' (aka 'int (*)(struct hw *, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>   117 |         [SRCIMP]        = { .create     = (create_t)srcimp_mgr_create,
>       |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> sound/pci/ctxfi/ctatc.c:118:20: error: cast from 'int (*)(struct srcimp_mgr *)' to 'destroy_t' (aka 'int (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
>   118 |                             .destroy    = (destroy_t)srcimp_mgr_destroy },
>       |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Change these to always pass void pointers and move the abstraction one level
> down.
> 
> Fixes: 8cc72361481f ("ALSA: SB X-Fi driver merge")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

Thanks, applied.


Takashi




[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux