Open FuuuOverclocking opened 1 year ago
This commit caused the test to fail due to fn test_mmap_region_build_raw()
(vm_memory::mmap_unix::tests) as addr
is 0 in this test.
I'm wondering, is addr
being 0 a valid parameter? Since the addr
here is an HVA, it seems inappropriate to set it to 0. Instead, it could be set to, for example, 40960.
@FuuuOverclocking what is the reason for this PR? 8 bytes in the great scheme of things does not feel like a lot.
In Rust, using Option<NonNull<u8>>
is a common pattern when both Option
and pointer are needed.
@FuuuOverclocking Hello, I think this PR should also wrap MmapRegion::addr
in NonNull<_>
as well. Would you be interested in rebasing and making this change?
This seems reasonable to me, I don't think there's any use case in mapping in the zero page, and Option<NonNull<u8>>
is indeed the more rust-y approach.
I also agree with @epilys that if we do this, we should probably be consistent with it, and use NonNull<u8>
everywhere (but in this case, this probably will need a changelog entry).
Also, it currently seems like unittests are failing, could you look into that? :o
Summary of the PR
Updates the
raw_ptr
field inMmapRegionBuilder
(mmap_unix.rs) fromOption<*mut u8>
toOption<NonNull<u8>>
. This modification saves 8 bytes on x86-64 systems, for example.The public API and functionality remain unchanged.
Requirements
Before submitting your PR, please make sure you addressed the following requirements:
git commit -s
), and the commit message has max 60 characters for the summary and max 75 characters for each description line.unsafe
code is properly documented.