From nobody Thu Oct 2 19:38:18 2025 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 863B7305046; Fri, 12 Sep 2025 12:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757680286; cv=none; b=HGcgAQ0qpYNuYZwaw5cPV2xKwNV1IhBgPjI/xBLk0ClKfko8mWne8zVjPFsKiEq2oICDAWZCCPpSBkqNDXCeYe9M41A8QaNweocXVh5wKW8iXYx7HUxLDy9oyNTjSrBdvXHzAL5xqdb4hTpsl0BK/ZHk9Q/vwsgtygauzMTFSmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757680286; c=relaxed/simple; bh=+8A4GsCErF68UbEHFv25lzsdwJliaWDufQGZLDYg8ro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sdEZ+0etOYRGk/ZM1QN6dl6kNDceC5/lJhseMrspo4CyaTAobUhTYpSG9XOw6InvwmrKjJzR18mr7ccTJovqOB7Hj7WOnjmCO3ybf+72r6PP60nTNEfysgrAHa89C1XSiKxTGBWSZXscxhY2u9QsOyFRf2CXZTkDWkZJn8EE7s0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=JZx55i85; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="JZx55i85" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1757680281; bh=+8A4GsCErF68UbEHFv25lzsdwJliaWDufQGZLDYg8ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZx55i85auuE2Dc9gI2kjOxJzaNdpk438dMjZ3qbQL2GxwcMfhkBMIOs40YaadmMV wgdsJrBpoCoUAjRjzNVKUI8eWzTXWHiW+2s4KN3g/fFEV7eI9q9zQXI1mG4OWu0x5V NiIJQ2RICSDnLJEwNqrobsYO/9Z2OuP+82YlfVyRMCQ+4bxTZ4+Rxd49j44ClTM4+g gSkNLKQ+aATw+Jj+2gF5Eym+jKSgw8LUtJxEPJwHQOUGHB4Cs4fDV4AgxKGrieGUja 6Md8nHWY87gIN4boh2hKV8fEHJRWIR6pZEDErfvcZ5RtcqJwpUrYZilceHx4IC1Agm gUcUTl0+Ps70g== Received: from mt.tail9873f4.ts.net (unknown [144.48.130.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by bali.collaboradmins.com (Postfix) with ESMTPSA id 26ED517E0927; Fri, 12 Sep 2025 14:31:14 +0200 (CEST) From: Muhammad Usama Anjum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Jason Gunthorpe , Leon Romanovsky , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Muhammad Usama Anjum , kernel@collabora.com, Sidhartha Kumar Subject: [PATCH 2/2] selftests/mm: protection_keys: Fix dead code Date: Fri, 12 Sep 2025 17:30:22 +0500 Message-ID: <20250912123025.1271051-3-usama.anjum@collabora.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250912123025.1271051-1-usama.anjum@collabora.com> References: <20250912123025.1271051-1-usama.anjum@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The while loop doesn't execute and following warning gets generated: protection_keys.c:561:15: warning: code will never be executed [-Wunreachable-code] int rpkey =3D alloc_random_pkey(); Let's enable the while loop such that it gets executed nr_iterations times. Simplify the code a bit as well. Reviewed-by: Sidhartha Kumar Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/protection_keys.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/s= elftests/mm/protection_keys.c index 23ebec367015f..6281d4c61b50e 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -557,13 +557,11 @@ int mprotect_pkey(void *ptr, size_t size, unsigned lo= ng orig_prot, int nr_iterations =3D random() % 100; int ret; =20 - while (0) { + while (nr_iterations-- >=3D 0) { int rpkey =3D alloc_random_pkey(); ret =3D sys_mprotect_pkey(ptr, size, orig_prot, pkey); dprintf1("sys_mprotect_pkey(%p, %zx, prot=3D0x%lx, pkey=3D%ld) ret: %d\n= ", ptr, size, orig_prot, pkey, ret); - if (nr_iterations-- < 0) - break; =20 dprintf1("%s()::%d, ret: %d pkey_reg: 0x%016llx" " shadow: 0x%016llx\n", --=20 2.47.3