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 5923BA00C2 for ; Thu, 8 Dec 2022 15:55:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52C2F40E28; Thu, 8 Dec 2022 15:55:51 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 7F23640A7E for ; Thu, 8 Dec 2022 15:55:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670511350; 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=UPZyfssyQfzTPJ+4hTlCFQKaztO4fkEJTaj/XoW9i0g=; b=iU4zA4fdnFtSt95HrjqLbJl1XJq2OdfewYGYwvgbrv3NWJkNFgFDvcYxhqCeBrxl1X/ykZ 65VuF911vxEZfMzccAxO7eVi5hk+ap2CD6XGtssPEquxIQBKyMfnDEf3KkU2u+fGJrPCHJ DwxEc1P45nhhZCm/p3TsseCCsoGxDyo= 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-537-fTWo-bJTN5WkHfbfPp18Bw-1; Thu, 08 Dec 2022 09:55:47 -0500 X-MC-Unique: fTWo-bJTN5WkHfbfPp18Bw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65ABD801231; Thu, 8 Dec 2022 14:55:46 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-246.brq.redhat.com [10.40.194.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A5F74C819; Thu, 8 Dec 2022 14:55:45 +0000 (UTC) From: David Marchand To: stable@dpdk.org Cc: bluca@debian.org, Stephen Hemminger Subject: [PATCH 20.11 2/4] net/ena: fix build with GCC 12 Date: Thu, 8 Dec 2022 15:49:08 +0100 Message-Id: <20221208144910.360883-2-david.marchand@redhat.com> In-Reply-To: <20221208144910.360883-1-david.marchand@redhat.com> References: <20221208144910.360883-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 2449949584667fbb275df1ea5a5ceeead1a65786 ] GCC 12 raises the following warning: In file included from ../lib/mempool/rte_mempool.h:46, from ../lib/mbuf/rte_mbuf.h:38, from ../lib/net/rte_ether.h:22, from ../drivers/net/ena/ena_ethdev.h:10, from ../drivers/net/ena/ena_rss.c:6: ../drivers/net/ena/ena_rss.c: In function ‘ena_rss_key_fill’: ../lib/eal/x86/include/rte_memcpy.h:370:9: warning: array subscript 64 is outside array bounds of ‘uint8_t[40]’ {aka ‘unsigned char[40]’} [-Warray-bounds] 370 | rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../drivers/net/ena/ena_rss.c:51:24: note: while referencing ‘default_key’ 51 | static uint8_t default_key[ENA_HASH_KEY_SIZE]; | ^~~~~~~~~~~ This is a false positive because the copied size is checked against ENA_HASH_KEY_SIZE in a (build) assert. Silence this warning by calling memcpy with the minimal size. Bugzilla ID: 849 Signed-off-by: David Marchand Acked-by: Stephen Hemminger --- Note on backport: - moved change to ena_ethdev.c, --- drivers/net/ena/ena_ethdev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index a4aac5a892..aa2b52ed47 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -292,15 +292,14 @@ void ena_rss_key_fill(void *key, size_t size) static uint8_t default_key[ENA_HASH_KEY_SIZE]; size_t i; - RTE_ASSERT(size <= ENA_HASH_KEY_SIZE); - if (!key_generated) { - for (i = 0; i < ENA_HASH_KEY_SIZE; ++i) + for (i = 0; i < RTE_DIM(default_key); ++i) default_key[i] = rte_rand() & 0xff; key_generated = true; } - rte_memcpy(key, default_key, size); + RTE_ASSERT(size <= sizeof(default_key)); + rte_memcpy(key, default_key, RTE_MIN(size, sizeof(default_key))); } static inline void ena_trigger_reset(struct ena_adapter *adapter, -- 2.38.1