From patchwork Thu Dec 5 02:57:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13894685 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 D1FDBE7716D for ; Thu, 5 Dec 2024 02:57:22 +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=vRPxK+TDbgd+WnjJz5FYIJPml/xFGCCVEYOQwqjjOv8=; b=jTVBsum2xjbPPG WHW7XF6sXP8bEp2DO85SAu4xsyOg8+MfzET8sseLyT8MLJfa82dxQWFOp5NZ8iUaB+jKLzy/BUvWz coghJjsQJkYkvf+trsdloVjlnhakHeR3FhbbKFfDPrOtMnH4XGKglQcifEWYp7wfuHfSojdX5DEam ZHp9C8M4kRJttINQmP/Kg7kdzPTT5jtciHIdSeW8Ly67RTGvp5YrNTw/sNNosAz9AJWDPx70W/YR/ sRs/QJAZpUh0uSs7mt85kGVuFoifs9SOdEIDN6eZkebfMuo2eZ+BcovQgvqx1UHjutqY95xCpQKKE +5Q+sRxcZkUsFoaNpX6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJ23J-0000000Ebqx-3FjE; Thu, 05 Dec 2024 02:57:17 +0000 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJ23G-0000000EbqM-24qO for linux-riscv@lists.infradead.org; Thu, 05 Dec 2024 02:57:15 +0000 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-5f203157278so249082eaf.0 for ; Wed, 04 Dec 2024 18:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1733367433; x=1733972233; 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=ipBWW2dnxGgAKU4Po5grW4q1klpnbh+IbcwsuY+B1d4=; b=ezOSpgFReD2d2dG/hf5kz9+UB9E2nVjzYHtzp90vPuVMIx/rP5SATm/0ePBmyGWn5K //mdQqxYH+o6zSDMGFbp+QcI50lUKBf17MguG0PBNbj1AUuqOWdivxo3lLnfRW3jmTo8 xhH3stHhpYCMtApa6wc8Jyk65WsJGDZW4bgjM/qlevYsvrCMMTf179M9gvoSCqa1icjX K2zHHQWjwdwrvO+u67odtbCXq84bnCxheHkocP0cjXOCXa0sOOFpUBM1ESfd5SW0feqs IWWCwdaZB/jeT0Be/hm0IoQvF4D9RYmGA1U11mPs1vV7QnAqpnOslMsKhREDdQA1Ai3T 1xeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733367433; x=1733972233; 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=ipBWW2dnxGgAKU4Po5grW4q1klpnbh+IbcwsuY+B1d4=; b=Do9+kfc7qrFi5w8mQ4u975dGQXDNMUgFv3Ns68j0npRnEJ2Dx4hShYILsgxhCr7w/f x/Pha0jEJk8Bgs0VKKak0Ccg2GD3ACTkBfK/1cM9xHK++9iHdIjqwG04PLoJnVC0A5Jo 25+EwKSo8StGNpbs0K2TXczUc/j6Gfg+L7RP2/3uRJfV1aZz5JVbfBivWoJUyT1KdEuo qtsNKewnX8X6ngHFCVjhATNFlWKYkE/tD3x0Nry/aMHzVs8YnyJSn2DAORa2qKQm/P6V xtfaMiRmjp6OsChTABx9Pa1s3BWSPH7hTDIKAGD/c8H/yuC/vnJxFq+onhvEIwfLm5tW ogSQ== X-Forwarded-Encrypted: i=1; AJvYcCVOZnEP+e0hb2ACq7x772Z6isHs9IJ3it2eTRihfjZxyVbuRmMBrHOkh7ROjXwmGyUUirq+8VqloJVXVw==@lists.infradead.org X-Gm-Message-State: AOJu0YzGCyveRHi0B7VkRRStKRp0WY1JhkX/7elxhrA6mVWWfYvVp6xJ sLj7m5XgKby+9TP+bSYQACQ/b7s3iJMX9kBW8BWhbFDD4En7/W2DkjSfwIKRy8Q= X-Gm-Gg: ASbGnctxUcdA1bQr8TnKvZ3GbHHLb+3s7/PlGhaglTewRRzKyzbQiPBr/LTbTg0jqWn +zUVBC8mMWhlWDjjxdMmToz22UqAovuSFITf/KdnkmW9aXPL6uoOk5h5xy6Xb1LpA6khkgjjJ/C ZjOzbewz/luvObapnLt30RbsEd0OO8k2btWGlAXsW1oLxStkOq5d8tQm50p+DReL93ip1TZtGJE xqi561PRK3h6670UvdBqe0AeswqFFpLfp2YLCoAJcqG9Pk2+hQgHiEZ5Otsa9q8kQ== X-Google-Smtp-Source: AGHT+IFEHWkyCS6LHG+yi34gQLK5jMcjxCLqzFDhxH1oJQf1pgNGxOZbslnPeagR+v0TgGJ8kNbHbQ== X-Received: by 2002:a05:6830:6016:b0:718:9d30:3c5a with SMTP id 46e09a7af769-71dad5edda4mr11520783a34.2.1733367432913; Wed, 04 Dec 2024 18:57:12 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd1568f26asm269581a12.9.2024.12.04.18.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 18:57:12 -0800 (PST) From: Charlie Jenkins Date: Wed, 04 Dec 2024 18:57:10 -0800 Subject: [PATCH v2] riscv: selftests: Fix warnings pointer masking test MIME-Version: 1.0 Message-Id: <20241204-fix_warnings_pointer_masking_tests-v2-1-1bf0c5095f58@rivosinc.com> X-B4-Tracking: v=1; b=H4sIAIYWUWcC/5WNQQ6CMBBFr0K6toaWguLKexjSNHWAiaElM03VE O5u9QYu30v++5tgIAQWl2oTBBkZYyigD5XwswsTSLwXFrrWRunayBFf9ukoYJjYrhFDArKL40c RNgEnls25q8GMTWt0L0poJSir38ltKDwjp0jv32dWX/tXPiupJDgFfde1Hk7uSpgjY/BHHxcx7 Pv+Afx+3AbXAAAA 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=2606; i=charlie@rivosinc.com; h=from:subject:message-id; bh=0kdYtWwDnP1BFgEDmuauQ4kRcQgJT5fkZ+DZ/JMhTyA=; b=owGbwMvMwCHWx5hUnlvL8Y3xtFoSQ3qgWLsNj3bsWpZHUWmFDRf+m6jKrLVaPXf1Re3UfeFvX Bl0nzh0lLIwiHEwyIopsvBca2BuvaNfdlS0bALMHFYmkCEMXJwCMJGeckaGy5E31Z6ZyXT2rDnV soktz/XWx30OxXv/KUQ/5P53Y87MDIZ/Gv4nj0isVhPeJ/664rZD2799yYbFnE81f2c6z9NKvqb DBQA= 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_185714_535991_CE57E903 X-CRM114-Status: UNSURE ( 9.98 ) 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 --- Changes in v2: - I had ret != 2 for testing, I changed it to be ret != 1. - Link to v1: https://lore.kernel.org/r/20241204-fix_warnings_pointer_masking_tests-v1-1-ea1e9665ce7a@rivosinc.com --- 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..229d85ccff50 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 != 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"); set_tagged_addr_ctrl(0, false);