OSDN Git Service

Minor code cleanup to address warnings found by Clang.
authorBen Cheng <bccheng@google.com>
Fri, 26 Jul 2013 16:46:06 +0000 (09:46 -0700)
committerBen Cheng <bccheng@google.com>
Mon, 29 Jul 2013 20:19:24 +0000 (13:19 -0700)
cherry-picked from internal Android branch
55617c82a73d84ff3695bdd5526159448262d009

Change-Id: I0f78ca6b8293c13d7dbb535556543f6ea9f4dd45

vm/Dvm.mk
vm/analysis/Optimize.cpp
vm/analysis/RegisterMap.cpp
vm/compiler/Loop.cpp
vm/hprof/Hprof.h
vm/hprof/HprofHeap.cpp

index 5c0f74e..2af0582 100644 (file)
--- a/vm/Dvm.mk
+++ b/vm/Dvm.mk
 #
 # Compiler defines.
 #
-LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
+
+LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2
 LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter
 LOCAL_CFLAGS += -DARCH_VARIANT=\"$(dvm_arch_variant)\"
 
+ifneq ($(strip $(LOCAL_CLANG)),true)
+LOCAL_CFLAGS += -fno-align-jumps
+endif
+
 #
 # Optional features.  These may impact the size or performance of the VM.
 #
index 55e7153..b61b82c 100644 (file)
@@ -375,16 +375,16 @@ void dvmUpdateCodeUnit(const Method* meth, u2* ptr, u2 newVal)
  * 16-bit op, we convert the opcode from "packed" form (e.g. 0x0108) to
  * bytecode form (e.g. 0x08ff).
  */
-static inline void updateOpcode(const Method* meth, u2* ptr, Opcode opcode)
+static inline void updateOpcode(const Method* meth, u2* ptr, u2 opcode)
 {
     if (opcode >= 256) {
         /* opcode low byte becomes high byte, low byte becomes 0xff */
         assert((ptr[0] & 0xff) == 0xff);
-        dvmUpdateCodeUnit(meth, ptr, (u2) (opcode << 8) | 0x00ff);
+        dvmUpdateCodeUnit(meth, ptr, (opcode << 8) | 0x00ff);
     } else {
         /* 8-bit op, just replace the low byte */
         assert((ptr[0] & 0xff) != 0xff);
-        dvmUpdateCodeUnit(meth, ptr, (ptr[0] & 0xff00) | (u2) opcode);
+        dvmUpdateCodeUnit(meth, ptr, (ptr[0] & 0xff00) | opcode);
     }
 }
 
index c62ec47..197fb7a 100644 (file)
@@ -508,6 +508,8 @@ static bool verifyMap(VerifierData* vdata, const RegisterMap* pMap)
             /* shouldn't happen */
             ALOGE("GLITCH: bad format (%d)", format);
             dvmAbort();
+            /* Make compiler happy */
+            addr = 0;
         }
 
         const RegType* regs = vdata->registerLines[addr].regTypes;
index f826686..dc04a11 100644 (file)
@@ -352,7 +352,7 @@ static bool doLoopBodyCodeMotion(CompilationUnit *cUnit)
             dvmCompilerDataFlowAttributes[mir->dalvikInsn.opcode];
 
         /* Skip extended MIR instructions */
-        if (dInsn->opcode >= kNumPackedOpcodes) continue;
+        if ((u2) dInsn->opcode >= kNumPackedOpcodes) continue;
 
         int instrFlags = dexGetFlagsFromOpcode(dInsn->opcode);
 
index 3ee8c61..c807529 100644 (file)
@@ -176,8 +176,8 @@ int hprofFinishHeapDump(hprof_context_t *ctx);
 
 int hprofSetGcScanState(hprof_context_t *ctx,
                         hprof_heap_tag_t state, u4 threadSerialNumber);
-int hprofMarkRootObject(hprof_context_t *ctx,
-                        const Object *obj, jobject jniObj);
+void hprofMarkRootObject(hprof_context_t *ctx,
+                         const Object *obj, jobject jniObj);
 
 int hprofDumpHeapObject(hprof_context_t *ctx, const Object *obj);
 
index 40e773b..8c34ff3 100644 (file)
@@ -119,14 +119,14 @@ static hprof_basic_type primitiveToBasicTypeAndSize(PrimitiveType prim,
  * only true when marking the root set or unreachable
  * objects.  Used to add rootset references to obj.
  */
-int hprofMarkRootObject(hprof_context_t *ctx, const Object *obj, jobject jniObj)
+void hprofMarkRootObject(hprof_context_t *ctx, const Object *obj,
+                         jobject jniObj)
 {
     hprof_record_t *rec = &ctx->curRec;
-    int err;
     hprof_heap_tag_t heapTag = (hprof_heap_tag_t)ctx->gcScanState;
 
     if (heapTag == 0) {
-        return 0;
+        return;
     }
 
     if (ctx->objectsInSegment >= OBJECTS_PER_SEGMENT ||
@@ -197,13 +197,10 @@ int hprofMarkRootObject(hprof_context_t *ctx, const Object *obj, jobject jniObj)
         break;
 
     default:
-        err = 0;
         break;
     }
 
     ctx->objectsInSegment++;
-
-    return err;
 }
 
 static int stackTraceSerialNumber(const void *obj)