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 16A25A05D3 for ; Tue, 23 Apr 2019 18:54:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9B0A51B486; Tue, 23 Apr 2019 18:53:52 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 3F7225F51 for ; Tue, 23 Apr 2019 18:53:47 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id i17so7786529pfo.6 for ; Tue, 23 Apr 2019 09:53:47 -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=B6vjUJvTH4zO2cRxNFnHr3m0WbM5epaG2ph1mdIHCIYkTN6jJ1I1jF54aAp5/44ace DBR8XaQ6L52oxqxSsWRgIb3uhHZ856D8QkeZSPHXrJjVGnLZ5oMpWuT4uYeQHtxz286e 3qJdF/cFC4xz8DZotMqISNbjWfIvE6Yu+rQJiGmFYPH9F/8xERWxhlFYndJR7FG1yOYV iPH9twYUAQ9BxRDq4nRHN9kv2b4SrQnlPCcBk7Wl69ovOSQVcbh9ba7XfT/hnLm/0IwB FJtXbq4L35ETgxYrE3Kvkor6fQg/yDQrtIWtqvB/ghGoqTbnoO4hd2wbRHFUybFoyPFI uHKQ== 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=MU7Gi77tmkbr3wTpRntedkF+lEErBbJz6Vua7Bx7M+TeF0FdcfYHcHXy5VJjEY6Bs3 Q3dkfkrkCp1cTsBEhNFcta0ttkjJyFP2HkG5ircepI4T30lkmg67J0pyibfbSNaE9+m/ vmqWybt9nSyYER12ne8V4eMF+K2MSKuAn763BTmTRpK48QMxjsyTzWYtkrOJu+8RNdO8 7lu4jjKCwXJuyCFt5LJhQBjLF+eaS8UtbZ8qcU2nv1iCwtjUBDTjRNo48v5Vc7fUE9qn oJYc+pQ9jAzatVvaelaRGoOVrvdQClDG8KgulwogbO8UfNu3N5hJip02DcsWywRGQKwR pR3w== X-Gm-Message-State: APjAAAWmPXhCzPcolDA6BEeRyqJsvpHELNSOHVVDpd6zCUGAHIWxH/uR 0DNb6Opm8aUGwoUjMrQrba6skpRObOI= X-Google-Smtp-Source: APXvYqzIfMtLgmI7ouO4fIMwSzd9j1nE2U2ifrIqdQg3gURAAajZkAB46aJoN1zssEWbuRsDr53bow== X-Received: by 2002:a65:62c9:: with SMTP id m9mr25649990pgv.309.1556038426235; Tue, 23 Apr 2019 09:53:46 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 71sm47194750pfs.36.2019.04.23.09.53.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 09:53:45 -0700 (PDT) From: Stephen Hemminger To: bruce.richardson@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 23 Apr 2019 09:53:33 -0700 Message-Id: <20190423165335.4025-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190423165335.4025-1-stephen@networkplumber.org> References: <20190423164812.3427-1-stephen@networkplumber.org> <20190423165335.4025-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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: <20190423165333.8iG8uBXvJW-eiaAcmJXTnLvllXSntXnmS2c2W1AoGKo@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