From: H. Peter Anvin Date: Fri, 13 Mar 2009 04:23:54 +0000 (-0700) Subject: cmd.c32: use strpcpy() instead of sprintf() X-Git-Tag: syslinux-3.74-pre4^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a708f025b241d8aca62014ebe7279fc605b1a46;p=platform%2Fupstream%2Fsyslinux.git cmd.c32: use strpcpy() instead of sprintf() Make the cmd.c32 module a lot smaller (and avoid a warning) by using strpcpy() instead of sprintf(). --- diff --git a/com32/modules/cmd.c b/com32/modules/cmd.c index f0b0a96..e1d646b 100644 --- a/com32/modules/cmd.c +++ b/com32/modules/cmd.c @@ -18,7 +18,6 @@ #include #include -#include #include 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); }