From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id A3ACDA05D3 for ; Tue, 23 Apr 2019 18:48:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 520E01B42B; Tue, 23 Apr 2019 18:48:27 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 72F711B3A8 for ; Tue, 23 Apr 2019 18:48:23 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id f6so7879603pgs.8 for ; Tue, 23 Apr 2019 09:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=62W36ynNMKSTZgtQuhWc9PSZc0VPxhnbMciWt9vJ8bE=; b=U9CkNZWHmo6NtbyHUpdR3ax/As4yOgvpGJWmxQJRMIjYYuzb9N1vfAj4DXYADcpZvL qO/WZFb4BOxiLc7fFCRT+fDS+PTtW/YAGdEYz8et71nys+MaaMD9qdfXffcZpQZ0WMNH LrXZB1E+HhGostpTza9UuDqmD/f1IxD6FHSIb7AkWTkBZMuyEGgLUosGskNM407Ugzx9 NCjB3Jxr7E89iZDUOHeogyznkGpw3/jZnLQkabSCXCWg0dKvS7EdaDNHTPhzwyw07mmH tlFE2a1FffrYdErtuzMQHwR1gd4GxoKJHh+A8y6nL4BfxXC/HXzKKj3wV+7YCqhAcoes v3Zw== 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:mime-version:content-transfer-encoding; bh=62W36ynNMKSTZgtQuhWc9PSZc0VPxhnbMciWt9vJ8bE=; b=eeLTVmxNxvUrkUjYD1OpXzh+/NzLcSloLwsmdv324GtWLg6zhdzoFsjciNzl/HxsXe 9IpKy/EI1riO+GgPWIqUinHbVylz7DNHjsUBkhRAMkTyA58ol+t3nev+OsxN8JEnhPpX yGmOD8SPOeeqN9GgGLNneVpO77PpJj8wPQ6lyyD3uaAbIJb/aq/J6qB8mTuqZifp9voX m8jT7kAtqxwMpqAbFiRmgWt05zBMCG2f/2x8Rn2VAVLoOuZI/uuUOSdFDdCU1dlE401X /FrEeJosS/aT10xFnp0BnzVfdnDX4T7kPZyVz0P3VehWOpBhl/5sCFzWAW24IYEJrB+2 8lfw== X-Gm-Message-State: APjAAAXYNm1AvNDbYd/1NNyPVesdIsFfwrhyHhlQezohxA+NTDlJzXIL Bp3X8aw+N0+IvyGPUd2cmhmqjiRbn1E= X-Google-Smtp-Source: APXvYqyBhLXNnbbJItPoT5Ib/kts6s3Wb5fRVFgmTr4p2OfqAS7qcuRcViFBsrOMAeGmbZ1PPUkj9w== X-Received: by 2002:a62:aa06:: with SMTP id e6mr28100079pff.254.1556038102629; Tue, 23 Apr 2019 09:48:22 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h65sm58943277pfd.108.2019.04.23.09.48.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 09:48:21 -0700 (PDT) From: Stephen Hemminger To: bruce.richardson@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 23 Apr 2019 09:48:10 -0700 Message-Id: <20190423164812.3427-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423164812.3427-1-stephen@networkplumber.org> References: <20190423164812.3427-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/4] net/ring: use sizeof() with snprintf 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190423164810.YSLFPuQ2FBsho90sNSj05TH8lOjW-x-4Jn0PQb60JDs@z> Don't hard code string length in two place; use sizeof() instead. Ring name shoudl use RTE_RING_NAMESIZE. Signed-off-by: Stephen Hemminger --- drivers/net/ring/rte_eth_ring.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 91e5f5f8f262..2e4ca3b16a1c 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -362,8 +362,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], .numa_node = numa_node, .addr = &args, }; - char args_str[32] = { 0 }; - char ring_name[32] = { 0 }; + char args_str[32]; + char ring_name[RTE_RING_NAMESIZE]; uint16_t port_id = RTE_MAX_ETHPORTS; int ret; @@ -381,8 +381,9 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], return -1; } - snprintf(args_str, 32, "%s=%p", ETH_RING_INTERNAL_ARG, &args); - snprintf(ring_name, 32, "net_ring_%s", name); + snprintf(args_str, sizeof(args_str), "%s=%p", + ETH_RING_INTERNAL_ARG, &args); + snprintf(ring_name, sizeof(ring_name), "net_ring_%s", name); ret = rte_vdev_init(ring_name, args_str); if (ret) { -- 2.20.1