File tree 2 files changed +9
-5
lines changed
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -1898,14 +1898,14 @@ pub unsafe extern "C-unwind" fn gzgetc(file: gzFile) -> c_int {
1898
1898
// `state.next + 1` is within the bounds of the `state.output` buffer, as required
1899
1899
// by the pointer `add` method.
1900
1900
state. next = unsafe { state. next . add ( 1 ) } ;
1901
- return ret as _ ;
1901
+ return c_int :: from ( ret) ;
1902
1902
}
1903
1903
1904
1904
// Nothing there -- try gz_read.
1905
- let mut buf = [ 0u8 ; 1 ] ;
1906
- // Safety: `buf ` is big enough to hold `len = 1` bytes.
1907
- match unsafe { gz_read ( state, buf . as_mut_ptr ( ) , 1 ) } {
1908
- 1 => buf [ 0 ] as _ ,
1905
+ let mut c = 0u8 ;
1906
+ // Safety: `c ` is big enough to hold `len = 1` bytes.
1907
+ match unsafe { gz_read ( state, core :: slice :: from_mut ( & mut c ) . as_mut_ptr ( ) , 1 ) } {
1908
+ 1 => c_int :: from ( c ) ,
1909
1909
_ => -1 ,
1910
1910
}
1911
1911
}
Original file line number Diff line number Diff line change @@ -1026,6 +1026,8 @@ fn gzputs_error() {
1026
1026
fn gzgetc_basic ( ) {
1027
1027
// Read data from a gzip file one byte at a time using gzgetc, and verify that
1028
1028
// the expected content is returned.
1029
+ // FIXME: Replace these closures with simple function pointers once the project MSRV
1030
+ // includes a fix for https://github.com/rust-lang/rust/issues/140293
1029
1031
for gzgetc_fn in [ |x| unsafe { gzgetc ( x) } , |x| unsafe { gzgetc_ ( x) } ] {
1030
1032
let file_name = crate_path ( "src/test-data/text.gz" ) ;
1031
1033
let file = unsafe {
@@ -1053,6 +1055,8 @@ fn gzgetc_basic() {
1053
1055
1054
1056
#[ test]
1055
1057
fn gzgetc_error ( ) {
1058
+ // FIXME: Replace these closures with simple function pointers once the project MSRV
1059
+ // includes a fix for https://github.com/rust-lang/rust/issues/140293
1056
1060
for gzgetc_fn in [ |x| unsafe { gzgetc ( x) } , |x| unsafe { gzgetc_ ( x) } ] {
1057
1061
// gzgetc on a null file handle should return -1.
1058
1062
assert_eq ! ( gzgetc_fn( ptr:: null_mut( ) ) , -1 ) ;
You can’t perform that action at this time.
0 commit comments