[4/9] batman-adv: Don't do pointer arithmetic with void*

Message ID 1305407694-16789-4-git-send-email-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit f896bd9280543d0e35f45d3fd404bf9dba0e46d0
Headers

Commit Message

Sven Eckelmann May 14, 2011, 9:14 p.m. UTC
  The size of void is currently set by gcc to 1, but is not well defined
in general. Therefore it is more advisable to cast it to char* before
doing pointer arithmetic.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 originator.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Marek Lindner May 18, 2011, 9:40 a.m. UTC | #1
On Saturday 14 May 2011 23:14:49 Sven Eckelmann wrote:
> The size of void is currently set by gcc to 1, but is not well defined
> in general. Therefore it is more advisable to cast it to char* before
> doing pointer arithmetic.

Applied in revision f896bd9.

Thanks,
Marek
  

Patch

diff --git a/originator.c b/originator.c
index 080ec88..9843b68 100644
--- a/originator.c
+++ b/originator.c
@@ -567,7 +567,7 @@  static int orig_node_del_if(struct orig_node *orig_node,
 	memcpy(data_ptr, orig_node->bcast_own, del_if_num * chunk_size);
 
 	/* copy second part */
-	memcpy(data_ptr + del_if_num * chunk_size,
+	memcpy((char *)data_ptr + del_if_num * chunk_size,
 	       orig_node->bcast_own + ((del_if_num + 1) * chunk_size),
 	       (max_if_num - del_if_num) * chunk_size);
 
@@ -587,7 +587,7 @@  free_bcast_own:
 	memcpy(data_ptr, orig_node->bcast_own_sum,
 	       del_if_num * sizeof(uint8_t));
 
-	memcpy(data_ptr + del_if_num * sizeof(uint8_t),
+	memcpy((char *)data_ptr + del_if_num * sizeof(uint8_t),
 	       orig_node->bcast_own_sum + ((del_if_num + 1) * sizeof(uint8_t)),
 	       (max_if_num - del_if_num) * sizeof(uint8_t));