[alsa-devel] [PATCH] pcm: returning semop error code for semaphore up/down failures.
Takashi Iwai
tiwai at suse.de
Mon Jan 9 13:52:40 CET 2017
On Mon, 09 Jan 2017 12:24:11 +0100,
sutar.mounesh at gmail.com wrote:
>
> From: Mounesh Sutar <sutar.mounesh at gmail.com>
>
> Signed-off-by: Mounesh Sutar <sutar.mounesh at gmail.com>
>
> diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h
> index 91e816c..a7c0439 100644
> --- a/src/pcm/pcm_direct.h
> +++ b/src/pcm/pcm_direct.h
> @@ -263,7 +263,12 @@ static inline int snd_pcm_direct_semaphore_down(snd_pcm_direct_t *dmix, int sem_
> {
> struct sembuf op[2] = { { sem_num, 0, 0 }, { sem_num, 1, SEM_UNDO } };
> int err = semop(dmix->semid, op, 2);
> - if (err == 0) dmix->locked[sem_num]++;
> + if (err == 0) {
> + dmix->locked[sem_num]++;
> + }
> + else if (err == -1) {
> + err = -errno;
> + }
Just a minor coding style preference:
no need for braces for a single line if/else in general.
if (err == 0)
dmix->locked[sem_num]++;
else if (err == -1)
err = -errno;
thanks,
Takashi
> return err;
> }
>
> @@ -271,7 +276,12 @@ static inline int snd_pcm_direct_semaphore_up(snd_pcm_direct_t *dmix, int sem_nu
> {
> struct sembuf op = { sem_num, -1, SEM_UNDO | IPC_NOWAIT };
> int err = semop(dmix->semid, &op, 1);
> - if (err == 0) dmix->locked[sem_num]--;
> + if (err == 0) {
> + dmix->locked[sem_num]--;
> + }
> + else if (err == -1) {
> + err = -errno;
> + }
> return err;
> }
>
> --
> 2.7.4
>
More information about the Alsa-devel
mailing list