From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: [PATCH 2/2] cmdline: remove useless intermediate buffer Date: Thu, 31 May 2018 10:03:28 +0200 Message-ID: <1527753808-19409-2-git-send-email-david.marchand@6wind.com> References: <1527753808-19409-1-git-send-email-david.marchand@6wind.com> Cc: Olivier Matz To: dev@dpdk.org Return-path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 87C252D13 for ; Thu, 31 May 2018 10:03:39 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id d8-v6so805904wro.4 for ; Thu, 31 May 2018 01:03:39 -0700 (PDT) In-Reply-To: <1527753808-19409-1-git-send-email-david.marchand@6wind.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Rather than copy the string, we can use a precision in the format string given to printf. Signed-off-by: David Marchand --- lib/librte_cmdline/cmdline_parse.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 961f9be..9666e90 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -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]; -- 2.7.4