Fix wrong return values in direct plugins

Fixed the codes returning error values that are not set properly
via errno.
This commit is contained in:
Takashi Iwai 2007-11-16 12:06:43 +01:00
parent c13b8dc986
commit 408af4b675

View file

@ -109,13 +109,15 @@ retryget:
} }
dmix->shmptr = shmat(dmix->shmid, 0, 0); dmix->shmptr = shmat(dmix->shmid, 0, 0);
if (dmix->shmptr == (void *) -1) { if (dmix->shmptr == (void *) -1) {
err = -errno;
snd_pcm_direct_shm_discard(dmix); snd_pcm_direct_shm_discard(dmix);
return -errno; return err;
} }
mlock(dmix->shmptr, sizeof(snd_pcm_direct_share_t)); mlock(dmix->shmptr, sizeof(snd_pcm_direct_share_t));
if (shmctl(dmix->shmid, IPC_STAT, &buf) < 0) { if (shmctl(dmix->shmid, IPC_STAT, &buf) < 0) {
err = -errno;
snd_pcm_direct_shm_discard(dmix); snd_pcm_direct_shm_discard(dmix);
return -errno; return err;
} }
if (buf.shm_nattch == 1) { /* we're the first user, clear the segment */ if (buf.shm_nattch == 1) { /* we're the first user, clear the segment */
memset(dmix->shmptr, 0, sizeof(snd_pcm_direct_share_t)); memset(dmix->shmptr, 0, sizeof(snd_pcm_direct_share_t));
@ -128,7 +130,7 @@ retryget:
} else { } else {
if (dmix->shmptr->magic != SND_PCM_DIRECT_MAGIC) { if (dmix->shmptr->magic != SND_PCM_DIRECT_MAGIC) {
snd_pcm_direct_shm_discard(dmix); snd_pcm_direct_shm_discard(dmix);
return -errno; return -EINVAL;
} }
} }
return 0; return 0;