Typecast void* before doing pointer arithmetic

Caught by cppcheck
This commit is contained in:
Alan Barr 2018-10-13 16:49:41 +01:00
parent 88c378154a
commit 687238b79b
1 changed files with 2 additions and 2 deletions

View File

@ -70,7 +70,7 @@ ssize_t writeall(int fd, const void *buf, size_t count) {
size_t written = 0; size_t written = 0;
while (written < count) { 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 (n == -1) {
if (errno == EINTR || errno == EAGAIN) if (errno == EINTR || errno == EAGAIN)
continue; continue;
@ -86,7 +86,7 @@ ssize_t writeall_nonblock(int fd, const void *buf, size_t count) {
size_t written = 0; size_t written = 0;
while (written < count) { 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 (n == -1) {
if (errno == EAGAIN) { if (errno == EAGAIN) {
return written; return written;