Skip to content

Commit 3c24542

Browse files
committed
fix wasmtime error
wasmtime does not like the use of function pointers somehow?
1 parent 6b2795b commit 3c24542

File tree

1 file changed

+7
-7
lines changed
  • test-libz-rs-sys/src

1 file changed

+7
-7
lines changed

test-libz-rs-sys/src/gz.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ fn gzputs_error() {
10261026
fn gzgetc_basic() {
10271027
// Read data from a gzip file one byte at a time using gzgetc, and verify that
10281028
// the expected content is returned.
1029-
for gzgetc_fn in [gzgetc, gzgetc_] {
1029+
for gzgetc_fn in [|x| unsafe { gzgetc(x) }, |x| unsafe { gzgetc_(x) }] {
10301030
let file_name = crate_path("src/test-data/text.gz");
10311031
let file = unsafe {
10321032
gzopen(
@@ -1040,31 +1040,31 @@ fn gzgetc_basic() {
10401040
let mut content = String::with_capacity(EXPECTED.len());
10411041
for _ in 0..EXPECTED.len() {
10421042
// Safety: `file` was initialized by `gzopen`.
1043-
let ch = unsafe { gzgetc_fn(file) };
1043+
let ch = gzgetc_fn(file);
10441044
assert_ne!(ch, -1);
10451045
content.push(ch as u8 as char);
10461046
}
10471047
// We should be at the end, so the next gzgetc should return -1.
1048-
assert_eq!(unsafe { gzgetc_fn(file) }, -1);
1048+
assert_eq!(gzgetc_fn(file), -1);
10491049
assert_eq!(unsafe { gzclose(file) }, Z_OK);
10501050
assert_eq!(content.as_str(), EXPECTED);
10511051
}
10521052
}
10531053

10541054
#[test]
10551055
fn gzgetc_error() {
1056-
for gzgetc_fn in [gzgetc, gzgetc_] {
1056+
for gzgetc_fn in [|x| unsafe { gzgetc(x) }, |x| unsafe { gzgetc_(x) }] {
10571057
// gzgetc on a null file handle should return -1.
1058-
assert_eq!(unsafe { gzgetc_fn(ptr::null_mut()) }, -1);
1058+
assert_eq!(gzgetc_fn(ptr::null_mut()), -1);
10591059

10601060
// gzgetc on a write-only file handle should return -1.
10611061
let file = unsafe { gzdopen(-2, CString::new("w").unwrap().as_ptr()) };
1062-
assert_eq!(unsafe { gzgetc_fn(file) }, -1);
1062+
assert_eq!(gzgetc_fn(file), -1);
10631063
assert_eq!(unsafe { gzclose(file) }, Z_ERRNO);
10641064

10651065
// Open an invalid file descriptor as a gzip read stream. gzgetc should return -1.
10661066
let file = unsafe { gzdopen(-2, CString::new("r").unwrap().as_ptr()) };
1067-
assert_eq!(unsafe { gzgetc_fn(file) }, -1);
1067+
assert_eq!(gzgetc_fn(file), -1);
10681068
assert_eq!(unsafe { gzclose(file) }, Z_ERRNO);
10691069
}
10701070
}

0 commit comments

Comments
 (0)