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 6EAF145B13; Fri, 11 Oct 2024 17:25:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15F154028B; Fri, 11 Oct 2024 17:25:46 +0200 (CEST) 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 CF77E4028B for ; Fri, 11 Oct 2024 17:25:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728660343; 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; bh=05rV4sXLAZr1HkRQs2qvKuUcBsjqAcXeUNz3T7FFIfE=; b=aRou2laTJGuTDzg+rZac93vtkQvZ0PecJBVK7HMYqNxF0R1p85zG5SAm+6L17VcMOULd2+ mezi7DV0UJwnTDcQs8P2XI8IlPArUuYAgfd84IG+3kZ9Nx0T6XrS/qoxn2zheDB/8KW10W LjRfAaMnoo5vbobR9DCmfyYuqTXggUI= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-549-7TZ-ShgKOr6tnCZlboU5bA-1; Fri, 11 Oct 2024 11:25:40 -0400 X-MC-Unique: 7TZ-ShgKOr6tnCZlboU5bA-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AEC0B1955D99; Fri, 11 Oct 2024 15:25:38 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.68]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 672B619560A2; Fri, 11 Oct 2024 15:25:35 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Jack Bond-Preston , =?UTF-8?q?Morten=20Br=C3=B8rup?= , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Tyler Retzlaff Subject: [PATCH] test/bitops: check worker lcore availability Date: Fri, 11 Oct 2024 17:25:33 +0200 Message-ID: <20241011152533.3189097-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 Coverity is not able to understand that having 2 lcores means that rte_get_next_lcore(-1, 0, 1) can't return RTE_MAX_LCORE. Add an assert. Coverity issue: 445382, 445383, 445384, 445387, 445389, 445391 Fixes: 35326b61aecb ("bitops: add atomic bit operations in new API") Signed-off-by: David Marchand --- Note: - a better fix would be to check lcore id validity in the EAL launch API, but it requires inspecting all functions and it could result in some API change, so sending this as a simple fix for now, --- app/test/test_bitops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/test/test_bitops.c b/app/test/test_bitops.c index 4200073ae4..4ed54709fb 100644 --- a/app/test/test_bitops.c +++ b/app/test/test_bitops.c @@ -159,6 +159,7 @@ test_bit_atomic_parallel_assign ## size(void) \ return TEST_SKIPPED; \ } \ worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + TEST_ASSERT(worker_lcore_id < RTE_MAX_LCORE, "Failed to find a worker lcore"); \ lmain.bit = rte_rand_max(size); \ do { \ lworker.bit = rte_rand_max(size); \ @@ -218,6 +219,7 @@ test_bit_atomic_parallel_test_and_modify ## size(void) \ return TEST_SKIPPED; \ } \ worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + TEST_ASSERT(worker_lcore_id < RTE_MAX_LCORE, "Failed to find a worker lcore"); \ int rc = rte_eal_remote_launch(run_parallel_test_and_modify ## size, &lworker, \ worker_lcore_id); \ TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ @@ -267,6 +269,7 @@ test_bit_atomic_parallel_flip ## size(void) \ return TEST_SKIPPED; \ } \ worker_lcore_id = rte_get_next_lcore(-1, 1, 0); \ + TEST_ASSERT(worker_lcore_id < RTE_MAX_LCORE, "Failed to find a worker lcore"); \ int rc = rte_eal_remote_launch(run_parallel_flip ## size, &lworker, worker_lcore_id); \ TEST_ASSERT(rc == 0, "Worker thread launch failed"); \ run_parallel_flip ## size(&lmain); \ -- 2.46.2