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 DD786A0503; Wed, 18 May 2022 12:17:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D189C42B7E; Wed, 18 May 2022 12:17:43 +0200 (CEST) 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 726FE42B7C for ; Wed, 18 May 2022 12:17:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652869062; 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=SpBsPtfJXg7uFYb7ZVgI2WwOY7y/aEYXx7lzo3SrJ9w=; b=J+YQXtkaH5fgM7ZyjcvJoqbm1rv/QIFblhgY4GziuPy9xknR9RSvhAhMsfzlYX6I9YJNG7 TJNM1VvXBocYwbOqCtj3gOi72OY/QgR71bi46P0k+gJCzi6xKAKSMoLCe+HdwFOK7jYsMo COfNzYQzobe9xIs35mbLg/LPFIDe8XM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-svzbCtz4O2yYhEn8YWXHGg-1; Wed, 18 May 2022 06:17:39 -0400 X-MC-Unique: svzbCtz4O2yYhEn8YWXHGg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7115A3C16193; Wed, 18 May 2022 10:17:38 +0000 (UTC) Received: from fchome.home (unknown [10.40.195.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EF76492C14; Wed, 18 May 2022 10:17:34 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@xilinx.com, stable@dpdk.org, Marcin Wojtas , Michal Krawczyk , Shai Brandes , Evgeny Schemeilin , Igor Chauskin Subject: [PATCH 04/12] net/ena: fix build with GCC 12 Date: Wed, 18 May 2022 12:16:49 +0200 Message-Id: <20220518101657.1230416-5-david.marchand@redhat.com> In-Reply-To: <20220518101657.1230416-1-david.marchand@redhat.com> References: <20220518101657.1230416-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com 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 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. Cc: stable@dpdk.org Signed-off-by: David Marchand --- drivers/net/ena/ena_rss.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ena/ena_rss.c b/drivers/net/ena/ena_rss.c index b6c4f76e38..b682d01c20 100644 --- a/drivers/net/ena/ena_rss.c +++ b/drivers/net/ena/ena_rss.c @@ -51,15 +51,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))); } int ena_rss_reta_update(struct rte_eth_dev *dev, -- 2.36.1