forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 482
Closed
Labels
• libRelated to the `rust/` library.Related to the `rust/` library.
Description
Related: #324, #335.
Orthogonal: whether we need the safe version of these, see #283.
Thinking about the pub(crate) helpers that help us "parse" return values from C functions, I think we can also improve the names for all these helpers:
- They are not constructors, so
from_*does not fit too well (i.e. do not confuse with theErrorconstructors). _kernel_does not add information -- we are also the kernel! Nothing instead (or perhaps_c_or_bindings_) would be better. I think nothing is OK because these functions are internal torust/kernel/and will be relatively well-known, since they will be used by most abstractions, so smaller names are better.
We need names for at least 3 functions:
decode_ret_ptr() -> Result<*mut T>: Decodes the return value of C functions that return a pointer or an error value (i.e. the C side usesIS_ERR()/ERR_PTR()etc.).decode_ret() -> Result: Decodes the return value of C functions that only return0on success, but otherwise do not use the positive side.decode_ret_value() -> Result<c_uint>: Decodes the return value of C functions that return a positive value on success.- Ideally we will specialize this one if some patterns repeat themselves, so that we can directly return the proper Rust-side type (e.g. the unsigned integer is a file descriptor which is then fed into a
File, so we could instead haveparse_result_fd()orparse_result_file()etc.).
- Ideally we will specialize this one if some patterns repeat themselves, so that we can directly return the proper Rust-side type (e.g. the unsigned integer is a file descriptor which is then fed into a
Possible prefixes:
parseinterprettransformto_resultdecode- ...
Possible middle nouns:
retresultreturnc_returncreturnretvalcretval- ...
Opinions, suggestions, etc. welcome!
Metadata
Metadata
Assignees
Labels
• libRelated to the `rust/` library.Related to the `rust/` library.