From: Alan Barr Date: Sat, 13 Oct 2018 15:49:41 +0000 (+0100) Subject: Typecast void* before doing pointer arithmetic X-Git-Tag: 4.16~18^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F3454%2Fhead;p=i3%2Fi3 Typecast void* before doing pointer arithmetic Caught by cppcheck --- diff --git a/libi3/safewrappers.c b/libi3/safewrappers.c index 04bbda44..1802b327 100644 --- a/libi3/safewrappers.c +++ b/libi3/safewrappers.c @@ -70,7 +70,7 @@ ssize_t writeall(int fd, const void *buf, size_t count) { size_t written = 0; while (written < count) { - const ssize_t n = write(fd, buf + written, count - written); + const ssize_t n = write(fd, ((char *)buf) + written, count - written); if (n == -1) { if (errno == EINTR || errno == EAGAIN) continue; @@ -86,7 +86,7 @@ ssize_t writeall_nonblock(int fd, const void *buf, size_t count) { size_t written = 0; while (written < count) { - const ssize_t n = write(fd, buf + written, count - written); + const ssize_t n = write(fd, ((char *)buf) + written, count - written); if (n == -1) { if (errno == EAGAIN) { return written;