Remove unused labels, variables, and functions.  Enable warnings.

Change-Id: Icbe24eaf1ad499f28b68b6a5f05368271a0a7e86
diff --git a/vm/analysis/CodeVerify.c b/vm/analysis/CodeVerify.c
index 91f5414..becce81 100644
--- a/vm/analysis/CodeVerify.c
+++ b/vm/analysis/CodeVerify.c
@@ -114,7 +114,9 @@
 
 
 /* fwd */
+#ifndef NDEBUG
 static void checkMergeTab(void);
+#endif
 static bool isInitMethod(const Method* meth);
 static RegType getInvocationThis(const RegType* insnRegs,\
     const int insnRegCount, const DecodedInstruction* pDecInsn,
@@ -540,10 +542,12 @@
 /*
  * Is this method a class initializer?
  */
+#if 0
 static bool isClassInitMethod(const Method* meth)
 {
     return (*meth->name == '<' && strcmp(meth->name+1, "clinit>") == 0);
 }
+#endif
 
 /*
  * Look up a class reference given as a simple string descriptor.
@@ -1338,8 +1342,6 @@
 static inline RegType getRegisterType(const RegType* insnRegs,
     const int insnRegCount, u4 vsrc, VerifyError* pFailure)
 {
-    RegType type;
-
     if (vsrc >= (u4) insnRegCount) {
         *pFailure = VERIFY_ERROR_GENERIC;
         return kRegTypeUnknown;
@@ -3105,10 +3107,7 @@
 {
     bool result = false;
     const int insnsSize = dvmGetMethodInsnsSize(meth);
-    const u2* insns = meth->insns;
     const bool generateRegisterMap = gDvm.generateRegisterMaps;
-    int i, offset;
-    bool isConditional;
     RegisterTable regTable;
 
     memset(&regTable, 0, sizeof(regTable));
@@ -3258,11 +3257,10 @@
     RegisterTable* regTable, UninitInstanceMap* uninitMap)
 {
     const int insnsSize = dvmGetMethodInsnsSize(meth);
-    const u2* insns = meth->insns;
     RegType workRegs[meth->registersSize + kExtraRegs];
     bool result = false;
     bool debugVerbose = false;
-    int insnIdx, startGuess, prevAddr;
+    int insnIdx, startGuess;
 
     /*
      * Begin by marking the first instruction as "changed".
@@ -3520,7 +3518,6 @@
     const DexFile* pDexFile = meth->clazz->pDvmDex->pDexFile;
     RegType entryRegs[meth->registersSize + kExtraRegs];
     ClassObject* resClass;
-    const char* className;
     int branchTarget = 0;
     const int insnRegCount = meth->registersSize;
     RegType tmpType;
@@ -4062,7 +4059,6 @@
     case OP_IF_NE:
         {
             RegType type1, type2;
-            bool tmpResult;
 
             type1 = getRegisterType(workRegs, insnRegCount, decInsn.vA,
                         &failure);
@@ -4488,7 +4484,6 @@
         goto iget_1nr_common;
 iget_1nr_common:
         {
-            ClassObject* fieldClass;
             InstField* instField;
             RegType objType, fieldType;
 
@@ -4521,7 +4516,6 @@
     case OP_IGET_WIDE_VOLATILE:
         {
             RegType dstType;
-            ClassObject* fieldClass;
             InstField* instField;
             RegType objType;
 
@@ -4609,7 +4603,6 @@
 iput_1nr_common:
         {
             RegType srcType, fieldType, objType;
-            ClassObject* fieldClass;
             InstField* instField;
 
             srcType = getRegisterType(workRegs, insnRegCount, decInsn.vA,
@@ -4665,7 +4658,6 @@
             checkWidePair(tmpType, typeHi, &failure);
         }
         if (VERIFY_OK(failure)) {
-            ClassObject* fieldClass;
             InstField* instField;
             RegType objType;
 
@@ -5125,7 +5117,6 @@
                  * do this for all registers that have the same object
                  * instance in them, not just the "this" register.
                  */
-                int uidx = regTypeToUninitIndex(thisType);
                 markRefsAsInitialized(workRegs, insnRegCount, uninitMap,
                     thisType, &failure);
                 if (!VERIFY_OK(failure))
@@ -5683,7 +5674,6 @@
      */
     if ((nextFlags & kInstrCanThrow) != 0 && dvmInsnIsInTry(insnFlags, insnIdx))
     {
-        DexFile* pDexFile = meth->clazz->pDvmDex->pDexFile;
         const DexCode* pCode = dvmGetMethodCode(meth);
         DexCatchIterator iterator;
 
diff --git a/vm/analysis/DexPrepare.c b/vm/analysis/DexPrepare.c
index 5756cd0..b3ddcd1 100644
--- a/vm/analysis/DexPrepare.c
+++ b/vm/analysis/DexPrepare.c
@@ -667,7 +667,6 @@
     optHdr.flags = headerFlags;
     optHdr.checksum = optChecksum;
 
-    ssize_t actual;
     lseek(fd, 0, SEEK_SET);
     if (sysWriteFully(fd, &optHdr, sizeof(optHdr), "DexOpt opt header") != 0)
         goto bail;
@@ -1239,11 +1238,10 @@
 static int writeDependencies(int fd, u4 modWhen, u4 crc)
 {
     u1* buf = NULL;
-    ssize_t actual;
     int result = -1;
     ssize_t bufLen;
     ClassPathEntry* cpe;
-    int i, numDeps;
+    int numDeps;
 
     /*
      * Count up the number of completed entries in the bootclasspath.
@@ -1307,7 +1305,6 @@
  */
 static bool writeChunk(int fd, u4 type, const void* data, size_t size)
 {
-    ssize_t actual;
     union {             /* save a syscall by grouping these together */
         char raw[8];
         struct {
diff --git a/vm/analysis/DexVerify.c b/vm/analysis/DexVerify.c
index 8f4ee7f..9309a11 100644
--- a/vm/analysis/DexVerify.c
+++ b/vm/analysis/DexVerify.c
@@ -120,7 +120,7 @@
     bool result = false;
     UninitInstanceMap* uninitMap = NULL;
     InsnFlags* insnFlags = NULL;
-    int i, newInstanceCount;
+    int newInstanceCount;
 
     /*
      * If there aren't any instructions, make sure that's expected, then
@@ -495,7 +495,6 @@
         int width = dvmInsnGetWidth(insnFlags, i);
         OpCode opcode = *insns & 0xff;
         InstructionFlags opFlags = dexGetInstrFlags(gDvm.instrFlags, opcode);
-        int offset, absOffset;
 
         if ((opFlags & gcMask) != 0) {
             /*
diff --git a/vm/analysis/Optimize.c b/vm/analysis/Optimize.c
index 354389f..82d50cd 100644
--- a/vm/analysis/Optimize.c
+++ b/vm/analysis/Optimize.c
@@ -36,8 +36,6 @@
 
 
 /* fwd */
-static void optimizeLoadedClasses(DexFile* pDexFile);
-static void optimizeClass(ClassObject* clazz);
 static bool optimizeMethod(Method* method);
 static void rewriteInstField(Method* method, u2* insns, OpCode newOpc);
 static bool rewriteVirtualInvoke(Method* method, u2* insns, OpCode newOpc);
@@ -562,7 +560,6 @@
     ClassObject* clazz = method->clazz;
     u2 fieldIdx = insns[1];
     InstField* field;
-    int byteOffset;
 
     field = dvmOptResolveInstField(clazz, fieldIdx, NULL);
     if (field == NULL) {
diff --git a/vm/analysis/ReduceConstants.c b/vm/analysis/ReduceConstants.c
index ec7ba0f..308db87 100644
--- a/vm/analysis/ReduceConstants.c
+++ b/vm/analysis/ReduceConstants.c
@@ -644,6 +644,7 @@
  *
  * Run through the instructions in this method, altering the constants used.
  */
+#if DVM_RESOLVER_CACHE == DVM_RC_EXPANDING
 static void updateUsedConstants(DexFile* pDexFile, const char* classDescriptor,
     DexMethod* pDexMethod, void* arg)
 {
@@ -666,6 +667,7 @@
         //printf(" (no code)\n");
     }
 }
+#endif
 
 /*
  * Count up the bits and show a count.
@@ -682,9 +684,9 @@
 static void summarizeResults(DvmDex* pDvmDex, ScanResults* pResults)
 {
     DexFile* pDexFile = pDvmDex->pDexFile;
+#if 0
     int i;
 
-#if 0
     for (i = 0; i < (int) pDvmDex->pDexFile->pHeader->typeIdsSize; i++) {
         const DexTypeId* pDexTypeId;
         const char* classDescr;
@@ -890,6 +892,7 @@
  * Construct an "expanding" chunk, with maps that convert instructions
  * with reduced constants back to their full original values.
  */
+#if DVM_RESOLVER_CACHE == DVM_RC_EXPANDING
 static bool constructExpandingDataChunk(IndexMapSet* pIndexMapSet)
 {
     int chunkLen = 0;
@@ -939,6 +942,7 @@
 
     return true;
 }
+#endif
 
 /*
  * Construct the "chunk" of data that will be appended to the optimized DEX
@@ -963,7 +967,6 @@
     ScanResults* pResults)
 {
     IndexMapSet* pIndexMapSet;
-    int setCount;
     bool okay = true;
 
     pIndexMapSet = calloc(1, sizeof(*pIndexMapSet));
diff --git a/vm/analysis/RegisterMap.c b/vm/analysis/RegisterMap.c
index a42d93a..8ab37f0 100644
--- a/vm/analysis/RegisterMap.c
+++ b/vm/analysis/RegisterMap.c
@@ -35,19 +35,20 @@
 /* verbose logging */
 #define REGISTER_MAP_VERBOSE    false
 
+//#define REGISTER_MAP_STATS
 
 // fwd
 static void outputTypeVector(const RegType* regs, int insnRegCount, u1* data);
 static bool verifyMap(VerifierData* vdata, const RegisterMap* pMap);
 static int compareMaps(const RegisterMap* pMap1, const RegisterMap* pMap2);
 
+#ifdef REGISTER_MAP_STATS
 static void computeMapStats(RegisterMap* pMap, const Method* method);
+#endif
 static RegisterMap* compressMapDifferential(const RegisterMap* pMap,\
     const Method* meth);
 static RegisterMap* uncompressMapDifferential(const RegisterMap* pMap);
 
-
-//#define REGISTER_MAP_STATS
 #ifdef REGISTER_MAP_STATS
 /*
  * Generate some statistics on the register maps we create and use.
@@ -471,7 +472,6 @@
     if (false) {
         const char* cd = "Landroid/net/http/Request;";
         const char* mn = "readResponse";
-        const char* sg = "(Landroid/net/http/AndroidHttpClientConnection;)V";
         if (strcmp(vdata->method->clazz->descriptor, cd) == 0 &&
             strcmp(vdata->method->name, mn) == 0)
         {
@@ -508,7 +508,6 @@
             dvmAbort();
         }
 
-        const u1* dataStart = rawMap;
         const RegType* regs = vdata->addrRegs[addr];
         if (regs == NULL) {
             LOGE("GLITCH: addr %d has no data\n", addr);
@@ -1243,9 +1242,9 @@
 /*
  * Compute some stats on an uncompressed register map.
  */
+#ifdef REGISTER_MAP_STATS
 static void computeMapStats(RegisterMap* pMap, const Method* method)
 {
-#ifdef REGISTER_MAP_STATS
     MapStats* pStats = (MapStats*) gDvm.registerMapStats;
     const u1 format = dvmRegisterMapGetFormat(pMap);
     const u2 numEntries = dvmRegisterMapGetNumEntries(pMap);
@@ -1361,9 +1360,8 @@
         prevAddr = addr;
         prevData = dataStart;
     }
-#endif
 }
-
+#endif
 
 /*
  * Compute the difference between two bit vectors.
diff --git a/vm/analysis/VerifySubs.c b/vm/analysis/VerifySubs.c
index 39d6dc8..16f128e 100644
--- a/vm/analysis/VerifySubs.c
+++ b/vm/analysis/VerifySubs.c
@@ -113,7 +113,6 @@
 bool dvmSetTryFlags(const Method* meth, InsnFlags* insnFlags)
 {
     u4 insnsSize = dvmGetMethodInsnsSize(meth);
-    DexFile* pDexFile = meth->clazz->pDvmDex->pDexFile;
     const DexCode* pCode = dvmGetMethodCode(meth);
     u4 triesSize = pCode->triesSize;
     const DexTry* pTries;
@@ -311,7 +310,6 @@
     int curOffset, bool selfOkay)
 {
     const int insnCount = dvmGetMethodInsnsSize(meth);
-    const u2* insns = meth->insns + curOffset;
     int offset, absOffset;
     bool isConditional;
 
@@ -411,7 +409,6 @@
     int curOffset, int* pOffset, bool* pConditional)
 {
     const u2* insns = meth->insns + curOffset;
-    int tmp;
 
     switch (*insns & 0xff) {
     case OP_GOTO: