diff options
-rw-r--r-- | src/check_jni.cc | 78 | ||||
-rw-r--r-- | src/class_linker.cc | 12 | ||||
-rw-r--r-- | src/compiled_method.cc | 6 | ||||
-rw-r--r-- | src/compiler.cc | 3 | ||||
-rw-r--r-- | src/context_x86.cc | 4 | ||||
-rw-r--r-- | src/dalvik_system_DexFile.cc | 52 | ||||
-rw-r--r-- | src/dalvik_system_Zygote.cc | 5 | ||||
-rw-r--r-- | src/debugger.cc | 12 | ||||
-rw-r--r-- | src/dex2oat.cc | 2 | ||||
-rw-r--r-- | src/dex_file.cc | 4 | ||||
-rw-r--r-- | src/dex_instruction.cc | 2 | ||||
-rw-r--r-- | src/heap.cc | 2 | ||||
-rw-r--r-- | src/indirect_reference_table.cc | 7 | ||||
-rw-r--r-- | src/jdwp/jdwp.h | 2 | ||||
-rw-r--r-- | src/oat_file.cc | 3 | ||||
-rw-r--r-- | src/oat_writer.cc | 2 | ||||
-rw-r--r-- | src/oatdump.cc | 2 | ||||
-rw-r--r-- | src/object.cc | 11 | ||||
-rw-r--r-- | src/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc | 2 | ||||
-rw-r--r-- | src/reference_table.cc | 2 | ||||
-rw-r--r-- | src/trace.cc | 2 | ||||
-rw-r--r-- | src/utils.cc | 1 |
22 files changed, 105 insertions, 111 deletions
diff --git a/src/check_jni.cc b/src/check_jni.cc index 94f4cbd132..0189ba3581 100644 --- a/src/check_jni.cc +++ b/src/check_jni.cc @@ -134,7 +134,7 @@ bool ShouldTrace(JavaVMExt* vm, const Method* method) { } class ScopedCheck { -public: + public: // For JNIEnv* functions. explicit ScopedCheck(JNIEnv* env, int flags, const char* functionName) { Init(env, reinterpret_cast<JNIEnvExt*>(env)->vm, flags, functionName, true); @@ -554,11 +554,11 @@ public: } else if (ch == 'z') { CheckLengthPositive(va_arg(ap, jsize)); } else if (strchr("BCISZbfmpEv", ch) != NULL) { - va_arg(ap, int); // Skip this argument. + va_arg(ap, uint32_t); // Skip this argument. } else if (ch == 'D' || ch == 'F') { va_arg(ap, double); // Skip this argument. } else if (ch == 'J') { - va_arg(ap, long); // Skip this argument. + va_arg(ap, uint64_t); // Skip this argument. } else if (ch == '.') { } else { LOG(FATAL) << "Unknown check format specifier: " << ch; @@ -568,7 +568,7 @@ public: } } -private: + private: void Init(JNIEnv* env, JavaVM* vm, int flags, const char* functionName, bool hasMethod) { env_ = reinterpret_cast<JNIEnvExt*>(env); vm_ = reinterpret_cast<JavaVMExt*>(vm); @@ -943,7 +943,7 @@ struct GuardedCopy { uint8_t* newBuf = DebugAlloc(newLen); /* fill it in with a pattern */ - uint16_t* pat = (uint16_t*) newBuf; + uint16_t* pat = reinterpret_cast<uint16_t*>(newBuf); for (size_t i = 0; i < newLen / 2; i++) { *pat++ = kGuardPattern; } @@ -955,8 +955,8 @@ struct GuardedCopy { uLong adler = 0; if (!modOkay) { adler = adler32(0L, Z_NULL, 0); - adler = adler32(adler, (const Bytef*)buf, len); - *(uLong*)newBuf = adler; + adler = adler32(adler, reinterpret_cast<const Bytef*>(buf), len); + *reinterpret_cast<uLong*>(newBuf) = adler; } GuardedCopy* pExtra = reinterpret_cast<GuardedCopy*>(newBuf); @@ -973,7 +973,7 @@ struct GuardedCopy { */ static void* Destroy(void* dataBuf) { const GuardedCopy* pExtra = GuardedCopy::FromData(dataBuf); - void* original_ptr = (void*) pExtra->original_ptr; + void* original_ptr = const_cast<void*>(pExtra->original_ptr); size_t len = pExtra->original_length; DebugFree(dataBuf, len); return original_ptr; @@ -1008,10 +1008,10 @@ struct GuardedCopy { size_t len = pExtra->original_length; /* check bottom half of guard; skip over optional checksum storage */ - const uint16_t* pat = (uint16_t*) fullBuf; + const uint16_t* pat = reinterpret_cast<const uint16_t*>(fullBuf); for (size_t i = sizeof(GuardedCopy) / 2; i < (kGuardLen / 2 - sizeof(GuardedCopy)) / 2; i++) { if (pat[i] != kGuardPattern) { - LOG(ERROR) << "JNI: guard pattern(1) disturbed at " << (void*) fullBuf << " + " << (i*2); + LOG(ERROR) << "JNI: guard pattern(1) disturbed at " << reinterpret_cast<const void*>(fullBuf) << " + " << (i*2); JniAbort(functionName); } } @@ -1020,9 +1020,9 @@ struct GuardedCopy { if (offset & 0x01) { /* odd byte; expected value depends on endian-ness of host */ const uint16_t patSample = kGuardPattern; - if (fullBuf[offset] != ((const uint8_t*) &patSample)[1]) { + if (fullBuf[offset] != reinterpret_cast<const uint8_t*>(&patSample)[1]) { LOG(ERROR) << "JNI: guard pattern disturbed in odd byte after " - << (void*) fullBuf << " (+" << offset << ") " + << reinterpret_cast<const void*>(fullBuf) << " (+" << offset << ") " << StringPrintf("0x%02x 0x%02x", fullBuf[offset], ((const uint8_t*) &patSample)[1]); JniAbort(functionName); } @@ -1030,10 +1030,10 @@ struct GuardedCopy { } /* check top half of guard */ - pat = (uint16_t*) (fullBuf + offset); + pat = reinterpret_cast<const uint16_t*>(fullBuf + offset); for (size_t i = 0; i < kGuardLen / 4; i++) { if (pat[i] != kGuardPattern) { - LOG(ERROR) << "JNI: guard pattern(2) disturbed at " << (void*) fullBuf << " + " << (offset + i*2); + LOG(ERROR) << "JNI: guard pattern(2) disturbed at " << reinterpret_cast<const void*>(fullBuf) << " + " << (offset + i*2); JniAbort(functionName); } } @@ -1071,7 +1071,7 @@ struct GuardedCopy { // LOGW("mprotect(PROT_NONE) failed: %s", strerror(errno)); // } if (munmap(fullBuf, totalByteCount) != 0) { - PLOG(FATAL) << "munmap(" << (void*) fullBuf << ", " << totalByteCount << ") failed"; + PLOG(FATAL) << "munmap(" << reinterpret_cast<void*>(fullBuf) << ", " << totalByteCount << ") failed"; } } @@ -1385,7 +1385,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); _retdecl; \ va_list args; \ va_start(args, mid); \ - _retasgn baseEnv(env)->Call##_jname##MethodV(env, obj, mid, args); \ + _retasgn(baseEnv(env)->Call##_jname##MethodV(env, obj, mid, args)); \ va_end(args); \ _retok; \ } \ @@ -1396,7 +1396,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); sc.CheckSig(mid, _retsig, false); \ sc.CheckVirtualMethod(obj, mid); \ _retdecl; \ - _retasgn baseEnv(env)->Call##_jname##MethodV(env, obj, mid, args); \ + _retasgn(baseEnv(env)->Call##_jname##MethodV(env, obj, mid, args)); \ _retok; \ } \ static _ctype Call##_jname##MethodA(JNIEnv* env, jobject obj, \ @@ -1406,7 +1406,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); sc.CheckSig(mid, _retsig, false); \ sc.CheckVirtualMethod(obj, mid); \ _retdecl; \ - _retasgn baseEnv(env)->Call##_jname##MethodA(env, obj, mid, args); \ + _retasgn(baseEnv(env)->Call##_jname##MethodA(env, obj, mid, args)); \ _retok; \ } \ /* Non-virtual... */ \ @@ -1419,7 +1419,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); _retdecl; \ va_list args; \ va_start(args, mid); \ - _retasgn baseEnv(env)->CallNonvirtual##_jname##MethodV(env, obj, clazz, mid, args); \ + _retasgn(baseEnv(env)->CallNonvirtual##_jname##MethodV(env, obj, clazz, mid, args)); \ va_end(args); \ _retok; \ } \ @@ -1430,7 +1430,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); sc.CheckSig(mid, _retsig, false); \ sc.CheckVirtualMethod(obj, mid); \ _retdecl; \ - _retasgn baseEnv(env)->CallNonvirtual##_jname##MethodV(env, obj, clazz, mid, args); \ + _retasgn(baseEnv(env)->CallNonvirtual##_jname##MethodV(env, obj, clazz, mid, args)); \ _retok; \ } \ static _ctype CallNonvirtual##_jname##MethodA(JNIEnv* env, \ @@ -1440,7 +1440,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); sc.CheckSig(mid, _retsig, false); \ sc.CheckVirtualMethod(obj, mid); \ _retdecl; \ - _retasgn baseEnv(env)->CallNonvirtual##_jname##MethodA(env, obj, clazz, mid, args); \ + _retasgn(baseEnv(env)->CallNonvirtual##_jname##MethodA(env, obj, clazz, mid, args)); \ _retok; \ } \ /* Static... */ \ @@ -1453,7 +1453,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); _retdecl; \ va_list args; \ va_start(args, mid); \ - _retasgn baseEnv(env)->CallStatic##_jname##MethodV(env, clazz, mid, args); \ + _retasgn(baseEnv(env)->CallStatic##_jname##MethodV(env, clazz, mid, args)); \ va_end(args); \ _retok; \ } \ @@ -1464,7 +1464,7 @@ FIELD_ACCESSORS(jdouble, Double, "D"); sc.CheckSig(mid, _retsig, true); \ sc.CheckStaticMethod(clazz, mid); \ _retdecl; \ - _retasgn baseEnv(env)->CallStatic##_jname##MethodV(env, clazz, mid, args); \ + _retasgn(baseEnv(env)->CallStatic##_jname##MethodV(env, clazz, mid, args)); \ _retok; \ } \ static _ctype CallStatic##_jname##MethodA(JNIEnv* env, \ @@ -1474,22 +1474,22 @@ FIELD_ACCESSORS(jdouble, Double, "D"); sc.CheckSig(mid, _retsig, true); \ sc.CheckStaticMethod(clazz, mid); \ _retdecl; \ - _retasgn baseEnv(env)->CallStatic##_jname##MethodA(env, clazz, mid, args); \ + _retasgn(baseEnv(env)->CallStatic##_jname##MethodA(env, clazz, mid, args)); \ _retok; \ } #define NON_VOID_RETURN(_retsig, _ctype) return CHECK_JNI_EXIT(_retsig, (_ctype) result) #define VOID_RETURN CHECK_JNI_EXIT_VOID() -CALL(jobject, Object, Object* result, result=(Object*), NON_VOID_RETURN("L", jobject), "L"); -CALL(jboolean, Boolean, jboolean result, result=, NON_VOID_RETURN("Z", jboolean), "Z"); -CALL(jbyte, Byte, jbyte result, result=, NON_VOID_RETURN("B", jbyte), "B"); -CALL(jchar, Char, jchar result, result=, NON_VOID_RETURN("C", jchar), "C"); -CALL(jshort, Short, jshort result, result=, NON_VOID_RETURN("S", jshort), "S"); -CALL(jint, Int, jint result, result=, NON_VOID_RETURN("I", jint), "I"); -CALL(jlong, Long, jlong result, result=, NON_VOID_RETURN("J", jlong), "J"); -CALL(jfloat, Float, jfloat result, result=, NON_VOID_RETURN("F", jfloat), "F"); -CALL(jdouble, Double, jdouble result, result=, NON_VOID_RETURN("D", jdouble), "D"); +CALL(jobject, Object, Object* result, result = reinterpret_cast<Object*>, NON_VOID_RETURN("L", jobject), "L"); +CALL(jboolean, Boolean, jboolean result, result =, NON_VOID_RETURN("Z", jboolean), "Z"); +CALL(jbyte, Byte, jbyte result, result =, NON_VOID_RETURN("B", jbyte), "B"); +CALL(jchar, Char, jchar result, result =, NON_VOID_RETURN("C", jchar), "C"); +CALL(jshort, Short, jshort result, result =, NON_VOID_RETURN("S", jshort), "S"); +CALL(jint, Int, jint result, result =, NON_VOID_RETURN("I", jint), "I"); +CALL(jlong, Long, jlong result, result =, NON_VOID_RETURN("J", jlong), "J"); +CALL(jfloat, Float, jfloat result, result =, NON_VOID_RETURN("F", jfloat), "F"); +CALL(jdouble, Double, jdouble result, result =, NON_VOID_RETURN("D", jdouble), "D"); CALL(void, Void, , , VOID_RETURN, "V"); static jstring NewString(JNIEnv* env, const jchar* unicodeChars, jsize len) { @@ -1522,7 +1522,7 @@ CALL(void, Void, , , VOID_RETURN, "V"); sc.CheckNonNull(chars); if (sc.ForceCopy()) { GuardedCopy::Check(__FUNCTION__, chars, false); - chars = (const jchar*) GuardedCopy::Destroy((jchar*)chars); + chars = reinterpret_cast<const jchar*>(GuardedCopy::Destroy(const_cast<jchar*>(chars))); } baseEnv(env)->ReleaseStringChars(env, string, chars); CHECK_JNI_EXIT_VOID(); @@ -1554,7 +1554,7 @@ CALL(void, Void, , , VOID_RETURN, "V"); CHECK_JNI_ENTRY(kFlag_ExcepOkay | kFlag_Release, "Esu", env, string, utf); // TODO: show pointer and truncate string. if (sc.ForceCopy()) { GuardedCopy::Check(__FUNCTION__, utf, false); - utf = (const char*) GuardedCopy::Destroy((char*)utf); + utf = reinterpret_cast<const char*>(GuardedCopy::Destroy(const_cast<char*>(utf))); } baseEnv(env)->ReleaseStringUTFChars(env, string, utf); CHECK_JNI_EXIT_VOID(); @@ -1596,13 +1596,13 @@ NEW_PRIMITIVE_ARRAY(jfloatArray, Float); NEW_PRIMITIVE_ARRAY(jdoubleArray, Double); struct ForceCopyGetChecker { -public: + public: ForceCopyGetChecker(ScopedCheck& sc, jboolean* isCopy) { force_copy = sc.ForceCopy(); no_copy = 0; if (force_copy && isCopy != NULL) { /* capture this before the base call tramples on it */ - no_copy = *(uint32_t*) isCopy; + no_copy = *reinterpret_cast<uint32_t*>(isCopy); } } @@ -1744,7 +1744,7 @@ PRIMITIVE_ARRAY_FUNCTIONS(jdouble, Double, 'D'); sc.CheckNonNull(carray); if (sc.ForceCopy()) { GuardedCopy::Check(__FUNCTION__, carray, false); - carray = (const jchar*) GuardedCopy::Destroy((jchar*)carray); + carray = reinterpret_cast<const jchar*>(GuardedCopy::Destroy(const_cast<jchar*>(carray))); } baseEnv(env)->ReleaseStringCritical(env, string, carray); CHECK_JNI_EXIT_VOID(); @@ -2040,7 +2040,7 @@ const JNINativeInterface* GetCheckJniNativeInterface() { } class CheckJII { -public: + public: static jint DestroyJavaVM(JavaVM* vm) { ScopedCheck sc(vm, false, __FUNCTION__); sc.Check(true, "v", vm); diff --git a/src/class_linker.cc b/src/class_linker.cc index 8a2cc5cc40..02d9acb8e3 100644 --- a/src/class_linker.cc +++ b/src/class_linker.cc @@ -549,7 +549,6 @@ void ClassLinker::RunRootClinits() { bool ClassLinker::GenerateOatFile(const std::string& dex_filename, int oat_fd, const std::string& oat_cache_filename) { - std::string dex2oat_string("/system/bin/dex2oat"); #ifndef NDEBUG dex2oat_string += 'd'; @@ -823,7 +822,7 @@ void ClassLinker::InitFromImage() { const std::vector<Space*>& spaces = Heap::GetSpaces(); for (size_t i = 0; i < spaces.size(); i++) { - Space* space = spaces[i] ; + Space* space = spaces[i]; if (space->IsImageSpace()) { OatFile* oat_file = OpenOat(space); CHECK(oat_file != NULL) << "Failed to open oat file for image"; @@ -1078,7 +1077,7 @@ Class* ClassLinker::FindSystemClass(const char* descriptor) { } Class* ClassLinker::FindClass(const char* descriptor, const ClassLoader* class_loader) { - DCHECK(*descriptor != '\0') << "descriptor is empty string"; + DCHECK_NE(*descriptor, '\0') << "descriptor is empty string"; Thread* self = Thread::Current(); DCHECK(self != NULL); CHECK(!self->IsExceptionPending()) << PrettyTypeOf(self->GetException()); @@ -2044,7 +2043,7 @@ static void CheckProxyConstructor(Method* constructor) { CHECK(constructor->IsConstructor()); MethodHelper mh(constructor); CHECK_STREQ(mh.GetName(), "<init>"); - CHECK(mh.GetSignature() == "(Ljava/lang/reflect/InvocationHandler;)V"); + CHECK_EQ(mh.GetSignature(), std::string("(Ljava/lang/reflect/InvocationHandler;)V")); DCHECK(constructor->IsPublic()); } @@ -2801,7 +2800,7 @@ bool ClassLinker::LinkStaticFields(SirtRef<Class>& klass) { } struct LinkFieldsComparator { - LinkFieldsComparator(FieldHelper* fh) : fh_(fh) {} + explicit LinkFieldsComparator(FieldHelper* fh) : fh_(fh) {} bool operator()(const Field* field1, const Field* field2) { // First come reference fields, then 64-bit, and finally 32-bit fh_->ChangeField(field1); @@ -2929,8 +2928,7 @@ bool ClassLinker::LinkFields(SirtRef<Class>& klass, bool is_static) { // that 'referent' is alphabetically last, so this is easy... CHECK_EQ(num_reference_fields, num_fields); fh.ChangeField(fields->Get(num_fields - 1)); - StringPiece name(fh.GetName()); - CHECK(name == "referent"); + CHECK_STREQ(fh.GetName(), "referent"); --num_reference_fields; } diff --git a/src/compiled_method.cc b/src/compiled_method.cc index ca7858a82a..ad36bd268e 100644 --- a/src/compiled_method.cc +++ b/src/compiled_method.cc @@ -109,7 +109,7 @@ uint32_t CompiledMethod::AlignCode(uint32_t offset, InstructionSet instruction_s case kX86: return offset; default: - LOG(FATAL) << "Unknown InstructionSet " << (int) instruction_set; + LOG(FATAL) << "Unknown InstructionSet: " << static_cast<int>(instruction_set); return 0; } } @@ -124,7 +124,7 @@ size_t CompiledMethod::CodeDelta() const { return 1; } default: - LOG(FATAL) << "Unknown InstructionSet " << (int) instruction_set_; + LOG(FATAL) << "Unknown InstructionSet: " << static_cast<int>(instruction_set_); return 0; } } @@ -142,7 +142,7 @@ const void* CompiledMethod::CodePointer(const void* code_pointer, return reinterpret_cast<const void*>(address); } default: - LOG(FATAL) << "Unknown InstructionSet " << (int) instruction_set; + LOG(FATAL) << "Unknown InstructionSet: " << static_cast<int>(instruction_set); return NULL; } } diff --git a/src/compiler.cc b/src/compiler.cc index 137f2424ca..647a8edc9a 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -74,7 +74,7 @@ ByteArray* Compiler::CreateJniDlsymLookupStub(InstructionSet instruction_set) { case kX86: return x86::CreateJniDlsymLookupStub(); default: - LOG(FATAL) << "Unknown InstructionSet " << (int) instruction_set; + LOG(FATAL) << "Unknown InstructionSet: " << static_cast<int>(instruction_set); return NULL; } } @@ -338,7 +338,6 @@ void Compiler::InitializeClassesWithoutClinit(const ClassLoader* class_loader, c } // clear any class not found or verification exceptions Thread::Current()->ClearException(); - } DexCache* dex_cache = class_linker->FindDexCache(dex_file); diff --git a/src/context_x86.cc b/src/context_x86.cc index e7faa3abf2..485ce5ff34 100644 --- a/src/context_x86.cc +++ b/src/context_x86.cc @@ -10,7 +10,7 @@ namespace x86 { X86Context::X86Context() { #ifndef NDEBUG // Initialize registers with easy to spot debug values - for (int i=0; i < 8; i++) { + for (int i = 0; i < 8; i++) { gprs_[i] = 0xEBAD6070+i; } eip_ = 0xEBAD601F; @@ -38,7 +38,7 @@ void X86Context::DoLongJump() { #if defined(__i386__) // Load ESP and EIP gprs_[ESP] -= 4; // push EIP for return - *((uintptr_t*)(gprs_[ESP])) = eip_; + *(reinterpret_cast<uintptr_t*>(gprs_[ESP])) = eip_; asm volatile( "pushl %4\n\t" "pushl %0\n\t" diff --git a/src/dalvik_system_DexFile.cc b/src/dalvik_system_DexFile.cc index c009abaf14..ee36f99394 100644 --- a/src/dalvik_system_DexFile.cc +++ b/src/dalvik_system_DexFile.cc @@ -45,40 +45,38 @@ namespace { // // TODO: rewrite to get rid of this, or change ScopedUtfChars to offer this option. class NullableScopedUtfChars { -public: - NullableScopedUtfChars(JNIEnv* env, jstring s) - : mEnv(env), mString(s) - { - mUtfChars = (s != NULL) ? env->GetStringUTFChars(s, NULL) : NULL; - } + public: + NullableScopedUtfChars(JNIEnv* env, jstring s) : mEnv(env), mString(s) { + mUtfChars = (s != NULL) ? env->GetStringUTFChars(s, NULL) : NULL; + } - ~NullableScopedUtfChars() { - if (mUtfChars) { - mEnv->ReleaseStringUTFChars(mString, mUtfChars); - } + ~NullableScopedUtfChars() { + if (mUtfChars) { + mEnv->ReleaseStringUTFChars(mString, mUtfChars); } + } - const char* c_str() const { - return mUtfChars; - } + const char* c_str() const { + return mUtfChars; + } - size_t size() const { - return strlen(mUtfChars); - } + size_t size() const { + return strlen(mUtfChars); + } - // Element access. - const char& operator[](size_t n) const { - return mUtfChars[n]; - } + // Element access. + const char& operator[](size_t n) const { + return mUtfChars[n]; + } -private: - JNIEnv* mEnv; - jstring mString; - const char* mUtfChars; + private: + JNIEnv* mEnv; + jstring mString; + const char* mUtfChars; - // Disallow copy and assignment. - NullableScopedUtfChars(const NullableScopedUtfChars&); - void operator=(const NullableScopedUtfChars&); + // Disallow copy and assignment. + NullableScopedUtfChars(const NullableScopedUtfChars&); + void operator=(const NullableScopedUtfChars&); }; static jint DexFile_openDexFile(JNIEnv* env, jclass, jstring javaSourceName, jstring javaOutputName, jint) { diff --git a/src/dalvik_system_Zygote.cc b/src/dalvik_system_Zygote.cc index 099ed27896..666541f9fd 100644 --- a/src/dalvik_system_Zygote.cc +++ b/src/dalvik_system_Zygote.cc @@ -49,7 +49,7 @@ void Zygote_nativeExecShell(JNIEnv* env, jclass, jstring javaCommand) { const char* argp[] = {_PATH_BSHELL, "-c", command.c_str(), NULL}; LOG(INFO) << "Exec: " << argp[0] << ' ' << argp[1] << ' ' << argp[2]; - execv(_PATH_BSHELL, (char**)argp); + execv(_PATH_BSHELL, const_cast<char**>(argp)); exit(127); } @@ -266,8 +266,7 @@ extern "C" int gMallocLeakZygoteChild; // Utility routine to fork zygote and specialize the child process. pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids, jint debug_flags, jobjectArray javaRlimits, - jlong permittedCapabilities, jlong effectiveCapabilities) -{ + jlong permittedCapabilities, jlong effectiveCapabilities) { Runtime* runtime = Runtime::Current(); CHECK(runtime->IsZygote()) << "runtime instance not started with -Xzygote"; if (false) { // TODO: do we need do anything special like !dvmGcPreZygoteFork()? diff --git a/src/debugger.cc b/src/debugger.cc index 72a4fdd659..f8f52483a7 100644 --- a/src/debugger.cc +++ b/src/debugger.cc @@ -260,8 +260,8 @@ static bool ParseJdwpOption(const std::string& name, const std::string& value) { return false; } char* end; - long port = strtol(port_string.c_str(), &end, 10); - if (*end != '\0') { + uint64_t port = strtoul(port_string.c_str(), &end, 10); + if (*end != '\0' || port > 0xffff) { LOG(ERROR) << "JDWP address has junk in port field: " << value; return false; } @@ -500,7 +500,7 @@ void Dbg::GetClassList(std::vector<JDWP::RefTypeId>& classes) { // the primitive types). // Returns a newly-allocated buffer full of RefTypeId values. struct ClassListCreator { - ClassListCreator(std::vector<JDWP::RefTypeId>& classes) : classes(classes) { + explicit ClassListCreator(std::vector<JDWP::RefTypeId>& classes) : classes(classes) { } static bool Visit(Class* c, void* arg) { @@ -1256,7 +1256,7 @@ bool Dbg::GetThreadFrame(JDWP::ObjectId threadId, int desired_frame_number, JDWP ScopedThreadListLock thread_list_lock; struct GetFrameVisitor : public Thread::StackVisitor { GetFrameVisitor(int desired_frame_number, JDWP::FrameId* pFrameId, JDWP::JdwpLocation* pLoc) - : found(false) ,depth(0), desired_frame_number(desired_frame_number), pFrameId(pFrameId), pLoc(pLoc) { + : found(false), depth(0), desired_frame_number(desired_frame_number), pFrameId(pFrameId), pLoc(pLoc) { } virtual void VisitFrame(const Frame& f, uintptr_t pc) { // TODO: we'll need to skip callee-save frames too. @@ -1821,7 +1821,7 @@ bool Dbg::DdmHandlePacket(const uint8_t* buf, int dataLen, uint8_t** pReplyBuf, *pReplyBuf = reply; *pReplyLen = length + kChunkHdrLen; - VLOG(jdwp) << StringPrintf("dvmHandleDdm returning type=%.4s buf=%p len=%d", (char*) reply, reply, length); + VLOG(jdwp) << StringPrintf("dvmHandleDdm returning type=%.4s buf=%p len=%d", reinterpret_cast<char*>(reply), reply, length); return true; } @@ -2245,7 +2245,7 @@ void Dbg::SetAllocTrackingEnabled(bool enabled) { } struct AllocRecordStackVisitor : public Thread::StackVisitor { - AllocRecordStackVisitor(AllocRecord* record) : record(record), depth(0) { + explicit AllocRecordStackVisitor(AllocRecord* record) : record(record), depth(0) { } virtual void VisitFrame(const Frame& f, uintptr_t pc) { diff --git a/src/dex2oat.cc b/src/dex2oat.cc index 971fc09825..096c694514 100644 --- a/src/dex2oat.cc +++ b/src/dex2oat.cc @@ -217,7 +217,7 @@ class Dex2Oat { private: - Dex2Oat(Runtime* runtime) : runtime_(runtime) {} + explicit Dex2Oat(Runtime* runtime) : runtime_(runtime) {} static Runtime* CreateRuntime(Runtime::Options& options) { Runtime* runtime = Runtime::Create(options, false); diff --git a/src/dex_file.cc b/src/dex_file.cc index 81478345d3..5127a17bd0 100644 --- a/src/dex_file.cc +++ b/src/dex_file.cc @@ -562,7 +562,7 @@ int32_t DexFile::GetLineNumFromPC(const Method* method, uint32_t rel_pc) const { } int32_t DexFile::FindCatchHandlerOffset(const CodeItem &code_item, int32_t tries_size, - uint32_t address){ + uint32_t address) { // Note: Signed type is important for max and min. int32_t min = 0; int32_t max = tries_size - 1; @@ -763,7 +763,7 @@ void DexFile::DecodeDebugInfo(const CodeItem* code_item, bool is_static, uint32_ } bool DexFile::LineNumForPcCb(void* cnxt, uint32_t address, uint32_t line_num) { - LineNumFromPcContext* context = (LineNumFromPcContext*) cnxt; + LineNumFromPcContext* context = reinterpret_cast<LineNumFromPcContext*>(cnxt); // We know that this callback will be called in // ascending address order, so keep going until we find diff --git a/src/dex_instruction.cc b/src/dex_instruction.cc index 029c68b7a1..e56492a6e8 100644 --- a/src/dex_instruction.cc +++ b/src/dex_instruction.cc @@ -189,7 +189,7 @@ void Instruction::Decode(uint32_t &vA, uint32_t &vB, uint64_t &vB_wide, uint32_t vB_wide = FETCH_u4(1) | ((uint64_t) FETCH_u4(3) << 32); break; default: - LOG(ERROR) << "Can't decode unexpected format " << (int) Format() << " (op=" << opcode << ")"; + LOG(ERROR) << "Can't decode unexpected format " << static_cast<int>(Format()) << " (op=" << opcode << ")"; return; } } diff --git a/src/heap.cc b/src/heap.cc index a99c6e5e3c..7e44116d3c 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -526,7 +526,7 @@ void Heap::CollectGarbageInternal() { size_t kib_freed = (bytes_freed > 0 ? std::max(bytes_freed/KB, size_t(1U)) : 0); size_t total = GetTotalMemory(); - size_t percentFree = 100 - static_cast<size_t>(100.0f * float(num_bytes_allocated_) / total); + size_t percentFree = 100 - static_cast<size_t>(100.0f * static_cast<float>(num_bytes_allocated_) / total); uint32_t duration = (t1 - t0)/1000/1000; bool gc_was_particularly_slow = (duration > 100); // TODO: crank this down for concurrent. diff --git a/src/indirect_reference_table.cc b/src/indirect_reference_table.cc index 7bb4dc233e..951cf370ac 100644 --- a/src/indirect_reference_table.cc +++ b/src/indirect_reference_table.cc @@ -34,8 +34,7 @@ static void AbortMaybe() { } IndirectReferenceTable::IndirectReferenceTable(size_t initialCount, - size_t maxCount, IndirectRefKind desiredKind) -{ + size_t maxCount, IndirectRefKind desiredKind) { CHECK_GT(initialCount, 0U); CHECK_LE(initialCount, maxCount); CHECK_NE(desiredKind, kSirtOrInvalid); @@ -106,8 +105,8 @@ IndirectRef IndirectReferenceTable::Add(uint32_t cookie, const Object* obj) { } DCHECK_GT(newSize, alloc_entries_); - table_ = (const Object**) realloc(table_, newSize * sizeof(const Object*)); - slot_data_ = (IndirectRefSlot*) realloc(slot_data_, newSize * sizeof(IndirectRefSlot)); + table_ = reinterpret_cast<const Object**>(realloc(table_, newSize * sizeof(const Object*))); + slot_data_ = reinterpret_cast<IndirectRefSlot*>(realloc(slot_data_, newSize * sizeof(IndirectRefSlot))); if (table_ == NULL || slot_data_ == NULL) { LOG(ERROR) << "JNI ERROR (app bug): unable to expand " << kind_ << " table (from " diff --git a/src/jdwp/jdwp.h b/src/jdwp/jdwp.h index ad3d077fb0..7bbc54f600 100644 --- a/src/jdwp/jdwp.h +++ b/src/jdwp/jdwp.h @@ -259,7 +259,7 @@ struct JdwpState { void UnregisterAll(); private: - JdwpState(const JdwpOptions* options); + explicit JdwpState(const JdwpOptions* options); bool InvokeInProgress(); bool IsConnected(); void SuspendByPolicy(JdwpSuspendPolicy suspendPolicy); diff --git a/src/oat_file.cc b/src/oat_file.cc index bd108ebac4..cfc832661b 100644 --- a/src/oat_file.cc +++ b/src/oat_file.cc @@ -238,7 +238,6 @@ OatFile::OatMethod::OatMethod(const byte* base, vmap_table_offset_(vmap_table_offset), gc_map_offset_(gc_map_offset), invoke_stub_offset_(invoke_stub_offset) { - #ifndef NDEBUG if (mapping_table_offset_ != 0) { // implies non-native, non-stub code if (vmap_table_offset_ == 0) { @@ -248,7 +247,7 @@ OatFile::OatMethod::OatMethod(const byte* base, DCHECK_EQ(vmap_table_[0], static_cast<uint32_t>(__builtin_popcount(core_spill_mask_) + __builtin_popcount(fp_spill_mask_))); } } else { - DCHECK(vmap_table_offset_ == 0); + DCHECK_EQ(vmap_table_offset_, 0U); } #endif } diff --git a/src/oat_writer.cc b/src/oat_writer.cc index f99bb03639..498ab34a17 100644 --- a/src/oat_writer.cc +++ b/src/oat_writer.cc @@ -133,7 +133,7 @@ size_t OatWriter::InitOatCodeDexFiles(size_t offset) { size_t OatWriter::InitOatCodeDexFile(size_t offset, size_t& oat_class_index, const DexFile& dex_file) { - for (size_t class_def_index = 0; + for (size_t class_def_index = 0; class_def_index < dex_file.NumClassDefs(); class_def_index++, oat_class_index++) { const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); diff --git a/src/oatdump.cc b/src/oatdump.cc index 9935d9db36..be02d4d7be 100644 --- a/src/oatdump.cc +++ b/src/oatdump.cc @@ -92,7 +92,7 @@ class OatDump { os << std::flush; - std::vector<const OatFile::OatDexFile*> oat_dex_files = oat_file.GetOatDexFiles() ; + std::vector<const OatFile::OatDexFile*> oat_dex_files = oat_file.GetOatDexFiles(); for (size_t i = 0; i < oat_dex_files.size(); i++) { const OatFile::OatDexFile* oat_dex_file = oat_dex_files[i]; CHECK(oat_dex_file != NULL); diff --git a/src/object.cc b/src/object.cc index 456df7c693..145f7efe50 100644 --- a/src/object.cc +++ b/src/object.cc @@ -539,15 +539,18 @@ void Method::Invoke(Thread* self, Object* receiver, byte* args, JValue* result) if (Runtime::Current()->IsStarted() && have_executable_code && stub != NULL) { bool log = false; if (log) { - LOG(INFO) << "invoking " << PrettyMethod(this) << " code=" << (void*) GetCode() << " stub=" << (void*) stub; + LOG(INFO) << StringPrintf("invoking %s code=%p stub=%p", + PrettyMethod(this).c_str(), GetCode(), stub); } (*stub)(this, receiver, self, args, result); if (log) { - LOG(INFO) << "returned " << PrettyMethod(this) << " code=" << (void*) GetCode() << " stub=" << (void*) stub; + LOG(INFO) << StringPrintf("returned %s code=%p stub=%p", + PrettyMethod(this).c_str(), GetCode(), stub); } } else { - LOG(INFO) << "not invoking " << PrettyMethod(this) << " code=" << (void*) GetCode() << " stub=" << (void*) stub - << " started=" << Runtime::Current()->IsStarted(); + LOG(INFO) << StringPrintf("not invoking %s code=%p stub=%p started=%s", + PrettyMethod(this).c_str(), GetCode(), stub, + Runtime::Current()->IsStarted() ? "true" : "false"); if (result != NULL) { result->j = 0; } diff --git a/src/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/src/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc index 4d20a853e9..71655a5e57 100644 --- a/src/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc +++ b/src/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc @@ -40,7 +40,7 @@ static jboolean DdmVmInternal_getRecentAllocationStatus(JNIEnv* env, jclass) { static Thread* FindThreadByThinLockId(uint32_t thin_lock_id) { struct ThreadFinder { - ThreadFinder(uint32_t thin_lock_id) : thin_lock_id(thin_lock_id), thread(NULL) { + explicit ThreadFinder(uint32_t thin_lock_id) : thin_lock_id(thin_lock_id), thread(NULL) { } static void Callback(Thread* t, void* context) { diff --git a/src/reference_table.cc b/src/reference_table.cc index e56f5ec3ae..dd3276550e 100644 --- a/src/reference_table.cc +++ b/src/reference_table.cc @@ -60,7 +60,7 @@ size_t GetElementCount(const Object* obj) { } struct ObjectComparator { - bool operator()(const Object* obj1, const Object* obj2){ + bool operator()(const Object* obj1, const Object* obj2) { // Ensure null references and cleared jweaks appear at the end. if (obj1 == NULL) { return true; diff --git a/src/trace.cc b/src/trace.cc index 83f50d30ef..ee97ee13a9 100644 --- a/src/trace.cc +++ b/src/trace.cc @@ -393,7 +393,7 @@ void Trace::DumpMethodList(std::ostream& os) { for (It it = visited_methods_.begin(); it != visited_methods_.end(); ++it) { const Method* method = *it; MethodHelper mh(method); - os << StringPrintf("0x%08x\t%s\t%s\t%s\t%s\t%d\n", (int) method, + os << StringPrintf("%p\t%s\t%s\t%s\t%s\t%d\n", method, PrettyDescriptor(mh.GetDeclaringClassDescriptor()).c_str(), mh.GetName(), mh.GetSignature().c_str(), mh.GetDeclaringClassSourceFile(), mh.GetLineNumFromNativePC(0)); diff --git a/src/utils.cc b/src/utils.cc index d4d2e3a8b6..c0be9b4a44 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -127,7 +127,6 @@ std::string PrettyDescriptor(const Class* klass) { return "null"; } return PrettyDescriptor(ClassHelper(klass).GetDescriptor()); - } std::string PrettyDescriptor(const std::string& descriptor) { |