Fix narrowing-initializer warnings with gcc 4.7. No bug, r=themaid

--HG--
extra : rebase_source : a5cf16fbc9eb408a9eb286a2f0bb6194835a4bc2
This commit is contained in:
Jeff Walden 2012-06-12 15:03:12 -07:00
parent cb7d5576ed
commit 695d880981
2 changed files with 10 additions and 7 deletions

View File

@ -2279,7 +2279,7 @@ js::array_sort(JSContext *cx, unsigned argc, Value *vp)
if (!strElements.reserve(2 * n))
return false;
int cursor = 0;
size_t cursor = 0;
for (size_t i = 0; i < n; i++) {
if (!JS_CHECK_OPERATION_LIMIT(cx))
return false;

View File

@ -408,9 +408,9 @@ JSFlatString::isIndexSlow(uint32_t *indexp) const
* This is used when we generate our table of short strings, so the compiler is
* happier if we use |c| as few times as possible.
*/
#define FROM_SMALL_CHAR(c) ((c) + ((c) < 10 ? '0' : \
(c) < 36 ? 'a' - 10 : \
'A' - 36))
#define FROM_SMALL_CHAR(c) jschar((c) + ((c) < 10 ? '0' : \
(c) < 36 ? 'a' - 10 : \
'A' - 36))
/*
* Declare length-2 strings. We only store strings where both characters are
@ -432,7 +432,7 @@ StaticStrings::init(JSContext *cx)
SwitchToCompartment sc(cx, cx->runtime->atomsCompartment);
for (uint32_t i = 0; i < UNIT_STATIC_LIMIT; i++) {
jschar buffer[] = { i, 0x00 };
jschar buffer[] = { jschar(i), '\0' };
JSFixedString *s = js_NewStringCopyN(cx, buffer, 1);
if (!s)
return false;
@ -440,7 +440,7 @@ StaticStrings::init(JSContext *cx)
}
for (uint32_t i = 0; i < NUM_SMALL_CHARS * NUM_SMALL_CHARS; i++) {
jschar buffer[] = { FROM_SMALL_CHAR(i >> 6), FROM_SMALL_CHAR(i & 0x3F), 0x00 };
jschar buffer[] = { FROM_SMALL_CHAR(i >> 6), FROM_SMALL_CHAR(i & 0x3F), '\0' };
JSFixedString *s = js_NewStringCopyN(cx, buffer, 2);
if (!s)
return false;
@ -455,7 +455,10 @@ StaticStrings::init(JSContext *cx)
TO_SMALL_CHAR((i % 10) + '0');
intStaticTable[i] = length2StaticTable[index];
} else {
jschar buffer[] = { (i / 100) + '0', ((i / 10) % 10) + '0', (i % 10) + '0', 0x00 };
jschar buffer[] = { jschar('0' + (i / 100)),
jschar('0' + ((i / 10) % 10)),
jschar('0' + (i % 10)),
'\0' };
JSFixedString *s = js_NewStringCopyN(cx, buffer, 3);
if (!s)
return false;