From: Paul Eggert Date: Wed, 15 May 2013 07:17:25 +0000 (-0700) Subject: mbsstr: port --enable-gcc-warnings to clang X-Git-Tag: v0.1~136 X-Git-Url: https://erislabs.net/gitweb/?p=gnulib.git;a=commitdiff_plain;h=c459fa109c50148d5f84c3c57862526ea408f305 mbsstr: port --enable-gcc-warnings to clang * lib/mbsstr.c (knuth_morris_pratt_multibyte): Avoid casts from looser to stricter-aligned pointers. --- diff --git a/ChangeLog b/ChangeLog index 508458ee3..1a8925ae0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2013-05-15 Paul Eggert + 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. diff --git a/lib/mbsstr.c b/lib/mbsstr.c index f84e689e4..24cff25da 100644 --- a/lib/mbsstr.c +++ b/lib/mbsstr.c @@ -45,11 +45,12 @@ knuth_morris_pratt_multibyte (const char *haystack, const char *needle, 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. */ {