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

Fix up some mutability warts on datasec skeleton accessors #611

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libbpf-cargo/src/gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@ fn gen_skel_datasec_getters(
write!(
skel,
r#"
pub fn {name}(&mut self) -> &'_ {mutability} {struct_name} {{
pub fn {name}(&{mutability} self) -> &{mutability} {struct_name} {{
unsafe {{
std::mem::transmute::<*mut std::ffi::c_void, &'_ {mutability} {struct_name}>(
std::mem::transmute::<*mut std::ffi::c_void, &{mutability} {struct_name}>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it intentional that we transmute to *mut c_void for both mutabilities?

Copy link
Collaborator Author

@danielocfb danielocfb Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which commit you looked at/commented on, but in the end mutability would be just the empty string for the "shared" accessor. So yeah, it's intentional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I commented on commit #2 ("Use non-exclusive receiver for immutable datasec getters"), and it will later be replaced with {ptr_suffix}, never mind.

self.skel_config.map_mmap_ptr({idx}).unwrap()
)
}}
Expand Down