Browse Source

memmem: Remove void * arithmetic warning

haystack is a void *, so we can't do pointer arithmetic on it uncasted.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
David Gibson 11 years ago
parent
commit
7bcba7662a
1 changed files with 3 additions and 1 deletions
  1. 3 1
      ccan/memmem/memmem.c

+ 3 - 1
ccan/memmem/memmem.c

@@ -1,5 +1,7 @@
 /* CC0 (Public domain) - see LICENSE file for details */
 
+#include "config.h"
+
 #include <string.h>
 #include <ccan/memmem/memmem.h>
 
@@ -15,7 +17,7 @@ void *memmem(const void *haystack, size_t haystacklen,
 	p = haystack;
 
 	for (p = haystack;
-	     (p + needlelen) <= (haystack + haystacklen);
+	     (p + needlelen) <= ((const char *)haystack + haystacklen);
 	     p++)
 		if (memcmp(p, needle, needlelen) == 0)
 			return (void *)p;