Skip to content

Commit a8bf6ef

Browse files
committed
Rust: Set Error constructor private to the crate
Code outside of this crate should not construct Error directly Signed-off-by: Fox Chen <[email protected]>
1 parent a71bbd9 commit a8bf6ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust/kernel/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Error {
6464
///
6565
/// When `errno` given is invalid, a warning will be printed
6666
/// and the `errno` will be converted to `EINVAL`.
67-
pub fn from_kernel_errno(errno: c_types::c_int) -> Error {
67+
pub(crate) fn from_kernel_errno(errno: c_types::c_int) -> Error {
6868
if errno < -(bindings::MAX_ERRNO as i32) || errno >= 0 {
6969
crate::pr_warn!(
7070
"Creating Error with an invalid errno {}, convert \
@@ -84,7 +84,7 @@ impl Error {
8484
/// # Safety
8585
///
8686
/// `errno` must be within error code range (i.e. `>= -MAX_ERRNO && < 0`).
87-
pub unsafe fn from_kernel_errno_unchecked(errno: c_types::c_int) -> Error {
87+
pub(crate) unsafe fn from_kernel_errno_unchecked(errno: c_types::c_int) -> Error {
8888
// INVARIANT: the contract ensures the type invariant
8989
// will hold.
9090
Error(errno)

0 commit comments

Comments
 (0)