aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-16 11:06:06 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-16 18:06:38 +0000
commit353f6258f92ed7f8787cc32cd92ac3d44aa88f21 (patch)
tree221d294887e4a29c9975d3adde2c558860f3349f /epan/ftypes
parent381966b6c490d3e6a1ef750c7616ddf95e1dcfd4 (diff)
Fix issues in some ARM compilers, due to char being unsigned?
I'm not 100% certain the comparisons were right even with signed char; make the comparisons unsigned vs. unsigned, regardless of whether char is signed or not. (No, C doesn't require it to be signed; that's why there's a "signed" keyword.) Change-Id: Icbbd1019a2f7d4ebb40d821255834f825cd7c5a7 Reviewed-on: https://code.wireshark.org/review/4731 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/ftypes')
-rw-r--r--epan/ftypes/ftype-pcre.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/epan/ftypes/ftype-pcre.c b/epan/ftypes/ftype-pcre.c
index e9e42681d6..693ea88423 100644
--- a/epan/ftypes/ftype-pcre.c
+++ b/epan/ftypes/ftype-pcre.c
@@ -50,18 +50,27 @@ static gboolean
raw_flag_needed(const gchar *pattern)
{
gboolean found = FALSE;
- const gchar *s = pattern;
+ /*
+ * gchar is neither guaranteed to be signed nor guaranteed to be
+ * unsigned. Make s point to guint8, and use regular hex constants,
+ * to make sure the comparisons are unsigned vs. unsigned (on at
+ * least one ARM version of gcc, with char being unsigned, the
+ * comparisons before those changes warned about always being
+ * true due to the limited range of the data type).
+ */
+ const guint8 *s;
size_t i, len;
/* find any character whose hex value is two letters */
- len = strlen(s);
+ len = strlen(pattern);
+ s = (const guint8 *)pattern;
for (i = 0; i < len; i++) {
- if ((s[i] >= '\xAA' && s[i] <= '\xAF') ||
- (s[i] >= '\xBA' && s[i] <= '\xBF') ||
- (s[i] >= '\xCA' && s[i] <= '\xCF') ||
- (s[i] >= '\xDA' && s[i] <= '\xDF') ||
- (s[i] >= '\xEA' && s[i] <= '\xEF') ||
- (s[i] >= '\xFA' && s[i] <= '\xFF'))
+ if ((s[i] >= 0xAA && s[i] <= 0xAF) ||
+ (s[i] >= 0xBA && s[i] <= 0xBF) ||
+ (s[i] >= 0xCA && s[i] <= 0xCF) ||
+ (s[i] >= 0xDA && s[i] <= 0xDF) ||
+ (s[i] >= 0xEA && s[i] <= 0xEF) ||
+ (s[i] >= 0xFA && s[i] <= 0xFF))
{
found = TRUE;
break;