diff options
author | dvdli <dvdli@google.com> | 2020-10-29 16:24:43 +0800 |
---|---|---|
committer | dvdli <dvdli@google.com> | 2020-10-29 16:24:43 +0800 |
commit | b39234c6a35378abb18e81ea0967331f68fd9029 (patch) | |
tree | 350cbb29e72f9b551ea7cd6e18b6b84d4dfdc969 | |
parent | c0c5e7534011a9a3d64b74e0f20a3417fbbbc290 (diff) |
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 <muirj@google.com>
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.
-rw-r--r-- | src/pcm.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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; } } |