From patchwork Thu Jan 9 17:38:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13933055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAFA2E77199 for ; Thu, 9 Jan 2025 17:39:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BFDB6B009D; Thu, 9 Jan 2025 12:39:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36F3B6B009E; Thu, 9 Jan 2025 12:39:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20EE76B009F; Thu, 9 Jan 2025 12:39:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 005F46B009D for ; Thu, 9 Jan 2025 12:39:43 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B183FAEBBA for ; Thu, 9 Jan 2025 17:39:43 +0000 (UTC) X-FDA: 82988625846.06.C923E72 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by imf02.hostedemail.com (Postfix) with ESMTP id CCE7A8000A for ; Thu, 9 Jan 2025 17:39:41 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=collabora.com header.s=zohomail header.b=A35ZxRJp; spf=pass (imf02.hostedemail.com: domain of usama.anjum@collabora.com designates 136.143.188.112 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=none) header.from=collabora.com; arc=pass ("zohomail.com:s=zohoarc:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736444382; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uB7d7cJEDiC0mfsDNRFgeWBfbQ3rX6PW8t4akxqZYn4=; b=thzLcZj2PYqPzlu7QA2BDvc+poP5BqkKfdqmYN5E7WOsyIEysHK6GTKNoYJ6sZl6Y/sbnX 1lBGlHCeIQwDL8nL56kyORCXhS+jg5T8+T1CeIyYHAC4ddBvqj+XBwG93FSl5tLTg10f6T 5rttN+V/PuBiH336uTgapLxGF6eCLMA= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=collabora.com header.s=zohomail header.b=A35ZxRJp; spf=pass (imf02.hostedemail.com: domain of usama.anjum@collabora.com designates 136.143.188.112 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=none) header.from=collabora.com; arc=pass ("zohomail.com:s=zohoarc:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1736444382; a=rsa-sha256; cv=pass; b=VcEB0Eb7CXskDWaNxepeDqNsMwxBtLWYdz6hpjSVUbUeogLdmkDZnLLsMEZ++S4Kmjmpgo LEXDM4jD0k1LZpTDfHAXTzGYhun/+DYQmOk5AY9GXo+kZ0u90UUG2OBcbaTpHKHZI4u1P7 +Nsr2PZzV+7TaLFrm9iMPeMyHzQCVEc= ARC-Seal: i=1; a=rsa-sha256; t=1736444359; cv=none; d=zohomail.com; s=zohoarc; b=V6WhZ1235fCUlH1yWZPtPmxICpHAgv0DtL9N4Ez7GYG6urRZm4P28QEEcjtPEYWzuEcsam2faHAUPU4g+LOFxwxeYxJUzlyXcAg9WTRAkRET6MVprE9zdWDOzO7a+VurEWDt4UpPT6TBq+/wrDArsE06fCDPgYot9Z+Uehf4vQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736444359; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=uB7d7cJEDiC0mfsDNRFgeWBfbQ3rX6PW8t4akxqZYn4=; b=E70OIudC6kPSaCUlYutnjGL8ZEm7oesyAoO6JNDdSACc5o5edMZ3R/Hbf9MFfX/d/mT2QEyR5nbEurCqggF/Ol+jQpSfOrJUc9vUMR2tHJwplL3fX4gVthuKcivXhI86JLR7abPL66SYqeaBx3zdrySpY9NiCkRO3KoWVSWrU4A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1736444359; s=zohomail; d=collabora.com; i=usama.anjum@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=uB7d7cJEDiC0mfsDNRFgeWBfbQ3rX6PW8t4akxqZYn4=; b=A35ZxRJpXC6uwKe+6hO0cF93zmH6F9UdJSZOA1d+7FC3QYhIUdIqDJdqBltvMeNV zlIGgSewv1HMOBh028S/kxWO71x51jpEOaAqdtQcyEt917zjUS4wZXwDzZo/5VlwkWe h6hgs+dJoPT1oEAxrw8Bz/9vZX/jLh6gUogubzeA= Received: by mx.zohomail.com with SMTPS id 1736444357047582.4071763448949; Thu, 9 Jan 2025 09:39:17 -0800 (PST) From: Muhammad Usama Anjum To: Kees Cook , Andy Lutomirski , Will Drewry , Shuah Khan , Andrew Morton , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Muhammad Usama Anjum , kernel@collabora.com Subject: [PATCH 06/16] selftests/mm: cow: remove unused variables and fix type mismatch errors Date: Thu, 9 Jan 2025 22:38:32 +0500 Message-Id: <20250109173842.1142376-7-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250109173842.1142376-1-usama.anjum@collabora.com> References: <20250109173842.1142376-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-ZohoMailClient: External X-Rspamd-Server: rspam05 X-Stat-Signature: p3efaaigqccndx81g99kap1nuk8dnct3 X-Rspamd-Queue-Id: CCE7A8000A X-Rspam-User: X-HE-Tag: 1736444381-32774 X-HE-Meta: U2FsdGVkX1/lKcIYlkT4wP3m46d5vj14qj2aBMi+IOChCp2sts8EMkz63ugPUmahWjMoTWmjTKXG2VLUUfa153I93GUGBKDPuiNug98i+ohpdu3sXlB8BGXQSu7LSDLopc+XL682EBxKd5awL5Q1eQHx8dYPjjIHkEDHTm4JtoBa6lrhbxv7P0hRMZVE5Fn7AgZSW1NdRXNHey48WIbSko5cAOy7aOTpICDj4AYPCQrW481myDVv1SYRNCSEjHy8liace1s7qbgWF+jfiKgwVFXnAx6Jw5u0jm1KdS3zsK04Ugbpyqj/ZX6VFJyvS0sYdLPymi9Ixl0tuc8G0WrVwhzlkZ7UUQgHXlEEzrLsNDBZ7SYwHQ0cgAqlt67neIsLyvC8SKCZovHyIb+ufvARCCckMitqn5Sey7gj6YVAkDrcp2uox9u+t4CRxJfza4BFHa39St85HLE0nHe6MZJS3EI92T5UwscYXtsW9eoL/CV5e9aMH9epyUtnrmWk9J8nuvo4Ez2bbhM9cY6ofK2WWlzgjDQxfV0r2i24RR9YaUBwtS1smUFDeZjzn4VxOYMG9PC3V77jN064Fy+xraHsRDhnySfj30j7lo4+/IdJaQ7iUWUytNQycx2dpYLPDJ5tuWzNoKNZncZ8Hm7u+dkRitx+9MFTVYMQ7IArhsEjHEDf0JPmdp59ISw7LtDWc5MO2ync5sBanH4oOs6NQofLL7gOACx6YqRZe5WM3HqIoxnwX84Q4Mu1g6pFatHHSA5Su9X63J9REYD/61814jgTaO4ZM8CrWHIUucvILMyQ1h5pdtQ0x4EkJ7JVBHXkoUM++F8ZYLwOsrxU4ezsapYFNZghXqvdhyYvEghdnGwOWHS4pxB/bJVONpqDPbcQ1nNxeHmSdGq8DeFJKuuw+1nKBpBRkc4Ejy8yz0tteGfWNp1qAerQ0xp9nrrr3CeNBNCxvZT7WwJ/MbJuaniu3Zv 66VHXX4S ib75xF5Aw81v1myEFwNUADMWXFfMPhIpoUuaC2VACg1obLFZ3JHvHiJcLqhAVTt8tFPKxFi9cKRY/P80fRNuk0N+7NBTe6Q9X4ZYnx6A/fSuh3PIyfpazLM8K0UYTyEwx9s2rWeb6HXnklZlIOvX2G2zQb0g5qmY2Itv9blQXb4QJyQnN7Do9qVPCr3qugQb92wyPspTwsOXhxo5St51jmaZds/TAJuEA7juDHZD+XMwdLAyQ+WKP17MDmPurAVW2st1sfmBhNSIQbSAQzx1/rDPJhXD0tnBLNjma9sFo826BERQUH86Qk7f8TimLuw6VQzIT X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Fix following warnings: - Remove unused variables - Use __attribute__(unused) with unused variables which aren't being used and cannot be removed because of function pointer declaration - Fix type mismatches Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/cow.c | 46 +++++++++++++++++++------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c index ea00c85c76caa..e37eb863e66cd 100644 --- a/tools/testing/selftests/mm/cow.c +++ b/tools/testing/selftests/mm/cow.c @@ -84,7 +84,7 @@ static void detect_huge_zeropage(void) return; ret = pread(fd, buf, sizeof(buf), 0); - if (ret > 0 && ret < sizeof(buf)) { + if (ret > 0 && (unsigned int)ret < sizeof(buf)) { buf[ret] = 0; enabled = strtoul(buf, NULL, 10); @@ -263,12 +263,14 @@ static void do_test_cow_in_parent(char *mem, size_t size, bool do_mprotect, close_comm_pipes(&comm_pipes); } -static void test_cow_in_parent(char *mem, size_t size, bool is_hugetlb) +static void test_cow_in_parent(char *mem, size_t size, + bool __attribute__((unused)) is_hugetlb) { do_test_cow_in_parent(mem, size, false, child_memcmp_fn, false); } -static void test_cow_in_parent_mprotect(char *mem, size_t size, bool is_hugetlb) +static void test_cow_in_parent_mprotect(char *mem, size_t size, + bool __attribute__((unused)) is_hugetlb) { do_test_cow_in_parent(mem, size, true, child_memcmp_fn, false); } @@ -408,10 +410,11 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork) struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; struct io_uring ring; - ssize_t cur, total; struct iovec iov; char *buf, *tmp; + size_t total; int ret, fd; + ssize_t cur; FILE *file; ret = setup_comm_pipes(&comm_pipes); @@ -515,7 +518,7 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork) goto quit_child; } - if (cqe->res != size) { + if ((unsigned int) cqe->res != size) { ksft_test_result_fail("write_fixed failed\n"); goto quit_child; } @@ -529,7 +532,7 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork) ksft_test_result_fail("pread() failed\n"); goto quit_child; } - total += cur; + total += (size_t)cur; } /* Finally, check if we read what we expected. */ @@ -553,12 +556,14 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork) close_comm_pipes(&comm_pipes); } -static void test_iouring_ro(char *mem, size_t size, bool is_hugetlb) +static void test_iouring_ro(char *mem, size_t size, + bool __attribute__((unused)) is_hugetlb) { do_test_iouring(mem, size, false); } -static void test_iouring_fork(char *mem, size_t size, bool is_hugetlb) +static void test_iouring_fork(char *mem, size_t size, + bool __attribute__((unused)) is_hugetlb) { do_test_iouring(mem, size, true); } @@ -702,36 +707,38 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test, free(tmp); } -static void test_ro_pin_on_shared(char *mem, size_t size, bool is_hugetlb) +static void test_ro_pin_on_shared(char *mem, size_t size, + bool __attribute__((unused)) is_hugetlb) { do_test_ro_pin(mem, size, RO_PIN_TEST_SHARED, false); } -static void test_ro_fast_pin_on_shared(char *mem, size_t size, bool is_hugetlb) +static void test_ro_fast_pin_on_shared(char *mem, size_t size, + bool __attribute__((unused)) is_hugetlb) { do_test_ro_pin(mem, size, RO_PIN_TEST_SHARED, true); } static void test_ro_pin_on_ro_previously_shared(char *mem, size_t size, - bool is_hugetlb) + bool __attribute__((unused)) is_hugetlb) { do_test_ro_pin(mem, size, RO_PIN_TEST_PREVIOUSLY_SHARED, false); } static void test_ro_fast_pin_on_ro_previously_shared(char *mem, size_t size, - bool is_hugetlb) + bool __attribute__((unused)) is_hugetlb) { do_test_ro_pin(mem, size, RO_PIN_TEST_PREVIOUSLY_SHARED, true); } static void test_ro_pin_on_ro_exclusive(char *mem, size_t size, - bool is_hugetlb) + bool __attribute__((unused)) is_hugetlb) { do_test_ro_pin(mem, size, RO_PIN_TEST_RO_EXCLUSIVE, false); } static void test_ro_fast_pin_on_ro_exclusive(char *mem, size_t size, - bool is_hugetlb) + bool __attribute__((unused)) is_hugetlb) { do_test_ro_pin(mem, size, RO_PIN_TEST_RO_EXCLUSIVE, true); } @@ -1192,7 +1199,7 @@ static void run_anon_test_case(struct test_case const *test_case) static void run_anon_test_cases(void) { - int i; + unsigned int i; ksft_print_msg("[INFO] Anonymous memory tests in private mappings\n"); @@ -1420,7 +1427,7 @@ static const struct test_case anon_thp_test_cases[] = { static void run_anon_thp_test_cases(void) { - int i; + unsigned int i; if (!pmdsize) return; @@ -1457,13 +1464,14 @@ static void test_cow(char *mem, const char *smem, size_t size) "Other mapping not modified\n"); free(old); } +//typedef void (*non_anon_test_fn)(char *mem, const char *smem, size_t size); -static void test_ro_pin(char *mem, const char *smem, size_t size) +static void test_ro_pin(char *mem, const char __attribute__((unused)) *smem, size_t size) { do_test_ro_pin(mem, size, RO_PIN_TEST, false); } -static void test_ro_fast_pin(char *mem, const char *smem, size_t size) +static void test_ro_fast_pin(char *mem, const char __attribute__((unused)) *smem, size_t size) { do_test_ro_pin(mem, size, RO_PIN_TEST, true); } @@ -1752,7 +1760,7 @@ static void run_non_anon_test_case(struct non_anon_test_case const *test_case) static void run_non_anon_test_cases(void) { - int i; + unsigned int i; ksft_print_msg("[RUN] Non-anonymous memory tests in private mappings\n");