Conditionally compile fn strlen

`strlen` is only used under certain feature flags, use `cfg` to
conditionally build it in.

Clears clippy warning.
This commit is contained in:
Tobin Harding 2020-12-22 11:28:57 +11:00
parent 617bff9df3
commit 3afc172096
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 7 additions and 4 deletions

View File

@ -630,7 +630,8 @@ pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_error_callback_fn(message:
panic!("[libsecp256k1] internal consistency check failed {}", msg); panic!("[libsecp256k1] internal consistency check failed {}", msg);
} }
#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
unsafe fn strlen(mut str_ptr: *const c_char) -> usize { unsafe fn strlen(mut str_ptr: *const c_char) -> usize {
let mut ctr = 0; let mut ctr = 0;
while *str_ptr != '\0' as c_char { while *str_ptr != '\0' as c_char {
@ -1161,11 +1162,13 @@ pub use self::fuzz_dummy::*;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
#[test]
fn test_strlen() {
use std::ffi::CString; use std::ffi::CString;
use super::strlen; use super::strlen;
#[test]
fn test_strlen() {
let orig = "test strlen \t \n"; let orig = "test strlen \t \n";
let test = CString::new(orig).unwrap(); let test = CString::new(orig).unwrap();