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>
This commit is contained in:
parent
381966b6c4
commit
353f6258f9
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue