[alsa-devel] [alsa-lib][RFC][PATCH 2/9] pcm: minor code refactoring for ioctl call

Takashi Sakamoto o-takashi at sakamocchi.jp
Thu Jun 22 16:43:27 CEST 2017


When error occurs, return value from ioctl(2) is -1 and error code can
be got thread local variable, errno. It's OK just to check the return
value without any assignment.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 src/pcm/pcm_hw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index f74bd0d7..cf143f2f 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -135,12 +135,12 @@ static int sync_ptr1(snd_pcm_hw_t *hw, struct snd_pcm_sync_ptr *ptr,
 	int err;
 
 	ptr->flags = flags;
-	err = ioctl(hw->fd, SNDRV_PCM_IOCTL_SYNC_PTR, ptr);
-	if (err < 0) {
+	if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SYNC_PTR, ptr) < 0) {
 		err = -errno;
 		SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err);
 		return err;
 	}
+
 	return 0;
 }
 
-- 
2.11.0



More information about the Alsa-devel mailing list