Skip to content

Commit

Permalink
Silence older rustc warnings about usize in FFI declarations.
Browse files Browse the repository at this point in the history
Until Rust 1.4, rustc will warn when `usize` or `isize` is used in an
FFI declaration. This patch silences those warnings so that *ring* can
compile without warnings with rustc 1.3 (the current stable version).
This workaround will be reverted when Rust 1.4 is released.

The code doesn't actually trigger this warning yet, but the next commit
would have made it do so.
  • Loading branch information
briansmith committed Oct 23, 2015
1 parent d34b6ea commit a4dd459
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ type OpenOrSealFn =
ad: *const libc::uint8_t, ad_len: libc::size_t)
-> libc::c_int;

// XXX: As of Rust 1.4, the compiler will no longer warn about the use of
// `usize` and `isize` in FFI declarations. Remove the `allow(improper_ctypes)`
// when Rust 1.4 is released.
#[allow(improper_ctypes)]
extern {
fn evp_aead_aes_gcm_init(ctx_buf: *mut u64, ctx_buf_len: libc::size_t,
key: *const libc::uint8_t, key_len: libc::size_t)
Expand Down
5 changes: 5 additions & 0 deletions src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ macro_rules! impl_Digest {
// BoringSSL they are always guaranteed to return 1 according to the
// documentation in the header files, so we can safely ignore their
// return values.
//
// XXX: As of Rust 1.4, the compiler will no longer warn about the use
// of `usize` and `isize` in FFI declarations. Remove the
// `allow(improper_ctypes)` when Rust 1.4 is released.
#[allow(improper_ctypes)]
extern {
fn $xxx_Init(ctx_state: *mut u64) -> libc::c_int;
fn $xxx_Update(ctx_state: *mut u64, data: *const u8,
Expand Down
4 changes: 4 additions & 0 deletions src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ enum EC_GROUP { }
#[allow(non_camel_case_types)]
enum EC_KEY { }

// XXX: As of Rust 1.4, the compiler will no longer warn about the use of
// `usize` and `isize` in FFI declarations. Remove the `allow(improper_ctypes)`
// when Rust 1.4 is released.
#[allow(improper_ctypes)]
extern {
fn EC_KEY_generate_key_ex(ec_group_new: ECGroupNewFn) -> *mut EC_KEY;
fn EC_KEY_public_key_to_oct(key: *const EC_KEY, out: *mut u8,
Expand Down
4 changes: 4 additions & 0 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ pub fn verify_slices_are_equal_ct(a: &[u8], b: &[u8]) -> Result<(), ()> {
}
}

// XXX: As of Rust 1.4, the compiler will no longer warn about the use of
// `usize` and `isize` in FFI declarations. Remove the `allow(improper_ctypes)`
// when Rust 1.4 is released.
#[allow(improper_ctypes)]
extern {
fn CRYPTO_memcmp(a: *const libc::uint8_t, b: *const libc::uint8_t,
len: libc::size_t) -> libc::c_int;
Expand Down
4 changes: 4 additions & 0 deletions src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub fn fill_secure_random(out: &mut [u8]) -> Result<(), ()> {
})
}

// XXX: As of Rust 1.4, the compiler will no longer warn about the use of
// `usize` and `isize` in FFI declarations. Remove the `allow(improper_ctypes)`
// when Rust 1.4 is released.
#[allow(improper_ctypes)]
extern {
fn RAND_bytes(buf: *mut libc::uint8_t, len: libc::size_t) -> libc::c_int;
}
4 changes: 4 additions & 0 deletions src/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ pub fn verify_rsa_pkcs1_signed_digest_asn1(digest: &digest::Digest, sig: &[u8],
})
}

// XXX: As of Rust 1.4, the compiler will no longer warn about the use of
// `usize` and `isize` in FFI declarations. Remove the `allow(improper_ctypes)`
// when Rust 1.4 is released.
#[allow(improper_ctypes)]
extern {
fn RSA_verify_pkcs1_signed_digest(hash_nid: libc::c_int, digest: *const u8,
digest_len: libc::size_t, sig: *const u8,
Expand Down

0 comments on commit a4dd459

Please sign in to comment.