summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-08-08 23:02:51 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2021-08-10 11:22:13 +0000
commit4fb5aeb096ec911c54662caa8606c413b91deb00 (patch)
treecd01aee0a29b9583a8b203b0d276495d1007c32b /apps
parent2f0fd66e44a2f3535d0d161144156c1551249010 (diff)
recorder/pcm_record.c cleanup copy function
re: coverity write_write_order: In long(*s++) + *s++, s is written in *s++ and written in long(*s++) but the order in which the side effects take place is undefined because there is no intervening sequence point. Change-Id: I2911c240f3e85fcfbf77297e8579e02e217c5af5
Diffstat (limited to 'apps')
-rw-r--r--apps/recorder/pcm_record.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index b5de670c0d..0a6e1b5a51 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -873,13 +873,17 @@ static bool open_rec_file(bool create)
static void * ICODE_ATTR
copy_buffer_mono_lr(void *dst, const void *src, size_t src_size)
{
- int16_t *d = dst;
- int16_t const *s = src;
-
- /* mono = (L + R) / 2 */
+ int16_t *d = (int16_t*) dst;
+ int16_t const *s = (int16_t const*) src;
+ ssize_t copy_size = src_size;
+
+ /* mono = (L + R) / 2 */
do
- *d++ = ((int32_t){ *s++ } + *s++ + 1) >> 1;
- while (src_size -= PCM_SAMP_SIZE);
+ {
+ *d++ = ((int32_t){s[0]} + s[1] + 1) >> 1;
+ s+=2;
+ }
+ while ((copy_size -= PCM_SAMP_SIZE) > 0);
return dst;
}
@@ -888,13 +892,13 @@ copy_buffer_mono_lr(void *dst, const void *src, size_t src_size)
static void * ICODE_ATTR
copy_buffer_mono_l(void *dst, const void *src, size_t src_size)
{
- int16_t *d = dst;
- int16_t const *s = (int16_t *)src - 2;
-
+ int16_t *d = (int16_t*)dst;
+ int16_t const *s = (int16_t const*)src - 2;
+ ssize_t copy_size = src_size;
/* mono = L */
do
*d++ = *(s += 2);
- while (src_size -= PCM_SAMP_SIZE);
+ while ((copy_size -= PCM_SAMP_SIZE) > 0);
return dst;
}
@@ -903,13 +907,13 @@ copy_buffer_mono_l(void *dst, const void *src, size_t src_size)
static void * ICODE_ATTR
copy_buffer_mono_r(void *dst, const void *src, size_t src_size)
{
- int16_t *d = dst;
- int16_t const *s = (int16_t *)src - 1;
-
+ int16_t *d = (int16_t*)dst;
+ int16_t const *s = (int16_t const*)src - 1;
+ ssize_t copy_size = src_size;
/* mono = R */
do
*d++ = *(s += 2);
- while (src_size -= PCM_SAMP_SIZE);
+ while ((copy_size -= PCM_SAMP_SIZE) > 0);
return dst;
}