From patchwork Fri Sep 6 11:26:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 1158952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46PwHN4phXz9s7T for ; Fri, 6 Sep 2019 21:26:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 95018E45; Fri, 6 Sep 2019 11:26:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id B4BBDE1E for ; Fri, 6 Sep 2019 11:26:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6B0C67DB for ; Fri, 6 Sep 2019 11:26:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A384B308624A; Fri, 6 Sep 2019 11:26:18 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-204-127.brq.redhat.com [10.40.204.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 650C2608A5; Fri, 6 Sep 2019 11:26:17 +0000 (UTC) From: David Marchand To: dev@openvswitch.org Date: Fri, 6 Sep 2019 13:26:02 +0200 Message-Id: <1567769162-10110-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 06 Sep 2019 11:26:18 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: i.maximets@samsung.com Subject: [ovs-dev] [PATCH] dpdk: Remove unneeded log message copy. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org No need to duplicate and null-terminate the passed buffer. We can directly give it to the vlog subsystem using a dynamic precision in the format string. Signed-off-by: David Marchand Acked-by: Eelco Chaudron --- lib/dpdk.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/dpdk.c b/lib/dpdk.c index f31e158..481a109 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -232,34 +232,32 @@ construct_dpdk_args(const struct smap *ovs_other_config, struct svec *args) static ssize_t dpdk_log_write(void *c OVS_UNUSED, const char *buf, size_t size) { - char *str = xmemdup0(buf, size); static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(600, 600); static struct vlog_rate_limit dbg_rl = VLOG_RATE_LIMIT_INIT(600, 600); switch (rte_log_cur_msg_loglevel()) { case RTE_LOG_DEBUG: - VLOG_DBG_RL(&dbg_rl, "%s", str); + VLOG_DBG_RL(&dbg_rl, "%.*s", (int)size, buf); break; case RTE_LOG_INFO: case RTE_LOG_NOTICE: - VLOG_INFO_RL(&rl, "%s", str); + VLOG_INFO_RL(&rl, "%.*s", (int)size, buf); break; case RTE_LOG_WARNING: - VLOG_WARN_RL(&rl, "%s", str); + VLOG_WARN_RL(&rl, "%.*s", (int)size, buf); break; case RTE_LOG_ERR: - VLOG_ERR_RL(&rl, "%s", str); + VLOG_ERR_RL(&rl, "%.*s", (int)size, buf); break; case RTE_LOG_CRIT: case RTE_LOG_ALERT: case RTE_LOG_EMERG: - VLOG_EMER("%s", str); + VLOG_EMER("%.*s", (int)size, buf); break; default: OVS_NOT_REACHED(); } - free(str); return size; }