[dpdk-dev,2/2] cmdline: remove useless intermediate buffer
Checks
Commit Message
Rather than copy the string, we can use a precision in the format string
given to printf.
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
lib/librte_cmdline/cmdline_parse.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
Comments
On Thu, May 31, 2018 at 10:03:28AM +0200, David Marchand wrote:
> Rather than copy the string, we can use a precision in the format string
> given to printf.
>
> Signed-off-by: David Marchand <david.marchand@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
@@ -208,9 +208,6 @@ cmdline_parse(struct cmdline *cl, const char * buf)
int err = CMDLINE_PARSE_NOMATCH;
int tok;
cmdline_parse_ctx_t *ctx;
-#ifdef RTE_LIBRTE_CMDLINE_DEBUG
- char debug_buf[BUFSIZ];
-#endif
char *result_buf = result.buf;
if (!cl || !buf)
@@ -250,10 +247,8 @@ cmdline_parse(struct cmdline *cl, const char * buf)
return linelen;
}
-#ifdef RTE_LIBRTE_CMDLINE_DEBUG
- strlcpy(debug_buf, buf, (linelen > 64 ? 64 : linelen));
- debug_printf("Parse line : len=%d, <%s>\n", linelen, debug_buf);
-#endif
+ debug_printf("Parse line : len=%d, <%.*s>\n",
+ linelen, linelen > 64 ? 64 : linelen, buf);
/* parse it !! */
inst = ctx[inst_num];