cmd: bootvx: Avoid strlen() calls when constructing VxWorks bootline
Remember the position in the VxWorks bootline buffer to avoid the call to strlen() each time. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
9dffa52da8
commit
7f0c3c51c2
|
|
@ -213,6 +213,7 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
char *bootline; /* Text of the bootline */
|
char *bootline; /* Text of the bootline */
|
||||||
char *tmp; /* Temporary char pointer */
|
char *tmp; /* Temporary char pointer */
|
||||||
char build_buf[128]; /* Buffer for building the bootline */
|
char build_buf[128]; /* Buffer for building the bootline */
|
||||||
|
int ptr = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the loadaddr variable.
|
* Check the loadaddr variable.
|
||||||
|
|
@ -277,30 +278,29 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
max(strlen(bootline), (size_t)255));
|
max(strlen(bootline), (size_t)255));
|
||||||
flush_cache(bootaddr, max(strlen(bootline), (size_t)255));
|
flush_cache(bootaddr, max(strlen(bootline), (size_t)255));
|
||||||
} else {
|
} else {
|
||||||
sprintf(build_buf, CONFIG_SYS_VXWORKS_BOOT_DEVICE);
|
ptr = sprintf(build_buf, CONFIG_SYS_VXWORKS_BOOT_DEVICE);
|
||||||
tmp = getenv("bootfile");
|
tmp = getenv("bootfile");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
sprintf(&build_buf[strlen(build_buf)],
|
ptr += sprintf(build_buf + ptr, "%s:%s ",
|
||||||
"%s:%s ", CONFIG_SYS_VXWORKS_SERVERNAME, tmp);
|
CONFIG_SYS_VXWORKS_SERVERNAME, tmp);
|
||||||
else
|
else
|
||||||
sprintf(&build_buf[strlen(build_buf)],
|
ptr += sprintf(build_buf + ptr, "%s:file ",
|
||||||
"%s:file ", CONFIG_SYS_VXWORKS_SERVERNAME);
|
CONFIG_SYS_VXWORKS_SERVERNAME);
|
||||||
|
|
||||||
tmp = getenv("ipaddr");
|
tmp = getenv("ipaddr");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
sprintf(&build_buf[strlen(build_buf)], "e=%s ", tmp);
|
ptr += sprintf(build_buf + ptr, "e=%s ", tmp);
|
||||||
|
|
||||||
tmp = getenv("serverip");
|
tmp = getenv("serverip");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
sprintf(&build_buf[strlen(build_buf)], "h=%s ", tmp);
|
ptr += sprintf(build_buf + ptr, "h=%s ", tmp);
|
||||||
|
|
||||||
tmp = getenv("hostname");
|
tmp = getenv("hostname");
|
||||||
if (tmp)
|
if (tmp)
|
||||||
sprintf(&build_buf[strlen(build_buf)], "tn=%s ", tmp);
|
ptr += sprintf(build_buf + ptr, "tn=%s ", tmp);
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_VXWORKS_ADD_PARAMS
|
#ifdef CONFIG_SYS_VXWORKS_ADD_PARAMS
|
||||||
sprintf(&build_buf[strlen(build_buf)],
|
ptr += sprintf(build_buf + ptr, CONFIG_SYS_VXWORKS_ADD_PARAMS);
|
||||||
CONFIG_SYS_VXWORKS_ADD_PARAMS);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memcpy((void *)bootaddr, build_buf,
|
memcpy((void *)bootaddr, build_buf,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue