From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V/DQ6pC4ReJggOaeJn9oACUD0Lzw3Tl3nNU0zdBYLAA=; b=By0CP3WZnkuHWmWQZe10GSw36QunSS38OLzR8o+FOhCy4BI58OIG1zk127jZWFjBVd UICm6AJledEocKaPEQABPfzYCSyEJabrjCU8v5lyTSGgtoLq8U7OzYNgfbQBRlXL5Yi/ IFJaRFJQpLRNwyPgqa0U6vjrT6KCNKlVZ+tmB/Ky8WTW3wckebNGO03cqhTzQ6mI3XYV wQ2ZMiF+RQTGskkveb2y4bJ4d+qQGzrX/FRevjirSwEUFk0DW9+nqCJqUarfYuQ3tAE8 nj7oCMHa7+bOM3rjIi48jp/RmOXrbhqtq+TKy6EmU/eGlnan/I8Tgi5Q0K012B1Pymub tVWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V/DQ6pC4ReJggOaeJn9oACUD0Lzw3Tl3nNU0zdBYLAA=; b=kUSQIYRxM+dC+a86vOseU3bdGIhODuRY75ag6U0RUy0rDDUSDAspK1G8ckrWKmfq9P DbvuiIVCO8GphqSMVmQM84atrSnhFA3jXCSybKvhbXKsgpjbSKoSl6nKc994c2Jh+TxJ 9RhcJpggY2Rhrci88G7HyT1DbCKWknn2keI2d7gc4KVtDIbj2/PHYUu/4j1nWXsc7tgD keIw00v2ga4XHmemyZPkI8cB6Mu+9vQiT9vP52DdMWnzPP9HFCs3gItTkCZXQWvHGWED kP64rCmj2iBLShNbIVljXdKSGcq9Tncuqh/qH1REONpKKd/rpP1a6d/i0YmdNQKGlXTK rxrg== X-Gm-Message-State: ALKqPwdqXsR7fZXePtgzfhkMvADqOs96QqOgulOHW1XK70Nd3FvIZQEQ PYI4XmqblstGEddgInKXqSbcE/QZAoc= X-Google-Smtp-Source: ADUXVKJPeI4PJCeFFn+mD7EBYBS6V5q6rz0n7Ofekt/HKQnfHHgK1Ik2/EywJacQLHwwc2ie7cFFWw== X-Received: by 2002:adf:8327:: with SMTP id 36-v6mr5013988wrd.176.1527753819047; Thu, 31 May 2018 01:03:39 -0700 (PDT) Received: from 6wind.com ([2a01:cb19:142:1800:5db:7039:641c:ad8c]) by smtp.gmail.com with ESMTPSA id 131-v6sm593036wms.34.2018.05.31.01.03.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 May 2018 01:03:38 -0700 (PDT) From: David Marchand To: dev@dpdk.org Cc: Olivier Matz Date: Thu, 31 May 2018 10:03:28 +0200 Message-Id: <1527753808-19409-2-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527753808-19409-1-git-send-email-david.marchand@6wind.com> References: <1527753808-19409-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH 2/2] cmdline: remove useless intermediate buffer X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2018 08:03:39 -0000 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