[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] mbsstr: fix warnings reported by gcc -Wcast-align on ARM
From: |
Dmitry V. Levin |
Subject: |
[PATCH] mbsstr: fix warnings reported by gcc -Wcast-align on ARM |
Date: |
Thu, 30 Sep 2010 16:43:08 +0400 |
* lib/mbsstr.c (knuth_morris_pratt_multibyte): Assign a raw memory
pointer returned by nmalloca() right to the variable of type
"mbchar_t *" thus removing redundant proxy variable of type "char *".
Signed-off-by: Dmitry V. Levin <address@hidden>
---
The issue originally arose during build of vanilla grep-2.7 on an ARM platform:
cc1: warnings being treated as errors
mbsstr.c: In function 'knuth_morris_pratt_multibyte':
mbsstr.c:50: error: cast increases required alignment of target type
[-Wcast-align]
mbsstr.c:51: error: cast increases required alignment of target type
[-Wcast-align]
lib/mbsstr.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/mbsstr.c b/lib/mbsstr.c
index d44b4c3..58eb951 100644
--- a/lib/mbsstr.c
+++ b/lib/mbsstr.c
@@ -44,11 +44,10 @@ 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));
- if (memory == NULL)
+ needle_mbchars = nmalloca (m, sizeof (mbchar_t) + sizeof (size_t));
+ if (needle_mbchars == NULL)
return false;
- needle_mbchars = (mbchar_t *) memory;
- table = (size_t *) (memory + m * sizeof (mbchar_t));
+ table = (size_t *) (needle_mbchars + m);
/* Fill needle_mbchars. */
{
@@ -172,7 +171,7 @@ knuth_morris_pratt_multibyte (const char *haystack, const
char *needle,
}
}
- freea (memory);
+ freea (needle_mbchars);
return true;
}
--
ldv
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] mbsstr: fix warnings reported by gcc -Wcast-align on ARM,
Dmitry V. Levin <=