From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 625DB42805; Wed, 22 Mar 2023 18:06:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0EB5740E09; Wed, 22 Mar 2023 18:06:40 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 3740340A84 for ; Wed, 22 Mar 2023 18:06:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679504797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1+1r1NysYz+fykOIVbDYQnEDiuZPK4okXzBzNNFn5fQ=; b=bhHUduaD9etQi5XSuzVrLNYg7Muvb04oO8IH3CHYhAFsQJ5C0XMBRo5vHWwloS1yN/QTCh EBVOCmR7limvmIgY+qYgVZalN9lytkOaWZVGGxv+PjRfX+5wZm71SbqXuh9CRHJjLHP2HG Bl3meW6Jc4HKoTJ1ksRvJN6FIQu60ps= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-538-kyCJod3nOsOBIDHQc1vrnA-1; Wed, 22 Mar 2023 13:06:36 -0400 X-MC-Unique: kyCJod3nOsOBIDHQc1vrnA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1776F886063; Wed, 22 Mar 2023 17:06:36 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39753140E96A; Wed, 22 Mar 2023 17:06:35 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH v2] net/mlx5: fix build with GCC 12 and ASan Date: Wed, 22 Mar 2023 18:06:27 +0100 Message-Id: <20230322170627.2317956-1-david.marchand@redhat.com> In-Reply-To: <20230309090317.847742-1-david.marchand@redhat.com> References: <20230309090317.847742-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Building with gcc 12 and ASan raises this warning: ../drivers/net/mlx5/mlx5_txpp.c: In function ‘mlx5_txpp_xstats_get_names’: ../drivers/net/mlx5/mlx5_txpp.c:1066:25: error: ‘strncpy’ specified bound 64 equals destination size [-Werror=stringop-truncation] 1066 | strncpy(xstats_names[i + n_used].name, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1067 | mlx5_txpp_stat_names[i], | ~~~~~~~~~~~~~~~~~~~~~~~~ 1068 | RTE_ETH_XSTATS_NAME_SIZE); | ~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Prefer strlcpy for xstats. Fixes: 3b025c0ca425 ("net/mlx5: provide send scheduling error statistics") Cc: stable@dpdk.org Signed-off-by: David Marchand --- Changes since v1: - updated mlx5_xstats_get_names too, --- drivers/net/mlx5/mlx5_stats.c | 3 +-- drivers/net/mlx5/mlx5_txpp.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index f64fa3587b..615e1d073d 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -288,10 +288,9 @@ mlx5_xstats_get_names(struct rte_eth_dev *dev, if (n >= mlx5_xstats_n && xstats_names) { for (i = 0; i != mlx5_xstats_n; ++i) { - strncpy(xstats_names[i].name, + strlcpy(xstats_names[i].name, xstats_ctrl->info[i].dpdk_name, RTE_ETH_XSTATS_NAME_SIZE); - xstats_names[i].name[RTE_ETH_XSTATS_NAME_SIZE - 1] = 0; } } mlx5_xstats_n = mlx5_txpp_xstats_get_names(dev, xstats_names, diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c index 63d98dbde9..0e1da1d5f5 100644 --- a/drivers/net/mlx5/mlx5_txpp.c +++ b/drivers/net/mlx5/mlx5_txpp.c @@ -1063,11 +1063,9 @@ int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev __rte_unused, if (n >= n_used + n_txpp && xstats_names) { for (i = 0; i < n_txpp; ++i) { - strncpy(xstats_names[i + n_used].name, + strlcpy(xstats_names[i + n_used].name, mlx5_txpp_stat_names[i], RTE_ETH_XSTATS_NAME_SIZE); - xstats_names[i + n_used].name - [RTE_ETH_XSTATS_NAME_SIZE - 1] = 0; } } return n_used + n_txpp; -- 2.39.2