From b39234c6a35378abb18e81ea0967331f68fd9029 Mon Sep 17 00:00:00 2001 From: dvdli Date: Thu, 29 Oct 2020 16:24:43 +0800 Subject: AOSP CL "pcm: Fix usage of oops() function for use of strerror." https://android.googlesource.com/platform/external/tinyalsa/+/50028cd233f8cf8a084e950c951eefc01e1cd15c commit 50028cd233f8cf8a084e950c951eefc01e1cd15c author John Muir pcm: Fix usage of oops() function for use of strerror. The oops() function expected errno to be passed in, but at some point it was broken to look at errno itself, and ignore the passed-in value. Fix the oops() function to check the passed-in value, and modify uses of oops() to actually pass in errno and not -errno or the return value from the errored function call. Bug: None Test: pcm error code printed correctly. Change-Id: I555e1eda0cdd0cc9b94e05423d341f1c08f8e485 (cherry picked from commit 2c1d902ace5f78dcff0c39740642d269b2e17dff) Note: the oops in pcm_mmap_transfer was removed. --- src/pcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pcm.c b/src/pcm.c index 3b54ec7..a175668 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -332,7 +332,7 @@ static int oops(struct pcm *pcm, int e, const char *fmt, ...) va_end(ap); sz = strlen(pcm->error); - if (errno) + if (e) snprintf(pcm->error + sz, PCM_ERROR_MAX - sz, ": %s", strerror(e)); return -1; @@ -455,7 +455,7 @@ int pcm_set_config(struct pcm *pcm, const struct pcm_config *config) if (pcm->flags & PCM_NOIRQ) { if (!(pcm->flags & PCM_MMAP)) { - oops(pcm, -EINVAL, "noirq only currently supported with mmap()."); + oops(pcm, EINVAL, "noirq only currently supported with mmap()."); return -EINVAL; } @@ -1082,7 +1082,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, rc = pcm_hw_mmap_status(pcm); if (rc < 0) { - oops(pcm, rc, "mmap status failed"); + oops(pcm, errno, "mmap status failed"); goto fail; } @@ -1091,7 +1091,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, int arg = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC; rc = pcm->ops->ioctl(pcm->data, SNDRV_PCM_IOCTL_TTSTAMP, &arg); if (rc < 0) { - oops(pcm, rc, "cannot set timestamp type"); + oops(pcm, errno, "cannot set timestamp type"); goto fail; } } -- cgit v1.2.3