summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-10-28 16:08:55 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-10-28 16:08:55 +0100
commit134e03ea2cbc9dc8772593c283f537c53f09fbbe (patch)
treebc8d632aca086d3da627076f0e2f9467fc745e48 /openpgp-ffi
parent2ae586d68eb8e01435ae5449473b46e19cc06e18 (diff)
openpgp-ffi: Fix returning pgp_tag_t.
- Force pgp_tag_t to have a defined size, and return integers of that size from the ffi glue. - This problem did only manifest itself when compiling with opt-level=1.
Diffstat (limited to 'openpgp-ffi')
-rw-r--r--openpgp-ffi/include/sequoia/openpgp/types.h4
-rw-r--r--openpgp-ffi/src/packet/mod.rs8
2 files changed, 8 insertions, 4 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp/types.h b/openpgp-ffi/include/sequoia/openpgp/types.h
index d1612a73..d7a8271e 100644
--- a/openpgp-ffi/include/sequoia/openpgp/types.h
+++ b/openpgp-ffi/include/sequoia/openpgp/types.h
@@ -286,6 +286,10 @@ typedef enum pgp_tag {
PGP_TAG_PRIVATE1 = 61,
PGP_TAG_PRIVATE2 = 62,
PGP_TAG_PRIVATE3 = 63,
+
+ /* Dummy value to make sure the enumeration has a defined size.
+ Do not use this value. */
+ PGP_TAG_FORCE_WIDTH = INT_MAX,
} pgp_tag_t;
/*/
diff --git a/openpgp-ffi/src/packet/mod.rs b/openpgp-ffi/src/packet/mod.rs
index d332da87..7bab6195 100644
--- a/openpgp-ffi/src/packet/mod.rs
+++ b/openpgp-ffi/src/packet/mod.rs
@@ -55,8 +55,8 @@ pub struct Packet(openpgp::Packet);
///
/// [Section 4.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-4.3
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
-fn pgp_packet_tag(p: *const Packet) -> u8 {
- u8::from(p.ref_raw().tag()) as u8
+fn pgp_packet_tag(p: *const Packet) -> u32 {
+ u8::from(p.ref_raw().tag()) as u32
}
/// Returns the parsed `Packet's` corresponding OpenPGP tag.
@@ -67,9 +67,9 @@ fn pgp_packet_tag(p: *const Packet) -> u8 {
/// into an `Packet::Unknown`. `tag()` returns `PGP_TAG_SIGNATURE`,
/// whereas `kind()` returns `0`.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
-fn pgp_packet_kind(p: *const Packet) -> u8 {
+fn pgp_packet_kind(p: *const Packet) -> u32 {
if let Some(kind) = p.ref_raw().kind() {
- kind.into()
+ u8::from(kind) as u32
} else {
0
}