File tree Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -490,11 +490,18 @@ jobs:
490490 RUSTFLAGS : " -Ctarget-feature=+avx2,+bmi2,+bmi1"
491491 - name : Test allocator with miri
492492 run : " cargo +nightly miri nextest run -j4 -p zlib-rs --target ${{ matrix.target }} allocate::"
493- - name : Test gz logic with miri
493+ - name : Test allocator with miri
494+ run : " cargo +nightly miri nextest run -j4 -p zlib-rs --target ${{ matrix.target }} allocate::"
495+ - name : Test gz internals with miri
494496 working-directory : libz-rs-sys-cdylib
495497 run : " cargo +nightly miri nextest run -j4 -p libz-rs-sys-cdylib --target ${{ matrix.target }} --features=gz"
496498 env :
497499 MIRIFLAGS : " -Zmiri-tree-borrows -Zmiri-disable-isolation"
500+ - name : Test gz api with miri
501+ if : ${{ contains(matrix.target, 'linux') }}
502+ run : " cargo +nightly miri nextest run -j4 -p test-libz-rs-sys --target ${{ matrix.target }} gz::"
503+ env :
504+ MIRIFLAGS : " -Zmiri-disable-isolation"
498505
499506 miri-avx512 :
500507 name : " Miri avx512"
Original file line number Diff line number Diff line change @@ -1809,29 +1809,27 @@ fn gz_init(state: &mut GzState) -> Result<(), ()> {
18091809}
18101810
18111811#[ cfg( not( miri) ) ]
1812- unsafe fn write ( fd : c_int , buf : * const c_void , count : size_t ) -> libc:: ssize_t {
1813- unsafe { libc:: write ( fd, buf, count) }
1814- }
1812+ use libc:: write;
18151813
18161814/// Deal with miri often not writing the full buffer in one go. That is valid, but zlib assumes
18171815/// that writes are to true files and succeed unless e.g. the disk is full.
18181816#[ cfg( miri) ]
18191817unsafe fn write ( fd : c_int , buf : * const c_void , count : size_t ) -> libc:: ssize_t {
1820- let mut total_written = 0isize ;
1818+ let mut total_written: libc :: ssize_t = 0 ;
18211819 loop {
18221820 let ret = unsafe {
18231821 libc:: write (
18241822 fd,
18251823 buf. add ( total_written as usize ) ,
1826- count - total_written as usize ,
1824+ ( count - total_written as size_t ) as _ ,
18271825 )
18281826 } ;
18291827
18301828 match ret. cmp ( & 0 ) {
1831- Ordering :: Less => return ret,
1829+ Ordering :: Less => return ret as libc :: ssize_t ,
18321830 Ordering :: Equal => return total_written,
18331831 Ordering :: Greater => {
1834- total_written += ret;
1832+ total_written += ret as libc :: ssize_t ;
18351833
18361834 if total_written as usize == count {
18371835 break ;
Original file line number Diff line number Diff line change @@ -36,31 +36,29 @@ fn binary_mode(mode: c_int) -> c_int {
3636}
3737
3838#[ cfg( not( miri) ) ]
39- unsafe fn write ( fd : c_int , buf : * const c_void , count : size_t ) -> libc:: ssize_t {
40- unsafe { libc:: write ( fd, buf, count) }
41- }
39+ use libc:: write;
4240
4341/// Deal with miri often not writing the full buffer in one go. That is valid, but zlib assumes
4442/// that writes are to true files and succeed unless e.g. the disk is full.
4543#[ cfg( miri) ]
4644unsafe fn write ( fd : c_int , buf : * const c_void , count : size_t ) -> libc:: ssize_t {
4745 use std:: cmp:: Ordering ;
4846
49- let mut total_written = 0isize ;
47+ let mut total_written: libc :: ssize_t = 0 ;
5048 loop {
5149 let ret = unsafe {
5250 libc:: write (
5351 fd,
5452 buf. add ( total_written as usize ) ,
55- count - total_written as usize ,
53+ ( count - total_written as size_t ) as _ ,
5654 )
5755 } ;
5856
5957 match ret. cmp ( & 0 ) {
60- Ordering :: Less => return ret,
58+ Ordering :: Less => return ret as libc :: ssize_t ,
6159 Ordering :: Equal => return total_written,
6260 Ordering :: Greater => {
63- total_written += ret;
61+ total_written += ret as libc :: ssize_t ;
6462
6563 if total_written as usize == count {
6664 break ;
You can’t perform that action at this time.
0 commit comments