]> git.sur5r.net Git - i3/i3/commitdiff
Typecast void* before doing pointer arithmetic 3454/head
authorAlan Barr <a.barr@outlook.com>
Sat, 13 Oct 2018 15:49:41 +0000 (16:49 +0100)
committerAlan Barr <a.barr@outlook.com>
Sat, 13 Oct 2018 16:41:50 +0000 (17:41 +0100)
Caught by cppcheck

libi3/safewrappers.c

index 04bbda44c8ae233d83a9fea4f0608a2b933e1bd7..1802b327ee4442802cc7acc96dfa67e262a114a6 100644 (file)
@@ -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;