Skip to content

Conversation

@kloenk
Copy link
Member

@kloenk kloenk commented Jul 23, 2021

This will be used for network drivers. (#439)

@kloenk kloenk added the • lib Related to the `rust/` library. label Jul 23, 2021
@ojeda
Copy link
Member

ojeda commented Jul 23, 2021

Perhaps we should add all the ones from include/uapi/asm-generic/errno.h.

@kloenk
Copy link
Member Author

kloenk commented Jul 24, 2021

Perhaps we should add all the ones from include/uapi/asm-generic/errno.h.

That would probably be a good idea. But doing it from hand is not the best work to do :-).

Maybe we can build some Marco to do it?

@kloenk kloenk requested a review from ojeda July 25, 2021 08:26
@kloenk
Copy link
Member Author

kloenk commented Aug 20, 2021

What about a short macro to make it easier, eg that you have to write it like this to declare ENOEXEC:

/// Exec format error.
declare_err!(ENOEXEC);

@bjorn3
Copy link
Member

bjorn3 commented Aug 20, 2021

I think the doc comment will need to be inside the macro invocation for this to work.

@kloenk
Copy link
Member Author

kloenk commented Aug 20, 2021

really? if the macro just expands to pub const ENOEXEC: Self = Error(-(bindings::ENOEXEC as i32));?

@kloenk
Copy link
Member Author

kloenk commented Aug 20, 2021

I think I will just try it out

@kloenk
Copy link
Member Author

kloenk commented Aug 20, 2021

Yes, sadly you are right, I think it's still a bit easier to write declare_err!("Operation not permitted.", EPERM); instead of pub const EPERM: Self = Error(-(bindings::EPERM as i32));

This will be used for network drivers.

Signed-off-by: Finn Behrens <[email protected]>
@kloenk
Copy link
Member Author

kloenk commented Aug 20, 2021

rebased and moved to the macro, Will add missing errors now

This makes declaring an error a bit easier, as the specific error only has
to be written once. This also saves repetitive code.

Signed-off-by: Finn Behrens <[email protected]>
@kloenk
Copy link
Member Author

kloenk commented Aug 20, 2021

@ojeda I now included all errors from include/uapi/asm-generic/errno.h as requested.

@ojeda ojeda merged commit 9740bcb into Rust-for-Linux:rust Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

• lib Related to the `rust/` library.

Development

Successfully merging this pull request may close these issues.

3 participants