fix C++11 narrowing conversion errors

This commit is contained in:
Joel Dice 2012-06-01 11:46:56 -06:00
parent 587ae00d80
commit b78c772ffb
3 changed files with 27 additions and 21 deletions

View File

@ -76,7 +76,9 @@ Java_java_util_zip_Inflater_inflate
int r = inflate(s, Z_SYNC_FLUSH); int r = inflate(s, Z_SYNC_FLUSH);
jint resultArray[3] jint resultArray[3]
= { r, inputLength - s->avail_in, outputLength - s->avail_out }; = { r,
static_cast<jint>(inputLength - s->avail_in),
static_cast<jint>(outputLength - s->avail_out) };
free(in); free(in);
@ -147,7 +149,9 @@ Java_java_util_zip_Deflater_deflate
int r = deflate(s, finish ? Z_FINISH : Z_NO_FLUSH); int r = deflate(s, finish ? Z_FINISH : Z_NO_FLUSH);
jint resultArray[3] jint resultArray[3]
= { r, inputLength - s->avail_in, outputLength - s->avail_out }; = { r,
static_cast<jint>(inputLength - s->avail_in),
static_cast<jint>(outputLength - s->avail_out) };
free(in); free(in);

View File

@ -252,7 +252,8 @@ NewString(Thread* t, const jchar* chars, jsize size)
{ {
if (chars == 0) return 0; if (chars == 0) return 0;
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(chars), size }; uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(chars),
static_cast<uintptr_t>(size) };
return reinterpret_cast<jstring>(run(t, newString, arguments)); return reinterpret_cast<jstring>(run(t, newString, arguments));
} }
@ -311,7 +312,7 @@ DefineClass(Thread* t, const char*, jobject loader, const jbyte* buffer,
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(loader), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(loader),
reinterpret_cast<uintptr_t>(buffer), reinterpret_cast<uintptr_t>(buffer),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jclass>(run(t, defineClass, arguments)); return reinterpret_cast<jclass>(run(t, defineClass, arguments));
} }
@ -1495,7 +1496,7 @@ SetByteField(Thread* t, jobject o, jfieldID field, jbyte v)
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(o), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(o),
field, field,
v }; static_cast<uintptr_t>(v) };
run(t, setByteField, arguments); run(t, setByteField, arguments);
} }
@ -1545,7 +1546,7 @@ SetShortField(Thread* t, jobject o, jfieldID field, jshort v)
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(o), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(o),
field, field,
v }; static_cast<uintptr_t>(v) };
run(t, setShortField, arguments); run(t, setShortField, arguments);
} }
@ -1570,7 +1571,7 @@ SetIntField(Thread* t, jobject o, jfieldID field, jint v)
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(o), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(o),
field, field,
v }; static_cast<uintptr_t>(v) };
run(t, setIntField, arguments); run(t, setIntField, arguments);
} }
@ -1975,7 +1976,7 @@ SetStaticByteField(Thread* t, jobject c, jfieldID field, jbyte v)
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c),
field, field,
v }; static_cast<uintptr_t>(v) };
run(t, setStaticByteField, arguments); run(t, setStaticByteField, arguments);
} }
@ -2033,7 +2034,7 @@ SetStaticShortField(Thread* t, jobject c, jfieldID field, jshort v)
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c),
field, field,
v }; static_cast<uintptr_t>(v) };
run(t, setStaticShortField, arguments); run(t, setStaticShortField, arguments);
} }
@ -2062,7 +2063,7 @@ SetStaticIntField(Thread* t, jobject c, jfieldID field, jint v)
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c),
field, field,
v }; static_cast<uintptr_t>(v) };
run(t, setStaticIntField, arguments); run(t, setStaticIntField, arguments);
} }
@ -2261,7 +2262,7 @@ newObjectArray(Thread* t, uintptr_t* arguments)
jobjectArray JNICALL jobjectArray JNICALL
NewObjectArray(Thread* t, jsize length, jclass class_, jobject init) NewObjectArray(Thread* t, jsize length, jclass class_, jobject init)
{ {
uintptr_t arguments[] = { length, uintptr_t arguments[] = { static_cast<uintptr_t>(length),
reinterpret_cast<uintptr_t>(class_), reinterpret_cast<uintptr_t>(class_),
reinterpret_cast<uintptr_t>(init) }; reinterpret_cast<uintptr_t>(init) };
@ -2302,7 +2303,7 @@ NewBooleanArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeBooleanArray)), = { reinterpret_cast<uintptr_t>(voidPointer(makeBooleanArray)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jbooleanArray>(run(t, newArray, arguments)); return reinterpret_cast<jbooleanArray>(run(t, newArray, arguments));
} }
@ -2318,7 +2319,7 @@ NewByteArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeByteArray0)), = { reinterpret_cast<uintptr_t>(voidPointer(makeByteArray0)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jbyteArray>(run(t, newArray, arguments)); return reinterpret_cast<jbyteArray>(run(t, newArray, arguments));
} }
@ -2328,7 +2329,7 @@ NewCharArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeCharArray)), = { reinterpret_cast<uintptr_t>(voidPointer(makeCharArray)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jcharArray>(run(t, newArray, arguments)); return reinterpret_cast<jcharArray>(run(t, newArray, arguments));
} }
@ -2338,7 +2339,7 @@ NewShortArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeShortArray)), = { reinterpret_cast<uintptr_t>(voidPointer(makeShortArray)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jshortArray>(run(t, newArray, arguments)); return reinterpret_cast<jshortArray>(run(t, newArray, arguments));
} }
@ -2348,7 +2349,7 @@ NewIntArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeIntArray)), = { reinterpret_cast<uintptr_t>(voidPointer(makeIntArray)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jintArray>(run(t, newArray, arguments)); return reinterpret_cast<jintArray>(run(t, newArray, arguments));
} }
@ -2358,7 +2359,7 @@ NewLongArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeLongArray)), = { reinterpret_cast<uintptr_t>(voidPointer(makeLongArray)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jlongArray>(run(t, newArray, arguments)); return reinterpret_cast<jlongArray>(run(t, newArray, arguments));
} }
@ -2368,7 +2369,7 @@ NewFloatArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeFloatArray)), = { reinterpret_cast<uintptr_t>(voidPointer(makeFloatArray)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jfloatArray>(run(t, newArray, arguments)); return reinterpret_cast<jfloatArray>(run(t, newArray, arguments));
} }
@ -2378,7 +2379,7 @@ NewDoubleArray(Thread* t, jsize length)
{ {
uintptr_t arguments[] uintptr_t arguments[]
= { reinterpret_cast<uintptr_t>(voidPointer(makeDoubleArray)), = { reinterpret_cast<uintptr_t>(voidPointer(makeDoubleArray)),
length }; static_cast<uintptr_t>(length) };
return reinterpret_cast<jdoubleArray>(run(t, newArray, arguments)); return reinterpret_cast<jdoubleArray>(run(t, newArray, arguments));
} }
@ -2905,7 +2906,7 @@ RegisterNatives(Thread* t, jclass c, const JNINativeMethod* methods,
{ {
uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c), uintptr_t arguments[] = { reinterpret_cast<uintptr_t>(c),
reinterpret_cast<uintptr_t>(methods), reinterpret_cast<uintptr_t>(methods),
methodCount }; static_cast<uintptr_t>(methodCount) };
return run(t, registerNatives, arguments) ? 0 : -1; return run(t, registerNatives, arguments) ? 0 : -1;
} }

View File

@ -340,7 +340,8 @@ class MySystem: public System {
// milliseconds) is infinity so as to avoid overflow: // milliseconds) is infinity so as to avoid overflow:
if (time and time < INT64_C(31536000000000000)) { if (time and time < INT64_C(31536000000000000)) {
int64_t then = s->now() + time; int64_t then = s->now() + time;
timespec ts = { then / 1000, (then % 1000) * 1000 * 1000 }; timespec ts = { static_cast<long>(then / 1000),
static_cast<long>((then % 1000) * 1000 * 1000) };
int rv UNUSED = pthread_cond_timedwait int rv UNUSED = pthread_cond_timedwait
(&(t->condition), &(t->mutex), &ts); (&(t->condition), &(t->mutex), &ts);
expect(s, rv == 0 or rv == ETIMEDOUT or rv == EINTR); expect(s, rv == 0 or rv == ETIMEDOUT or rv == EINTR);