[PATCH 2/2] rust: drm: fix non-const `read8` in unit test

Gary Guo <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,dev.linux.lists.driver-core,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
From: Gary Guo <[email protected]>

With CONFIG_CC_OPTIMIZE_FOR_SIZE, the address validity check in non-const
`read8` invocaction is not optimized away, leading to build failure.

Signed-off-by: Gary Guo <[email protected]>
---
 rust/kernel/drm/gem/shmem.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs
index 580e0808d6c0..a687d46d170d 100644
--- a/rust/kernel/drm/gem/shmem.rs
+++ b/rust/kernel/drm/gem/shmem.rs
@@ -688,7 +688,7 @@ fn vmap_io() -> Result {
         // Ensure the ordering in memory is correct
         let expected = 0xFEDCBA98_u32.to_ne_bytes().into_iter();
         for (offset, expected) in (0x20..=0x23).zip(expected) {
-            assert_eq!(vmap.read8(offset), expected);
+            assert_eq!(vmap.try_read8(offset).unwrap(), expected);
         }
 
         Ok(())
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.