OSDN Git Service

Move declarations to the top to avoid potential uninitialized use.
authorDan Bornstein <danfuzz@android.com>
Mon, 13 Sep 2010 00:34:35 +0000 (17:34 -0700)
committerDan Bornstein <danfuzz@android.com>
Mon, 13 Sep 2010 00:41:18 +0000 (17:41 -0700)
I didn't catch the warnings among the build spew before. Also, made
"--preopt" use stderr for its complaints about arguments.

Change-Id: I8d470ccc40c4cdc9131beb0991060358039e2727

dexopt/OptMain.c

index 276db82..ca7031e 100644 (file)
@@ -322,8 +322,17 @@ bail:
  */
 static int preopt(int argc, char* const argv[])
 {
+    int zipFd = -1;
+    int outFd = -1;
+    int result = -1;
+
     if (argc != 5) {
-        LOGE("Wrong number of args for --preopt (found %d)\n", argc);
+        /*
+         * Use stderr here, since this variant is meant to be called on
+         * the host side.
+         */
+        fprintf(stderr, "Wrong number of args for --preopt (found %d)\n",
+                argc);
         goto bail;
     }
 
@@ -331,10 +340,6 @@ static int preopt(int argc, char* const argv[])
     const char* outName = argv[3];
     const char* dexoptFlags = argv[4];
 
-    int zipFd = -1;
-    int outFd = -1;
-    int result = -1;
-
     zipFd = open(zipName, O_RDONLY);
     if (zipFd < 0) {
         perror(argv[0]);