linux.c32: replace the kernel name with BOOT_IMAGE= syslinux-3.81-pre2
authorH. Peter Anvin <hpa@zytor.com>
Tue, 5 May 2009 20:56:49 +0000 (13:56 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 5 May 2009 20:58:26 +0000 (13:58 -0700)
The BOOT_IMAGE= argument is generated by replacing the kernel name in
the argument array.  As a result, we shouldn't advance argp.  Move the
code around slightly, to make it more obvious that that is what is
happening.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/modules/linux.c

index 70afdcb..0c40df2 100644 (file)
@@ -143,7 +143,16 @@ int main(int argc, char *argv[])
   }
 
   kernel_name = arg;
-  argp++;
+
+  boot_image = malloc(strlen(kernel_name)+12);
+  if (!boot_image)
+    goto bail;
+  strcpy(boot_image, "BOOT_IMAGE=");
+  strcpy(boot_image+11, kernel_name);
+  /* argp now points to the kernel name, and the command line follows.
+     Overwrite the kernel name with the BOOT_IMAGE= argument, and thus
+     we have the final argument. */
+  *argp = boot_image;
 
   if (find_boolean(argp,"quiet"))
     opt_quiet = true;
@@ -159,18 +168,6 @@ int main(int argc, char *argv[])
   if (!opt_quiet)
     printf("ok\n");
 
-  boot_image = malloc(strlen(kernel_name)+12);
-  if (!boot_image)
-    goto bail;
-
-  strcpy(boot_image, "BOOT_IMAGE=");
-  strcpy(boot_image+11, kernel_name);
-
-  /* argp now points to the kernel name, and the command line follows.
-     Overwrite the kernel name with the BOOT_IMAGE= argument, and thus
-     we have the final argument. */
-  *argp = boot_image;
-
   cmdline = make_cmdline(argp);
   if (!cmdline)
     goto bail;