From a37d094f31f0382668d969cdfde58e74f9f9cf4d Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 22 Aug 2023 11:55:40 +0300 Subject: [PATCH] fs/shmfs: Fix illegal usage of void* arithmetics Fixes build error with -Werror: shm/shmfs.c: In function 'shmfs_read': shm/shmfs.c:122:33: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith] 122 | memcpy(buffer, sho->paddr + startpos, nread); | ^ shm/shmfs.c: In function 'shmfs_write': shm/shmfs.c:166:25: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith] 166 | memcpy(sho->paddr + startpos, buffer, nwritten); | ^ cc1: all warnings being treated as errors --- fs/shm/shmfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/shm/shmfs.c b/fs/shm/shmfs.c index 1adf884033..1c9da72709 100644 --- a/fs/shm/shmfs.c +++ b/fs/shm/shmfs.c @@ -119,7 +119,7 @@ static ssize_t shmfs_read(FAR struct file *filep, FAR char *buffer, if (sho->paddr != NULL) { - memcpy(buffer, sho->paddr + startpos, nread); + memcpy(buffer, (FAR char *)sho->paddr + startpos, nread); filep->f_pos += nread; } else @@ -163,7 +163,7 @@ static ssize_t shmfs_write(FAR struct file *filep, FAR const char *buffer, if (sho->paddr != NULL) { - memcpy(sho->paddr + startpos, buffer, nwritten); + memcpy((FAR char *)sho->paddr + startpos, buffer, nwritten); filep->f_pos += nwritten; } else