cmd.c32: use strpcpy() instead of sprintf() syslinux-3.74-pre4
authorH. Peter Anvin <hpa@zytor.com>
Fri, 13 Mar 2009 04:23:54 +0000 (21:23 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 13 Mar 2009 04:23:54 +0000 (21:23 -0700)
Make the cmd.c32 module a lot smaller (and avoid a warning) by using
strpcpy() instead of sprintf().

com32/modules/cmd.c

index f0b0a96..e1d646b 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <string.h>
 #include <alloca.h>
-#include <console.h>
 #include <com32.h>
 
 int main(int argc, const char *argv[])
@@ -28,15 +27,17 @@ int main(int argc, const char *argv[])
   char *tmp;
   int i;
 
-  openconsole(&dev_stdcon_r, &dev_stdcon_w);
-
   for (i = 1; i < argc; i++)
     len += strlen(argv[i]) + 1;
 
   tmp = cmd = alloca(len);
 
-  for (i = 1; i < argc; i++)
-    tmp += sprintf(tmp, "%s%s", argv[i], (i == argc-1) ? "" : " ");
+  for (i = 1; i < argc; i++) {
+    tmp = strpcpy(tmp, argv[i]);
+    if (i != argc-1)
+      *tmp++ = ' ';
+  }
+  *tmp = '\0';
 
   syslinux_run_command(cmd);
 }