From patchwork Fri May 3 20:31:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13653414 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53B1220B0F; Fri, 3 May 2024 20:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714768299; cv=none; b=b5Fc2G81+F1csprH4H3/N+uFwJI+4N27U3QYdGmqEaS2XlL9sAT3jF+1EyTrunVRRutTbBchVbLN8UJ+1bc+6muyaNVH60nZJPQ+dMRC9hZa7+H/tyyEjnM1ZpU9is7bGOQdrEYew3CDUs0KO1NP9flpFQHEPOCUJsi8wRe2HvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714768299; c=relaxed/simple; bh=bQv0f4/wzs5hDrGBpr/rtiheHbS4IDq6X15ct59uLMk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IzeVEcE39G4ZGGTSlO3zIl9XG8hK2uZyMHFhSlol3Ns4vkKn4AJsoTCpjKN3ZLdVlzdazuva7n/0ho3eQwOsszvgDNyCRpIa44JQbr/WIizeIbWSBLMi/srOfmOwlPo8M/YHxlUsWggM5RSikdF6YUuU1gy+dJk8u6LmgWsAryw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U8uCDzk7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U8uCDzk7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B41BAC4AF1A; Fri, 3 May 2024 20:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714768298; bh=bQv0f4/wzs5hDrGBpr/rtiheHbS4IDq6X15ct59uLMk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=U8uCDzk765l9Ygwhh4btegniTw/2GDkgNCwi9kH6oLQFWjaWY6nrvwk6pN0kHFNCx e3yLKgz1UMaOW5IU2MgluEUUa3AvYuhngG5l3L/mtnegSRkYCvSGpKaiXgq003HTxX Cr3Fk7tJTGq0phClxANEG0e1EGtFu904s10Urb/LbAP98Fq4/7zZ94RgHHk2NiKD4G Vow/jW4TnI+nk1So5E9WaMNOTCbamXFJFumhQX9oPcm9CXZ1yqOyNBt+RGU7Sp/hSy zns3HEqyuKXA1vn5vlqtykLHAlUWf9FNJ36lbzXLszuCm0H7eaGm2uGTN7plItx8LT i8hx/m4BLZaFA== From: Simon Horman Date: Fri, 03 May 2024 21:31:26 +0100 Subject: [PATCH net-next 1/2] gve: Avoid unnecessary use of comma operator Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240503-gve-comma-v1-1-b50f965694ef@kernel.org> References: <20240503-gve-comma-v1-0-b50f965694ef@kernel.org> In-Reply-To: <20240503-gve-comma-v1-0-b50f965694ef@kernel.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Dan Carpenter , Kees Cook , netdev@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org X-Mailer: b4 0.12.3 X-Patchwork-Delegate: kuba@kernel.org Although it does not seem to have any untoward side-effects, the use of ';' to separate to assignments seems more appropriate than ','. Flagged by clang-18 -Wcomma No functional change intended. Compile tested only. Signed-off-by: Simon Horman --- drivers/net/ethernet/google/gve/gve_adminq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c index b2b619aa2310..8d49462170a3 100644 --- a/drivers/net/ethernet/google/gve/gve_adminq.c +++ b/drivers/net/ethernet/google/gve/gve_adminq.c @@ -649,9 +649,9 @@ static int gve_adminq_create_rx_queue(struct gve_priv *priv, u32 queue_index) GVE_RAW_ADDRESSING_QPL_ID : rx->data.qpl->id; cmd.create_rx_queue.rx_desc_ring_addr = - cpu_to_be64(rx->desc.bus), + cpu_to_be64(rx->desc.bus); cmd.create_rx_queue.rx_data_ring_addr = - cpu_to_be64(rx->data.data_bus), + cpu_to_be64(rx->data.data_bus); cmd.create_rx_queue.index = cpu_to_be32(queue_index); cmd.create_rx_queue.queue_page_list_id = cpu_to_be32(qpl_id); cmd.create_rx_queue.packet_buffer_size = cpu_to_be16(rx->packet_buffer_size); From patchwork Fri May 3 20:31:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13653415 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1F341CD29; Fri, 3 May 2024 20:31:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714768303; cv=none; b=c/LcFmFRhLBima+QYnzXHpKtuOcyj+LVX/Z9GnCqckonQGSoChLkis6Q/DvcS2UBQDXnBiXSSWrcqhGWOcAvr1+iVQ6nDKJK+zDFdZ/jDVSCBeQ7XqpsP6GrfO8+qwZSA554hDcn+wHP1E2kY7JeZVmmS5io/6hQ+UTY+G5hg/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714768303; c=relaxed/simple; bh=bcTauFkomv1VILEJF41wZk4z7dvbXuYeoULUQhP2zZk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OzGWSVaqVvkD87KgXVU0yxtbHATt23tg0ttZ7griZ0mskep6+NLP41u8JbA7qUUkp2a+BT0y9PSfLvKGutky9vPF6ukK5RLY2rB8YRVjlokOR+iVsP/NLXtk+BIKgGs68Az93bhOQVk8vI03+TGx17PnJrpsYKKt/LzPegtmVaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W93gt274; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W93gt274" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 528CCC4AF18; Fri, 3 May 2024 20:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714768302; bh=bcTauFkomv1VILEJF41wZk4z7dvbXuYeoULUQhP2zZk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=W93gt274PAHvzNxwsBcJ3CCeVDGGGfNF+yeyVwqj0nN0wXYGYqVna7KqLAsylNFM0 cWQGae7LwjrM1ci3bTzUYNHoL7jWx1Hw+WkuFHEHNPvWZP9gzf2tbgbxDjHVRYa9IN 9I/m1sgvuzYp7hqBoWtvNARPS0Ic0zo/xsTbAUuULtmV4Hj5vBOQ8GdvAKQgcXh+ZT SGQfYDPbhnxU9PuYBJkJYkoYy9W84itMv7Axb84bjWhqZIPUCzMXtP8sQYsRdq4yn4 CYOPqlUeJNsg9/yaQQepyOKhXHjBEgb+IigK/aFc4Nso/Igq0UuTULNKce+PQCjL4p aB0H6BXJmgCqA== From: Simon Horman Date: Fri, 03 May 2024 21:31:27 +0100 Subject: [PATCH net-next 2/2] gve: Use ethtool_sprintf/puts() to fill stats strings Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240503-gve-comma-v1-2-b50f965694ef@kernel.org> References: <20240503-gve-comma-v1-0-b50f965694ef@kernel.org> In-Reply-To: <20240503-gve-comma-v1-0-b50f965694ef@kernel.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Dan Carpenter , Kees Cook , netdev@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org X-Mailer: b4 0.12.3 X-Patchwork-Delegate: kuba@kernel.org Make use of standard helpers to simplify filling in stats strings. The first two ethtool_puts() changes address the following fortification warnings flagged by W=1 builds with clang-18. (The last ethtool_puts change does not because the warning relates to writing beyond the first element of an array, and gve_gstrings_priv_flags only has one element.) .../fortify-string.h:562:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning] 562 | __read_overflow2_field(q_size_field, size); | ^ .../fortify-string.h:562:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning] Likewise, the same changes resolve the same problems flagged by Smatch. .../gve_ethtool.c:100 gve_get_strings() error: __builtin_memcpy() '*gve_gstrings_main_stats' too small (32 vs 576) .../gve_ethtool.c:120 gve_get_strings() error: __builtin_memcpy() '*gve_gstrings_adminq_stats' too small (32 vs 512) Compile tested only. Signed-off-by: Simon Horman --- drivers/net/ethernet/google/gve/gve_ethtool.c | 42 +++++++++++---------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c index bd7632eed776..31563eeb0a41 100644 --- a/drivers/net/ethernet/google/gve/gve_ethtool.c +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c @@ -89,42 +89,34 @@ static const char gve_gstrings_priv_flags[][ETH_GSTRING_LEN] = { static void gve_get_strings(struct net_device *netdev, u32 stringset, u8 *data) { struct gve_priv *priv = netdev_priv(netdev); - char *s = (char *)data; + u8 *s = (char *)data; int num_tx_queues; int i, j; num_tx_queues = gve_num_tx_queues(priv); switch (stringset) { case ETH_SS_STATS: - memcpy(s, *gve_gstrings_main_stats, - sizeof(gve_gstrings_main_stats)); - s += sizeof(gve_gstrings_main_stats); - - for (i = 0; i < priv->rx_cfg.num_queues; i++) { - for (j = 0; j < NUM_GVE_RX_CNTS; j++) { - snprintf(s, ETH_GSTRING_LEN, - gve_gstrings_rx_stats[j], i); - s += ETH_GSTRING_LEN; - } - } + for (i = 0; i < ARRAY_SIZE(gve_gstrings_main_stats); i++) + ethtool_puts(&s, gve_gstrings_main_stats[i]); - for (i = 0; i < num_tx_queues; i++) { - for (j = 0; j < NUM_GVE_TX_CNTS; j++) { - snprintf(s, ETH_GSTRING_LEN, - gve_gstrings_tx_stats[j], i); - s += ETH_GSTRING_LEN; - } - } + for (i = 0; i < priv->rx_cfg.num_queues; i++) + for (j = 0; j < NUM_GVE_RX_CNTS; j++) + ethtool_sprintf(&s, gve_gstrings_rx_stats[j], + i); + + for (i = 0; i < num_tx_queues; i++) + for (j = 0; j < NUM_GVE_TX_CNTS; j++) + ethtool_sprintf(&s, gve_gstrings_tx_stats[j], + i); + + for (i = 0; i < ARRAY_SIZE(gve_gstrings_adminq_stats); i++) + ethtool_puts(&s, gve_gstrings_adminq_stats[i]); - memcpy(s, *gve_gstrings_adminq_stats, - sizeof(gve_gstrings_adminq_stats)); - s += sizeof(gve_gstrings_adminq_stats); break; case ETH_SS_PRIV_FLAGS: - memcpy(s, *gve_gstrings_priv_flags, - sizeof(gve_gstrings_priv_flags)); - s += sizeof(gve_gstrings_priv_flags); + for (i = 0; i < ARRAY_SIZE(gve_gstrings_priv_flags); i++) + ethtool_puts(&s, gve_gstrings_priv_flags[i]); break; default: