Skip to content

Conversation

@hulxv
Copy link
Contributor

@hulxv hulxv commented Dec 17, 2025

Related to #4725

@rustbot
Copy link
Collaborator

rustbot commented Dec 17, 2025

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Dec 17, 2025
@RalfJung
Copy link
Member

@hulxv please do not submit half a dozen PRs at once. That feels like a DoS attack.
I'll likely have feedback for the first PR that I won't want to repeat for later PRs.

@hulxv
Copy link
Contributor Author

hulxv commented Dec 17, 2025

@hulxv please do not submit half a dozen PRs at once. That feels like a DoS attack. I'll likely have feedback for the first PR that I won't want to repeat for later PRs.

oh sorry for that xD
I just finished the work and opened a PR for each file depends on your instruction

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comments to the other PR. :)

That's why it's better to wait after submitting the first PR in a series -- the same comments are likely to apply many times. I will not look at your remaining PRs until we finished these first two, to avoid having to repeat the same comments.

View changes since this review


#[path = "../../utils/libc.rs"]
mod libc_utils;
use libc_utils::{errno_check, errno_result, read_all_into_array, write_all_from_slice};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use libc_utils::{errno_check, errno_result, read_all_into_array, write_all_from_slice};
use libc_utils::*;

let data = b"abc";
write_all_from_slice(fds[0], data).unwrap();
let mut buf2: [u8; 5] = [0; 5];
let res = unsafe { libc::read(fds[1], buf2.as_mut_ptr().cast(), buf2.len() as libc::size_t) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to #4768, this should use helpers instead of directly invoking read.

let data = b"123";
write_all_from_slice(fds[1], data).unwrap();
let mut buf4: [u8; 5] = [0; 5];
let res = unsafe { libc::read(fds[0], buf4.as_mut_ptr().cast(), buf4.len() as libc::size_t) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another place that should use a helper.

// Reading the other end should return that data, then EOF.
let mut buf: [u8; 5] = [0; 5];
let res =
unsafe { libc_utils::read_all(fds[1], buf.as_mut_ptr().cast(), buf.len() as libc::size_t) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another helper candidate.

assert_eq!(&buf[0..3], "123".as_bytes());
assert_eq!(&buf[0..3], b"123");
let res =
unsafe { libc_utils::read_all(fds[1], buf.as_mut_ptr().cast(), buf.len() as libc::size_t) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And another one

let data = "12345".as_bytes().as_ptr();
let res = unsafe { libc_utils::write_all(fds[1], data as *const libc::c_void, 5) };
assert_eq!(res, 5);
let data = b"12345";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable seems to be used only once, please inline it. (Same everywhere else in this PR, and in your other PRs as well.)

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Dec 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: Waiting for the PR author to address review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants