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

std(in|out|err) methods can create multiple mutable references to the same object #239

Closed
toku-sa-n opened this issue Jun 11, 2021 · 1 comment · Fixed by #240
Closed

Comments

@toku-sa-n
Copy link
Member

pub fn stdin(&self) -> &mut text::Input {
unsafe { &mut *self.table.stdin }
}
/// Returns the standard output protocol.
pub fn stdout(&self) -> &mut text::Output {
let stdout_ptr = self.table.stdout as *const _ as *mut _;
unsafe { &mut *stdout_ptr }
}
/// Returns the standard error protocol.
pub fn stderr(&self) -> &mut text::Output {
let stderr_ptr = self.table.stderr as *const _ as *mut _;
unsafe { &mut *stderr_ptr }
}

I tried to change &self to &mut self, but it was difficult to fix the test codes.

pub fn test(st: &SystemTable<Boot>) {
info!("Testing various protocols");
let bt = st.boot_services();
find_protocol(bt);
console::test(st);
debug::test(bt);
media::test(bt);
pi::test(bt);
shim::test(bt);
}

Here, boot_services() takes an immutable reference to SystemTable while console::test has to take a mutable reference to SystemTable. This causes the conflict of the mutability of references.

@GabrielMajeri
Copy link
Collaborator

@toku-sa-n I've opened #240 to attempt to fix this. Does it provide a reasonable solution to prevent multiple mutable references?

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 a pull request may close this issue.

2 participants