Fix void* arithmetic warning (-Wpointer-arith)
authorJenny Wong <jyw@google.com>
Thu, 6 Aug 2015 17:02:35 +0000 (10:02 -0700)
committerJenny Wong <jyw@google.com>
Thu, 6 Aug 2015 18:55:52 +0000 (11:55 -0700)
https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html
gcc will assume sizeof(void) == 1 when doing pointer arithmetic on
void*s, but other compilers may not.

src/network.c

index 9169000..84e13a9 100644 (file)
@@ -1368,7 +1368,7 @@ static int parse_part_encr_aes256 (sockent_t *se, /* {{{ */
     warning_has_been_printed = 1;
   }
 
-  *ret_buffer += ph_length;
+  *ret_buffer = (void *) (((char *) *ret_buffer) + ph_length);
   *ret_buffer_size -= ph_length;
 
   return (0);
@@ -1407,7 +1407,7 @@ static int parse_packet (sockent_t *se, /* {{{ */
                                (void *) buffer,
                                sizeof (pkg_type));
                memcpy ((void *) &pkg_length,
-                               (void *) (buffer + sizeof (pkg_type)),
+                               (void *) (((char *) buffer) + sizeof (pkg_type)),
                                sizeof (pkg_length));
 
                pkg_length = ntohs (pkg_length);