Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/uu/yes/src/yes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,12 @@ fn args_into_buffer<'a>(
/// Assumes buf holds a single output line forged from the command line arguments, copies it
/// repeatedly until the buffer holds as many copies as it can under [`BUF_SIZE`].
fn prepare_buffer(buf: &mut Vec<u8>) {
if buf.len() * 2 > BUF_SIZE {
return;
}

assert!(!buf.is_empty());

let line_len = buf.len();
let target_size = line_len * (BUF_SIZE / line_len);
debug_assert!(
line_len > 0,
"buffer is not empty since we have default value y"
);
let target_size = line_len * (BUF_SIZE / line_len); // 0 if line_len is too large

while buf.len() < target_size {
let to_copy = std::cmp::min(target_size - buf.len(), buf.len());
Expand Down
Loading