From nobody Sat Oct 4 00:20:05 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 7129A2EBB93; Fri, 22 Aug 2025 08:23:11 +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=1755850993; cv=none; b=Js8W6B1SLlJerWS02r1yUtBko2JpvCa+BbMYzwVJy/hcGLGxj+enqbT8n1iPPYoxlovb71Ri7xvG0oy1Ol7nq3cUSIf3dObdNz/X57p5l+Ju7B6IlF4ursJvP2AbPwBSoXq6Yw3/0wecLvaqGl7tqNpAGSRkE9GDrBie/+co3h0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755850993; c=relaxed/simple; bh=vKA3QXzgA9t4nw9n7BL15bfwnNSlvwYMDzMnDq2mC9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JzTkZjIOtMPHS9Wrd0kGJi08MtQ1NkPjYssJhLgpO2dR32P3UvXQGp0Vhn1Rij02uJQNgI7kV8t2jEOoaDFfZbDCTnVRBEQ8Ead7rlLTpEP2GuuiYZbM4AF0yKNGCuxS++qfymq8iC8lviiJdFaZTPMkRL2UU7MPYPRmE7f7rK8= 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=lvazUn21; 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="lvazUn21" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1755850984; bh=vKA3QXzgA9t4nw9n7BL15bfwnNSlvwYMDzMnDq2mC9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lvazUn21mN5Ye3Fu9Rd0Qb8O/9oQP7dp2h2wxUwlcWLhgES+LpwVZJLjpScWskZL7 3WZBdRrI7PEAxplXJcGJHIRGcaXaInkLbb8aym1lu1i5+/jO2ZFvXq4wj6QUjP8wHm +wJE4gX6Tm6AbF/do2Yy4zaHURlmKy6N9o0UnIaoHifbkeIp6djQ6MUebA17j/Sofj BRHbz5sKR0pFZdY5WVu3kd6CEYM5losGNsySuj2MHjxq7cOlNmxR/jImA84XpEMPC+ k85k93U/nvYGBpFw2SAKlNlivkJPKqMVja4sPTnj2zxRT9ShfMkYjiKYPd7KEIrGmO tnkywhhJ5UGSg== Received: from mt.tail9873f4.ts.net (unknown [103.151.43.82]) (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 8A15717E1340; Fri, 22 Aug 2025 10:22:59 +0200 (CEST) From: Muhammad Usama Anjum To: Shuah Khan , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jason Gunthorpe , John Hubbard , Peter Xu , Leon Romanovsky , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, kevin.brodsky@arm.com Cc: Muhammad Usama Anjum , kernel@collabora.com, Sidhartha Kumar Subject: [PATCH v3 1/8] selftests/mm: Add -Wunreachable-code and fix warnings Date: Fri, 22 Aug 2025 13:20:58 +0500 Message-ID: <20250822082145.4145617-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250822082145.4145617-1-usama.anjum@collabora.com> References: <20250822082145.4145617-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" Enable -Wunreachable-code flag to catch dead code and fix them. 1. Remove the dead code and write a comment instead: hmm-tests.c:2033:3: warning: code will never be executed [-Wunreachable-code] perror("Should not reach this\n"); ^~~~~~ 2. ksft_exit_fail_msg() calls exit(). Remove the dead code. split_huge_page_test.c:301:3: warning: code will never be executed [-Wunreachable-code] goto cleanup; ^~~~~~~~~~~~ 3. Remove duplicate inline. pkey_sighandler_tests.c:44:15: warning: duplicate 'inline' declaration specifier [-Wduplicate-decl-specifier] static inline __always_inline Reviewed-by: Sidhartha Kumar Signed-off-by: Muhammad Usama Anjum Reviewed-by: Kevin Brodsky --- Changes since v2: - In split_huge_page_test.c, print error message and then go to cleanup tag for cleanup instead of just exiting without cleanup --- tools/testing/selftests/mm/Makefile | 1 + tools/testing/selftests/mm/hmm-tests.c | 5 ++--- tools/testing/selftests/mm/pkey_sighandler_tests.c | 2 +- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/= mm/Makefile index d13b3cef2a2b2..23d4bf6215465 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -34,6 +34,7 @@ endif MAKEFLAGS +=3D --no-builtin-rules =20 CFLAGS =3D -Wall -O2 -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) $(T= OOLS_INCLUDES) +CFLAGS +=3D -Wunreachable-code LDLIBS =3D -lrt -lpthread -lm =20 # Some distributions (such as Ubuntu) configure GCC so that _FORTIFY_SOURC= E is diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftes= ts/mm/hmm-tests.c index 141bf63cbe05e..15aadaf24a667 100644 --- a/tools/testing/selftests/mm/hmm-tests.c +++ b/tools/testing/selftests/mm/hmm-tests.c @@ -2027,11 +2027,10 @@ TEST_F(hmm, hmm_cow_in_device) if (pid =3D=3D -1) ASSERT_EQ(pid, 0); if (!pid) { - /* Child process waitd for SIGTERM from the parent. */ + /* Child process waits for SIGTERM from the parent. */ while (1) { } - perror("Should not reach this\n"); - exit(0); + /* Should not reach this */ } /* Parent process writes to COW pages(s) and gets a * new copy in system. In case of device private pages, diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/tes= ting/selftests/mm/pkey_sighandler_tests.c index b5e076a564c95..302fef54049c8 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -41,7 +41,7 @@ static siginfo_t siginfo =3D {0}; * syscall will attempt to access the PLT in order to call a library funct= ion * which is protected by MPK 0 which we don't have access to. */ -static inline __always_inline +static __always_inline long syscall_raw(long n, long a1, long a2, long a3, long a4, long a5, long= a6) { unsigned long ret; diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/test= ing/selftests/mm/split_huge_page_test.c index bf40e6b121abc..de0d26f3df675 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -297,7 +297,7 @@ void split_file_backed_thp(int order) =20 status =3D snprintf(testfile, INPUT_MAX, "%s/thp_file", tmpfs_loc); if (status >=3D INPUT_MAX) { - ksft_exit_fail_msg("Fail to create file-backed THP split testing file\n"= ); + ksft_print_msg("Fail to create file-backed THP split testing file\n"); goto cleanup; } =20 --=20 2.47.2