changeset 17404:832be175c090

mbsstr: port --enable-gcc-warnings to clang * lib/mbsstr.c (knuth_morris_pratt_multibyte): Avoid casts from looser to stricter-aligned pointers.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 15 May 2013 00:17:25 -0700
parents 621e5ff3aca8
children 2760c772c42c
files ChangeLog lib/mbsstr.c
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-05-15  Paul Eggert  <eggert@cs.ucla.edu>
 
+	mbsstr: port --enable-gcc-warnings to clang
+	* lib/mbsstr.c (knuth_morris_pratt_multibyte):
+	Avoid casts from looser to stricter-aligned pointers.
+
 	malloca: port --enable-gcc-warnings to clang
 	* lib/malloca.c (struct header): New member 'magic', to avoid casts.
 	(mmalloca): Avoid casts from looser to stricter-aligned pointers.
--- a/lib/mbsstr.c
+++ b/lib/mbsstr.c
@@ -45,11 +45,12 @@
   size_t *table;
 
   /* Allocate room for needle_mbchars and the table.  */
-  char *memory = (char *) nmalloca (m, sizeof (mbchar_t) + sizeof (size_t));
+  void *memory = nmalloca (m, sizeof (mbchar_t) + sizeof (size_t));
+  void *table_memory;
   if (memory == NULL)
     return false;
-  needle_mbchars = (mbchar_t *) memory;
-  table = (size_t *) (memory + m * sizeof (mbchar_t));
+  needle_mbchars = memory;
+  table = table_memory = needle_mbchars + m;
 
   /* Fill needle_mbchars.  */
   {