Skip to content

Commit a57d151

Browse files
tiwaiJaroslav Kysela
authored andcommitted
[ALSA] emux - Avoid cast of function pointers
Modules: Common EMU synth Pass the proper functions instead of cast of function pointers, which can be dangerous with compiler optimizations. Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent cb43237 commit a57d151

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

‎sound/synth/emux/emux.c‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,29 @@ int snd_emux_new(snd_emux_t **remu)
6666

6767
/*
6868
*/
69+
static int sf_sample_new(void *private_data, snd_sf_sample_t *sp,
70+
snd_util_memhdr_t *hdr,
71+
const void __user *buf, long count)
72+
{
73+
snd_emux_t *emu = private_data;
74+
return emu->ops.sample_new(emu, sp, hdr, buf, count);
75+
76+
}
77+
78+
static int sf_sample_free(void *private_data, snd_sf_sample_t *sp,
79+
snd_util_memhdr_t *hdr)
80+
{
81+
snd_emux_t *emu = private_data;
82+
return emu->ops.sample_free(emu, sp, hdr);
83+
84+
}
85+
86+
static void sf_sample_reset(void *private_data)
87+
{
88+
snd_emux_t *emu = private_data;
89+
emu->ops.sample_reset(emu);
90+
}
91+
6992
int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
7093
{
7194
int err;
@@ -85,9 +108,12 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
85108
/* create soundfont list */
86109
memset(&sf_cb, 0, sizeof(sf_cb));
87110
sf_cb.private_data = emu;
88-
sf_cb.sample_new = (snd_sf_sample_new_t)emu->ops.sample_new;
89-
sf_cb.sample_free = (snd_sf_sample_free_t)emu->ops.sample_free;
90-
sf_cb.sample_reset = (snd_sf_sample_reset_t)emu->ops.sample_reset;
111+
if (emu->ops.sample_new)
112+
sf_cb.sample_new = sf_sample_new;
113+
if (emu->ops.sample_free)
114+
sf_cb.sample_free = sf_sample_free;
115+
if (emu->ops.sample_reset)
116+
sf_cb.sample_reset = sf_sample_reset;
91117
emu->sflist = snd_sf_new(&sf_cb, emu->memhdr);
92118
if (emu->sflist == NULL)
93119
return -ENOMEM;

0 commit comments

Comments
 (0)