comparison lwasm/symbol.c @ 362:d149e2b56981

Silence tautological comparison warnings Because "char" may be signed or unsigned depending on the system, comparing for byte values 128...255 has to be forced as an unsigned comparison to be portable and clear. Modify two such comparisons in the symbol handling code to treat the symbol offset as a pointer to unsigned. This quiets tautological comparison warnings on systems with an 8 bit signed type as the default char type.
author William Astle <lost@l-w.ca>
date Tue, 26 May 2015 23:42:00 -0600
parents f45b2a68c3da
children 3f8abaac214c
comparison
equal deleted inserted replaced
361:4130ffdeb5c8 362:d149e2b56981
91 if (!sym || !*sym) 91 if (!sym || !*sym)
92 { 92 {
93 lwasm_register_error(as, cl, "Bad symbol (%s)", sym); 93 lwasm_register_error(as, cl, "Bad symbol (%s)", sym);
94 return NULL; 94 return NULL;
95 } 95 }
96 if (*sym < 0x80 && (!strchr(SSYMCHARS, *sym) && !strchr(sym + 1, '$') && !strchr(sym + 1, '@') && !strchr(sym + 1, '?'))) 96 if (*(unsigned char *)sym < 0x80 && (!strchr(SSYMCHARS, *sym) && !strchr(sym + 1, '$') && !strchr(sym + 1, '@') && !strchr(sym + 1, '?')))
97 { 97 {
98 lwasm_register_error(as, cl, "Bad symbol (%s)", sym); 98 lwasm_register_error(as, cl, "Bad symbol (%s)", sym);
99 return NULL; 99 return NULL;
100 } 100 }
101 101
112 islocal = 1; 112 islocal = 1;
113 if (*cp == '$' && !(CURPRAGMA(cl, PRAGMA_DOLLARNOTLOCAL))) 113 if (*cp == '$' && !(CURPRAGMA(cl, PRAGMA_DOLLARNOTLOCAL)))
114 islocal = 1; 114 islocal = 1;
115 115
116 // bad symbol 116 // bad symbol
117 if (!(flags & symbol_flag_nocheck) && *cp < 0x80 && !strchr(SYMCHARS, *cp)) 117 if (!(flags & symbol_flag_nocheck) && *(unsigned char *)cp < 0x80 && !strchr(SYMCHARS, *cp))
118 { 118 {
119 lwasm_register_error(as, cl, "Bad symbol (%s)", sym); 119 lwasm_register_error(as, cl, "Bad symbol (%s)", sym);
120 return NULL; 120 return NULL;
121 } 121 }
122 } 122 }