-
Notifications
You must be signed in to change notification settings - Fork 13
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
[closes #426] Apply AsBytes+FromBytes #466
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
#[derive(Copy, Clone)] | ||
#[repr(C)] | ||
use zerocopy::{AsBytes, FromBytes}; | ||
|
||
#[derive(Copy, Clone, AsBytes, FromBytes)] | ||
// repr(packed) is required for AsBytes. | ||
// https://docs.rs/zerocopy/0.3.0/zerocopy/trait.AsBytes.html | ||
#[repr(packed)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추가로, struct에서 padding에 해당하는 부분을 읽는 것이 Rust에서 UB인지 unspecified behavior인지 확인해 보는 것이 좋을 것 같습니다.
(https://doc.rust-lang.org/reference/behavior-considered-undefined.html)
(C18 Spec: Unspecified behavior) Rust reference의 설명을 봐도 그렇고, C에서 unspecified인 것을 봐도 그렇고 아마 UB는 아닌 것 같습니다만, 정확히 아시는 분이 계시면 좋을 것 같네요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rust-lang/unsafe-code-guidelines#174 확실하지는 않지만 아마 괜찮을 것 같습니다 |
||
pub struct Stat { | ||
/// File system's disk device | ||
pub dev: i32, | ||
|
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.
FromBytes
는 없어도 되지 않나요? (UserMemory::copy_out
도 마찬가지)