Skip to content

Commit

Permalink
Merge pull request #260 from tcharding/clippy
Browse files Browse the repository at this point in the history
Clear clippy warnings
  • Loading branch information
apoelstra authored Dec 22, 2020
2 parents 3151352 + 02dec3e commit 1a818ea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
12 changes: 8 additions & 4 deletions secp256k1-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub const SECP256K1_START_VERIFY: c_uint = 1 | (1 << 8);
/// Flag for context to enable signing precomputation
pub const SECP256K1_START_SIGN: c_uint = 1 | (1 << 9);
/// Flag for keys to indicate uncompressed serialization format
#[allow(unused_parens)]
pub const SECP256K1_SER_UNCOMPRESSED: c_uint = (1 << 1);
/// Flag for keys to indicate compressed serialization format
pub const SECP256K1_SER_COMPRESSED: c_uint = (1 << 1) | (1 << 8);
Expand Down Expand Up @@ -629,7 +630,8 @@ pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_error_callback_fn(message:
panic!("[libsecp256k1] internal consistency check failed {}", msg);
}


#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
unsafe fn strlen(mut str_ptr: *const c_char) -> usize {
let mut ctr = 0;
while *str_ptr != '\0' as c_char {
Expand Down Expand Up @@ -1160,11 +1162,13 @@ pub use self::fuzz_dummy::*;

#[cfg(test)]
mod tests {
use std::ffi::CString;
use super::strlen;

#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
#[test]
fn test_strlen() {
use std::ffi::CString;
use super::strlen;

let orig = "test strlen \t \n";
let test = CString::new(orig).unwrap();

Expand Down
16 changes: 9 additions & 7 deletions secp256k1-sys/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ macro_rules! impl_array_newtype {
dat.as_mut_ptr()
}

#[inline]
/// Gets a reference to the underlying array
pub fn as_ref(&self) -> &[$ty; $len] {
let &$thing(ref dat) = self;
dat
}

#[inline]
/// Returns the length of the object as an array
pub fn len(&self) -> usize { $len }
Expand All @@ -50,6 +43,15 @@ macro_rules! impl_array_newtype {
pub fn is_empty(&self) -> bool { false }
}

impl AsRef<[$ty; $len]> for $thing {
#[inline]
/// Gets a reference to the underlying array
fn as_ref(&self) -> &[$ty; $len] {
let &$thing(ref dat) = self;
dat
}
}

impl PartialEq for $thing {
#[inline]
fn eq(&self, other: &$thing) -> bool {
Expand Down
1 change: 1 addition & 0 deletions secp256k1-sys/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl AlignedType {
}
}

#[cfg(all(feature = "std", not(feature = "external-symbols")))]
pub(crate) const ALIGN_TO: usize = mem::align_of::<AlignedType>();


Expand Down

0 comments on commit 1a818ea

Please sign in to comment.