Remove more lint.
Change-Id: I48714db4169d9ea0536342809361210910ee2091
diff --git a/src/check_jni.cc b/src/check_jni.cc
index 94f4cbd..0189ba3 100644
--- a/src/check_jni.cc
+++ b/src/check_jni.cc
@@ -134,7 +134,7 @@
}
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 @@
} 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 @@
}
}
-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 @@
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 @@
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 @@
*/
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 @@
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 @@
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 @@
}
/* 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 @@
// 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 @@
_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 @@
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 @@
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 @@
_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 @@
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 @@
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 @@
_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 @@
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 @@
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 @@
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 @@
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(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 @@
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 @@
}
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 8a2cc5c..02d9acb 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -549,7 +549,6 @@
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 @@
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::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 @@
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 @@
}
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 @@
// 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 ca7858a..ad36bd2 100644
--- a/src/compiled_method.cc
+++ b/src/compiled_method.cc
@@ -109,7 +109,7 @@
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 @@
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 @@
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 137f242..647a8ed 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -74,7 +74,7 @@
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 @@
}
// 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 e7faa3a..485ce5f 100644
--- a/src/context_x86.cc
+++ b/src/context_x86.cc
@@ -10,7 +10,7 @@
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 @@
#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 c009aba..ee36f99 100644
--- a/src/dalvik_system_DexFile.cc
+++ b/src/dalvik_system_DexFile.cc
@@ -45,40 +45,38 @@
//
// 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 099ed27..666541f 100644
--- a/src/dalvik_system_Zygote.cc
+++ b/src/dalvik_system_Zygote.cc
@@ -49,7 +49,7 @@
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 @@
// 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 72a4fdd..f8f5248 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -260,8 +260,8 @@
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 @@
// 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 @@
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 @@
*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 @@
}
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 971fc09..096c694 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -217,7 +217,7 @@
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 8147834..5127a17 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -562,7 +562,7 @@
}
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 @@
}
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 029c68b..e56492a 100644
--- a/src/dex_instruction.cc
+++ b/src/dex_instruction.cc
@@ -189,7 +189,7 @@
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 a99c6e5..7e44116 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -526,7 +526,7 @@
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 7bb4dc2..951cf37 100644
--- a/src/indirect_reference_table.cc
+++ b/src/indirect_reference_table.cc
@@ -34,8 +34,7 @@
}
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 @@
}
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 ad3d077..7bbc54f 100644
--- a/src/jdwp/jdwp.h
+++ b/src/jdwp/jdwp.h
@@ -259,7 +259,7 @@
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 bd108eb..cfc8326 100644
--- a/src/oat_file.cc
+++ b/src/oat_file.cc
@@ -238,7 +238,6 @@
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 @@
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 f99bb03..498ab34 100644
--- a/src/oat_writer.cc
+++ b/src/oat_writer.cc
@@ -133,7 +133,7 @@
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 9935d9d..be02d4d 100644
--- a/src/oatdump.cc
+++ b/src/oatdump.cc
@@ -92,7 +92,7 @@
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 456df7c..145f7ef 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -539,15 +539,18 @@
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 4d20a85..71655a5 100644
--- a/src/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
+++ b/src/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
@@ -40,7 +40,7 @@
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 e56f5ec..dd32765 100644
--- a/src/reference_table.cc
+++ b/src/reference_table.cc
@@ -60,7 +60,7 @@
}
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 83f50d3..ee97ee1 100644
--- a/src/trace.cc
+++ b/src/trace.cc
@@ -393,7 +393,7 @@
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 d4d2e3a..c0be9b4 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -127,7 +127,6 @@
return "null";
}
return PrettyDescriptor(ClassHelper(klass).GetDescriptor());
-
}
std::string PrettyDescriptor(const std::string& descriptor) {