Skip to content

Commit

Permalink
fix: dont violate semver
Browse files Browse the repository at this point in the history
  • Loading branch information
nhtyy committed Jan 17, 2025
1 parent 7a30583 commit 207d139
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 1 addition & 4 deletions crates/zkvm/entrypoint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub struct ReadVecResult {
pub ptr: *mut u8,
pub len: usize,
pub capacity: usize,
pub failed: bool,
}

/// Read a buffer from the input stream.
Expand All @@ -76,7 +75,7 @@ pub extern "C" fn read_vec_raw() -> ReadVecResult {

// If the length is u32::MAX, then the input stream is exhausted.
if len == usize::MAX {
return ReadVecResult { ptr: std::ptr::null_mut(), len: 0, capacity: 0, failed: true };
return ReadVecResult { ptr: std::ptr::null_mut(), len: 0, capacity: 0 };
}

// Round up to multiple of 4 for whole-word alignment.
Expand Down Expand Up @@ -104,7 +103,6 @@ pub extern "C" fn read_vec_raw() -> ReadVecResult {
ptr: ptr as *mut u8,
len,
capacity,
failed: false,
}
} else if #[cfg(feature = "bump")] {
// Allocate a buffer of the required length that is 4 byte aligned.
Expand All @@ -123,7 +121,6 @@ pub extern "C" fn read_vec_raw() -> ReadVecResult {
ptr: ptr as *mut u8,
len,
capacity,
failed: false,
}
} else {
// An allocator must be selected.
Expand Down
8 changes: 4 additions & 4 deletions crates/zkvm/lib/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl Write for SyscallWriter {
/// ```
#[track_caller]
pub fn read_vec() -> Vec<u8> {
let ReadVecResult { ptr, len, capacity, failed } = unsafe { read_vec_raw() };
let ReadVecResult { ptr, len, capacity } = unsafe { read_vec_raw() };

if failed {
if ptr.is_null() {
panic!(
"Tried to read from the input stream, but it was empty @ {} \n
Was the correct data written into SP1Stdin?",
Expand All @@ -69,9 +69,9 @@ pub fn read_vec() -> Vec<u8> {
/// ```
#[track_caller]
pub fn read<T: DeserializeOwned>() -> T {
let ReadVecResult { ptr, len, capacity, failed } = unsafe { read_vec_raw() };
let ReadVecResult { ptr, len, capacity } = unsafe { read_vec_raw() };

if failed {
if ptr.is_null() {
panic!(
"Tried to read from the input stream, but it was empty @ {} \n
Was the correct data written into SP1Stdin?",
Expand Down
1 change: 0 additions & 1 deletion crates/zkvm/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,4 @@ pub struct ReadVecResult {
pub ptr: *mut u8,
pub len: usize,
pub capacity: usize,
pub failed: bool,
}

0 comments on commit 207d139

Please sign in to comment.