Const-correctness.
[oota-llvm.git] / tools / llvm-stub / llvm-stub.c
index 91537a0b9cc7d388d6706d795fc1b35a59934da4..f2e478e69583b85d66f2a22ce4c08d14f8351442 100644 (file)
@@ -1,4 +1,4 @@
-/*===- llvm-stub.c - Stub executable to run llvm bitcode files -----------===//
+/*===- llvm-stub.c - Stub executable to run llvm bitcode files ------------===//
 // 
 //                     The LLVM Compiler Infrastructure
 //
@@ -38,7 +38,6 @@
 int main(int argc, char** argv) {
   const char *Interp = getenv("LLVMINTERP");
   const char **Args;
-  int len;
   if (Interp == 0) Interp = "lli";
 
   /* Set up the command line options to pass to the JIT. */
@@ -47,12 +46,14 @@ int main(int argc, char** argv) {
   Args[0] = Interp;
 
 #ifdef LLVM_ON_WIN32
-  len = strlen(argv[0]);
-  if (len < 4 || strcmp(argv[0] + len - 4, ".exe") != 0) {
-    /* .exe suffix is stripped off of argv[0] if the executable was run on the
-     * command line without one. Put it back on.
-     */
-    argv[0] = strcat(strcpy((char*)malloc(len + 5), argv[0]), ".exe");
+  {
+    int len = strlen(argv[0]);
+    if (len < 4 || strcmp(argv[0] + len - 4, ".exe") != 0) {
+      /* .exe suffix is stripped off of argv[0] if the executable was run on the
+       * command line without one. Put it back on.
+       */
+      argv[0] = strcat(strcpy((char*)malloc(len + 5), argv[0]), ".exe");
+    }
   }
 #endif
 
@@ -60,11 +61,10 @@ int main(int argc, char** argv) {
   Args[1] = strcat(strcpy((char*)malloc(strlen(argv[0])+4), argv[0]), ".bc");
 
   /* The rest of the args are as before. */
-  memcpy(Args+2, argv+1, sizeof(char*)*argc);
+  memcpy((char **)Args+2, argv+1, sizeof(char*)*argc);
 
   /* Run the JIT. */
-  execvp(Interp, (char *const*)Args);
-
+  execvp(Interp, (char **)Args);
   /* if _execv returns, the JIT could not be started. */
   fprintf(stderr, "Could not execute the LLVM JIT.  Either add 'lli' to your"
           " path, or set the\ninterpreter you want to use in the LLVMINTERP "