-
Notifications
You must be signed in to change notification settings - Fork 256
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
aya: MapData::fd is non-optional #758
Conversation
✅ Deploy Preview for aya-rs-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hey @alessandrod, this pull request changes the Aya Public API and requires your review. |
097e40d
to
059270a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable, but is this change motivated as part of some other effort? I get the ways in which this is better. I suppose before it was possible to defer the actual creation of the map from the setup and it's not now, but I'm unsure as to why somebody might have wanted to do that.
I noticed the oddity during review of another PR and decided to fix it. In particular this makes life better when we later replace the RawFd with an OwnedFd (notice we are no longer passing a "42" file descriptor in tests)
Indeed. Unclear why anyone would want such deferral. |
aya/src/maps/array/array.rs
Outdated
@@ -39,7 +39,7 @@ impl<T: Borrow<MapData>, V: Pod> Array<T, V> { | |||
let data = map.borrow(); | |||
check_kv_size::<u32, V>(data)?; | |||
|
|||
let _fd = data.fd_or_err()?; | |||
let _fd = data.fd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can go now? We used to get the fd to ensure that the map was created, but
now it's always created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks for catching that.
aya/src/maps/array/per_cpu_array.rs
Outdated
@@ -58,7 +58,7 @@ impl<T: Borrow<MapData>, V: Pod> PerCpuArray<T, V> { | |||
let data = map.borrow(); | |||
check_kv_size::<u32, V>(data)?; | |||
|
|||
let _fd = data.fd_or_err()?; | |||
let _fd = data.fd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here (and everywhere else)
059270a
to
712eb66
Compare
aya/src/maps/mod.rs
Outdated
pinned: false, | ||
}), | ||
Err(_) => { | ||
let mut map = Self::create(obj, name, None)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is btf_fd hardcoded to None here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
Done.
a352537
to
d749634
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for doing this, see comments
The primary driver of change here is that `MapData::create` is now a factory function that returns `Result<Self, _>` rather than mutating `&mut self`. The remaining changes are consequences of that change, the most notable of which is the removal of several errors which are no longer possible.
This is consistent with all the other maps.
d749634
to
a31544b
Compare
I've addressed all the comments, PTAL. |
context for posterity https://discord.com/channels/855676609003651072/855676609003651075/1141557678955577445 |
The primary driver of change here is that
MapData::create
is now afactory function that returns
Result<Self, _>
rather than mutating&mut self
. The remaining changes are consequences of that change, themost notable of which is the removal of several errors which are no
longer possible.