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

Add ARef::into_raw #1044

Open
y86-dev opened this issue Dec 2, 2023 · 6 comments · May be fixed by #1056
Open

Add ARef::into_raw #1044

y86-dev opened this issue Dec 2, 2023 · 6 comments · May be fixed by #1056
Labels
good first issue Good for newcomers • lib Related to the `rust/` library.

Comments

@y86-dev
Copy link
Collaborator

y86-dev commented Dec 2, 2023

Add the function into_raw to ARef<T>, the function should:

  • consume the ARef<T> by value, but not run the destructor, so you need to mem::forget the ARef<T>.
  • return a NonNull<T> or a *mut T, figure out which one works better.
  • have an example and some documentation.

Also adjust instances where ARefs are manually forgotten to use this new function.


This requires submitting a proper patch to the LKML and the Rust for Linux mailing list. Please recall to test your changes, to use a proper title for the commit, to sign your commit under the Developer's Certificate of Origin and so on. Please see https://docs.kernel.org/process/submitting-patches.html and https://rust-for-linux.com/contributing for details.

Please take this issue only if you are new to the kernel development process and you would like to use it as a test to submit your first patch to the kernel.

@y86-dev y86-dev added • lib Related to the `rust/` library. good first issue Good for newcomers labels Dec 2, 2023
@Kartik1397
Copy link

I'll take this one.

@y86-dev
Copy link
Collaborator Author

y86-dev commented Dec 3, 2023

Sure!

Note that there currently are no instances of ARefs getting manually forgotten. I created this issue, while reviewing [PATCH 4/7] rust: file: add FileDescriptorReservation. So depending on which thing makes it first into upstream you will or won't have to adjust other stuff.

@Redhawk18
Copy link

I'll take this one.

Are you currently working on it?

@Kartik1397
Copy link

Yes @Redhawk18, I've the patch ready here, which I'm planning to submit in couple of days once I complete testing of changes in rust/kernel/net/filter.rs and rust/kernel/file.rs files.

@Kartik1397 Kartik1397 linked a pull request Jan 15, 2024 that will close this issue
@Kartik1397
Copy link

Hi @y86-dev, I've drafted a PR for initial review. Please take a look when you can.
I'll send the patch to the mailing list after that.

vincenzopalazzo added a commit to vincenzopalazzo/linux that referenced this issue Mar 24, 2024
Add the function `into_raw` to `ARef<T>`. This method
can be used to turn an `ARef` into a raw pointer.

Link: Rust-for-Linux#1044
Co-developed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Kartik Prajapati <kartikprajapati987@gmail.com>
vincenzopalazzo pushed a commit to vincenzopalazzo/linux that referenced this issue Mar 27, 2024
Add the function `into_raw` to `ARef<T>`. This method
can be used to turn an `ARef` into a raw pointer.

Link: Rust-for-Linux#1044
Co-developed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Kartik Prajapati <kartikprajapati987@gmail.com>
@vincenzopalazzo
Copy link

vincenzopalazzo pushed a commit to vincenzopalazzo/linux that referenced this issue May 30, 2024
Add the function `into_raw` to `ARef<T>`. This method
can be used to turn an `ARef` into a raw pointer.

Link: Rust-for-Linux#1044
Co-developed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Kartik Prajapati <kartikprajapati987@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers • lib Related to the `rust/` library.
Development

Successfully merging a pull request may close this issue.

4 participants