Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/std/os/uefi/protocol/file.zig: change io adapter fns to const ptr #23160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dotcarmen
Copy link
Contributor

The rest of the methods in this type expect a *const File, and the type definitions even specify *const File. It's also only possible to construct a *const File ie

const uefi = @import("std").uefi;
const fs = try boot_services.openProtocolSt(uefi.protocol.SimpleFileSystem, uefi.handle);
var vol: *const uefi.protocol.File = undefined;
try fs.openVolume(&vol).err();

where fs.openVolume expects a **const File. As such, calling vol.reader() results in a type error, since a *const File can't be downcasted to *File

@dotcarmen
Copy link
Contributor Author

tbh, the rest of the API could use some consistency 😅 for example BlockIo's methods use *BlockIo instead of *const BlockIo. I can follow-up this pr with additional corrections if desired

@linusg
Copy link
Collaborator

linusg commented Mar 10, 2025

The rest of the methods in this type expect a *const File

I believe all of these are incorrect - even though it's fine to treat self as a const pointer from the Zig compiler's perspective, this only works because the UEFI API function pointers are also (incorrectly) typed this way - they definitely get mutated in the underlying implementation (seek offset for instance). Being able to read and write from a *const File is nonsense, so I'd rather not paper over it like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants