summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-01-09 14:09:22 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-09 14:34:35 +0100
commit55643507592c64b9d26d7bb0e6ee02118b46a446 (patch)
treec7c90326ceb82552370d2220d7da099ff9813ae8
parent39aa2d99250156bbcc14873af03e365c8024e9ef (diff)
ffi: Fix conversion to ffi_param_ref.
-rw-r--r--ffi/src/core.rs8
-rw-r--r--ffi/src/openpgp/fingerprint.rs4
-rw-r--r--ffi/src/openpgp/keyid.rs4
-rw-r--r--ffi/src/openpgp/mod.rs2
-rw-r--r--ffi/src/openpgp/tpk.rs4
5 files changed, 11 insertions, 11 deletions
diff --git a/ffi/src/core.rs b/ffi/src/core.rs
index b207bdb9..df4cf258 100644
--- a/ffi/src/core.rs
+++ b/ffi/src/core.rs
@@ -134,15 +134,15 @@ pub extern "system" fn sq_context_configure(domain: *const c_char)
/// Returns the domain of the context.
#[no_mangle]
pub extern "system" fn sq_context_domain(ctx: Option<&Context>) -> *const c_char {
- assert!(ctx.is_some());
- ctx.unwrap().c.domain().as_bytes().as_ptr() as *const c_char
+ let ctx = ffi_param_ref!(ctx);
+ ctx.c.domain().as_bytes().as_ptr() as *const c_char
}
/// Returns the directory containing shared state.
#[no_mangle]
pub extern "system" fn sq_context_home(ctx: Option<&Context>) -> *const c_char {
- assert!(ctx.is_some());
- ctx.unwrap().c.home().to_string_lossy().as_ptr() as *const c_char
+ let ctx = ffi_param_ref!(ctx);
+ ctx.c.home().to_string_lossy().as_ptr() as *const c_char
}
/// Returns the directory containing backend servers.
diff --git a/ffi/src/openpgp/fingerprint.rs b/ffi/src/openpgp/fingerprint.rs
index 5713b961..ee614bc4 100644
--- a/ffi/src/openpgp/fingerprint.rs
+++ b/ffi/src/openpgp/fingerprint.rs
@@ -109,7 +109,7 @@ pub extern "system" fn sq_fingerprint_to_keyid(fp: Option<&Fingerprint>)
pub extern "system" fn sq_fingerprint_equal(a: Option<&Fingerprint>,
b: Option<&Fingerprint>)
-> bool {
- let a = a.expect("Fingerprint 'a' is NULL");
- let b = b.expect("Fingerprint 'b' is NULL");
+ let a = ffi_param_ref!(a);
+ let b = ffi_param_ref!(b);
a == b
}
diff --git a/ffi/src/openpgp/keyid.rs b/ffi/src/openpgp/keyid.rs
index 8b64d2f8..2a4e2ff6 100644
--- a/ffi/src/openpgp/keyid.rs
+++ b/ffi/src/openpgp/keyid.rs
@@ -98,7 +98,7 @@ pub extern "system" fn sq_keyid_to_hex(id: Option<&KeyID>)
pub extern "system" fn sq_keyid_equal(a: Option<&KeyID>,
b: Option<&KeyID>)
-> bool {
- let a = a.expect("KeyID 'a' is NULL");
- let b = b.expect("KeyID 'b' is NULL");
+ let a = ffi_param_ref!(a);
+ let b = ffi_param_ref!(b);
a == b
}
diff --git a/ffi/src/openpgp/mod.rs b/ffi/src/openpgp/mod.rs
index b3ae71fe..552eb799 100644
--- a/ffi/src/openpgp/mod.rs
+++ b/ffi/src/openpgp/mod.rs
@@ -895,7 +895,7 @@ pub extern "system" fn sq_packet_parser_buffer_unread_content<'a>
-> *const uint8_t {
let ctx = ffi_param_ref!(ctx);
let pp = ffi_param_ref!(pp);
- let len = len.expect("Length pointer is NULL");
+ let len = ffi_param_ref!(len);
let buf = fry!(ctx, pp.buffer_unread_content());
*len = buf.len();
buf.as_ptr()
diff --git a/ffi/src/openpgp/tpk.rs b/ffi/src/openpgp/tpk.rs
index 814bac99..424b7948 100644
--- a/ffi/src/openpgp/tpk.rs
+++ b/ffi/src/openpgp/tpk.rs
@@ -121,8 +121,8 @@ pub extern "system" fn sq_tpk_clone(tpk: Option<&TPK>)
pub extern "system" fn sq_tpk_equal(a: Option<&TPK>,
b: Option<&TPK>)
-> bool {
- let a = a.expect("TPK 'a' is NULL");
- let b = b.expect("TPK 'b' is NULL");
+ let a = ffi_param_ref!(a);
+ let b = ffi_param_ref!(b);
a == b
}