From patchwork Thu Dec 5 02:53:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13894684 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8EABE7716D for ; Thu, 5 Dec 2024 02:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=N2pmZkSnYxKDvMfNeZL4TWc7+p8GD+Ux4b5Z5/6KbF8=; b=lzZv2snyQ3bZH4 m3DZhw05CxgS0dCHufSdpIR8kIb4E0NMl+LgIQByqBQszEu3GOMTCRKDjiAivTnECG75TEIBAHTlE FGEKaz8AAcZnVR8u/xOQe0Jq3Zmr0wahlLc5NGYdfHNVsvezq9+EHBMIcyDhONIMG+TbssfD2O3BV 1B+p9zT0AYa5FkDIBAxgcYH/xG2tnju9qHboS/zPFHzPjXgy/KouBEw1anI2dkmGBv5IFRSNZQj9D V8wBLJwvl3oAjclcU1CpEQRdSxeedhX00RJJP9o4YF4Ao24hc6Z+ej0daThcsTX5IR+EoeWqqkEPH 7ddK58oJj70xhjOGYbww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJ1zq-0000000EbRF-3hsI; Thu, 05 Dec 2024 02:53:42 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJ1zo-0000000EbQc-2GVD for linux-riscv@lists.infradead.org; Thu, 05 Dec 2024 02:53:42 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-215b0582aaeso2914665ad.3 for ; Wed, 04 Dec 2024 18:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1733367219; x=1733972019; darn=lists.infradead.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=Y5i2W/fX0uIIT+J5MfXCDS794yT/hd4XA/lGS5kDrh8=; b=RUWU8WSE72xn/e3Pav8Dk7t1ePtMXmTJzecoIIk030VhJZZY7G2d+6TxlatTsuPZFa geyKgy8nCxzb1tMJK605414PVrD6mZ8zw2MAMf9Cpmxiq30XQrZJ0v8b1ZBn6VqeCVA5 dICM2dILtTl65cNXxxlth5cBEPgFTt7lsxORcjehioNewZqHWe7PrEj0+L9H+knpzrLA lQTy1aB9PxOpqSRvHP86KHG3X8xp92QeuiGSUibZBuTPMNu9RHVGUSX8uP/fWzOaVhBF nKMbp8ghp5WVrocMI/deYfvMrsJbeAHTJXR+dBSniiXHFgtIdJP3PMTFC2bkr9bj6vmd EdZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733367219; x=1733972019; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Y5i2W/fX0uIIT+J5MfXCDS794yT/hd4XA/lGS5kDrh8=; b=ds7G7W0DWK2AJi+UbySiUdY/97SKkZQIdZoX9ktmOdQ5FeVnlVkiGMyojwqcBOIHDp CPcPWjpqqnEeXpGAJYIBnY/urE/nyNJQstc8u3Zmit0uMM1xNhHeYImU/m/AUdcnYdYo s7GSusn12M00sWnhvQBAQclvj8CTdwz1xgqiWksMfl3VlWUZNcCGclB99SwnIWnNw+rL arNLSpuF1H/U1vbOVZwYJZCMlyNcBuMC1Rdb57G1rpE2swRethq1HqaCz+aacIMqK00P DzWLl9HLhzds4FE5A/xbsI7Tj+zexszrsrrQ3MMmdRR/c36ccvqEToNpLZ46WkspPeZm Vekg== X-Forwarded-Encrypted: i=1; AJvYcCUoz14oPVR8hAwlMZBO7qiJmBFMCDu5/il9WhTmqawHLyDIO35Jbs42P1noquX+Zo+4WSz/uveuOZrMgA==@lists.infradead.org X-Gm-Message-State: AOJu0YyaS4B/vc6nrQ9Kk3f0yzHbHclqb7nOV5yLygrhWRvj3gHeNecl RwkvatiFvRnsBaMSIVsryU6/ttjQSuD3LdaYRzzaNtsaXiaCE3i8b23I0tkj/OQ= X-Gm-Gg: ASbGncvtD2V//9UjzS2sXQhHj39s537FTkok2eLskLbYHeWQeBKVRhpPpEmyRjj52gz Lm8SpX58oJvtPixhqWaUBcWgbVigSSBJAsff4WtmrGATaAAaS92zKdadUAJQr7YqNKwfM5psisC wwmhxFeM/rF2dznqEb+mmxPh1omGK66m9vb1PE6ZU9GtlizPwnTrRZN8L0Szrerfr61/Lg0HuL2 6dO82dteAnJs53MPlRvC+W+9neV8jj3j/bghQlY7kxVWYo1/JhT/a2TBKlOFw1KKQ== X-Google-Smtp-Source: AGHT+IF0E05Cz0CNGSRzqNmt+I+ohBvI+aYOdKpP0GLbqUbjAZpdOYjCbypomo4HQRAuwyG/o5iD3A== X-Received: by 2002:a17:903:2442:b0:215:a98c:aabb with SMTP id d9443c01a7336-215bd0e66a5mr135859375ad.24.1733367219179; Wed, 04 Dec 2024 18:53:39 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8e62c36sm2468565ad.65.2024.12.04.18.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 18:53:38 -0800 (PST) From: Charlie Jenkins Date: Wed, 04 Dec 2024 18:53:28 -0800 Subject: [PATCH] riscv: selftests: Fix warnings pointer masking test MIME-Version: 1.0 Message-Id: <20241204-fix_warnings_pointer_masking_tests-v1-1-ea1e9665ce7a@rivosinc.com> X-B4-Tracking: v=1; b=H4sIAKcVUWcC/x2N0QrCMAxFf2Xk2ULXVVF/RaSULa1BzEZSVBj79 4U9ngvnnhUUhVDh3q0g+CWlmQ36UwfjK3NFR5MxBB9iH3x0hf7pl4WJq6ZlJm4o6ZP1bUNqqE3 dcL14jGU4x3ADO1oEzToij+e27SDGsaZ0AAAA To: Shuah Khan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Samuel Holland Cc: linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2409; i=charlie@rivosinc.com; h=from:subject:message-id; bh=h5pkF7WFsF6QKVOZr0OZCA6MCXRJdUGJ2thXdNkkSus=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ3qg6MoFCz3CMjK6WW9+Xj7vzKoNdvv6WxY//7S91L3LQ fve+dW6HaUsDGIcDLJiiiw81xqYW+/olx0VLZsAM4eVCWQIAxenAEyk3ozhf7klwyeXpJcfj+S0 X121KjA9Lpf1y9ZW3ZyL5p3/Tj6bas7IcEDHblf3zqw9WfE7GXaWXpL7s/DgNf7JpQ5ejlbvv31 7ywUA X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241204_185340_842799_6A106E09 X-CRM114-Status: UNSURE ( 8.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org When compiling the pointer masking tests with -Wall this warning is present: pointer_masking.c: In function ‘test_tagged_addr_abi_sysctl’: pointer_masking.c:203:9: warning: ignoring return value of ‘pwrite’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 203 | pwrite(fd, &value, 1, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~ pointer_masking.c:208:9: warning: ignoring return value of ‘pwrite’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 208 | pwrite(fd, &value, 1, 0); I came across this on riscv64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04). Fix this by checking that the number of bytes written equal the expected number of bytes written. Fixes: 7470b5afd150 ("riscv: selftests: Add a pointer masking test") Signed-off-by: Charlie Jenkins --- tools/testing/selftests/riscv/abi/pointer_masking.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) --- base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37 change-id: 20241204-fix_warnings_pointer_masking_tests-3860e4f35429 diff --git a/tools/testing/selftests/riscv/abi/pointer_masking.c b/tools/testing/selftests/riscv/abi/pointer_masking.c index dee41b7ee3e3..5ae941e9ac73 100644 --- a/tools/testing/selftests/riscv/abi/pointer_masking.c +++ b/tools/testing/selftests/riscv/abi/pointer_masking.c @@ -189,6 +189,7 @@ static void test_tagged_addr_abi_sysctl(void) { char value; int fd; + int ret; ksft_print_msg("Testing tagged address ABI sysctl\n"); @@ -200,14 +201,24 @@ static void test_tagged_addr_abi_sysctl(void) } value = '1'; - pwrite(fd, &value, 1, 0); + ret = pwrite(fd, &value, 1, 0); + if (ret != 1) { + ksft_test_result_fail("Write to /proc/sys/abi/tagged_addr_disabled failed.\n"); + return; + } + ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == -EINVAL, "sysctl disabled\n"); value = '0'; - pwrite(fd, &value, 1, 0); - ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == 0, - "sysctl enabled\n"); + ret = pwrite(fd, &value, 1, 0); + if (ret != 2) { + ksft_test_result_fail("Write to /proc/sys/abi/tagged_addr_disabled failed.\n"); + return; + } + + ksft_test_result(set_tagged_addr_ctrl(min_pmlen, true) == -EINVAL, + "sysctl disabled\n"); set_tagged_addr_ctrl(0, false);