pcm: return -ENOSYS when ops or fast_ops callback is NULL

function is allowed to continue until it checks for error variable, as to
not conflict with original implementation flow

for simple functions involving only one line, return error immediately in
case callback is NULL

Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Adam Miartus 2019-07-24 12:12:59 +02:00 committed by Takashi Iwai
parent d7ee2a9a30
commit 3bf780dcc3
4 changed files with 148 additions and 31 deletions

View file

@ -269,7 +269,10 @@ int snd_pcm_mmap(snd_pcm_t *pcm)
SNDMSG("Already mmapped");
return -EBUSY;
}
err = pcm->ops->mmap(pcm);
if (pcm->ops->mmap)
err = pcm->ops->mmap(pcm);
else
err = -ENOSYS;
if (err < 0)
return err;
if (pcm->mmap_shadow)
@ -445,7 +448,10 @@ int snd_pcm_munmap(snd_pcm_t *pcm)
return -ENXIO;
}
if (pcm->mmap_shadow)
return pcm->ops->munmap(pcm);
if (pcm->ops->munmap)
return pcm->ops->munmap(pcm);
else
return -ENOSYS;
for (c = 0; c < pcm->channels; ++c) {
snd_pcm_channel_info_t *i = &pcm->mmap_channels[c];
unsigned int c1;
@ -503,7 +509,10 @@ int snd_pcm_munmap(snd_pcm_t *pcm)
}
i->addr = NULL;
}
err = pcm->ops->munmap(pcm);
if (pcm->ops->munmap)
err = pcm->ops->munmap(pcm);
else
err = -ENOSYS;
if (err < 0)
return err;
free(pcm->mmap_channels);