Skip to content

Commit

Permalink
Wrap return value of archive_write_data_block(3)
Browse files Browse the repository at this point in the history
archive_write_data_block(3) might depending on the version of libarchive
on success return 0 or the number of bytes written.
`archive_write_data_block` however always expects 0 on success.
See man:archive_write_data(3)
  • Loading branch information
cgzones committed Mar 20, 2023
1 parent 2c86cfa commit 31e277b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,13 @@ fn libarchive_copy_data(
}

archive_result(
ffi::archive_write_data_block(archive_writer, buffer, size, offset) as i32,
/* Might depending on the version of libarchive on success
* return 0 or the number of bytes written,
* see man:archive_write_data(3) */
match ffi::archive_write_data_block(archive_writer, buffer, size, offset) {
x if x >= 0 => 0,
x => i32::try_from(x).unwrap(),
},
archive_writer,
)?;
}
Expand Down

0 comments on commit 31e277b

Please sign in to comment.