Skip to content

Commit 457d313

Browse files
committed
drop unclear/untested/unused callback functions when no_symbol_renaming is on
1 parent 58f946f commit 457d313

File tree

1 file changed

+0
-79
lines changed

1 file changed

+0
-79
lines changed

secp256k1-sys/src/lib.rs

-79
Original file line numberDiff line numberDiff line change
@@ -575,69 +575,6 @@ pub unsafe fn secp256k1_context_destroy(ctx: *mut Context) {
575575
rustsecp256k1_v0_4_0_context_destroy(ctx)
576576
}
577577

578-
579-
/// **This function is an override for the C function, this is the an edited version of the original description:**
580-
///
581-
/// A callback function to be called when an illegal argument is passed to
582-
/// an API call. It will only trigger for violations that are mentioned
583-
/// explicitly in the header. **This will cause a panic**.
584-
///
585-
/// The philosophy is that these shouldn't be dealt with through a
586-
/// specific return value, as calling code should not have branches to deal with
587-
/// the case that this code itself is broken.
588-
///
589-
/// On the other hand, during debug stage, one would want to be informed about
590-
/// such mistakes, and the default (crashing) may be inadvisable.
591-
/// When this callback is triggered, the API function called is guaranteed not
592-
/// to cause a crash, though its return value and output arguments are
593-
/// undefined.
594-
///
595-
/// See also secp256k1_default_error_callback_fn.
596-
///
597-
#[no_mangle]
598-
#[cfg(not(rust_secp_no_symbol_renaming))]
599-
pub unsafe extern "C" fn rustsecp256k1_v0_4_0_default_illegal_callback_fn(message: *const c_char, _data: *mut c_void) {
600-
use core::str;
601-
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
602-
let msg = str::from_utf8_unchecked(msg_slice);
603-
panic!("[libsecp256k1] illegal argument. {}", msg);
604-
}
605-
606-
/// **This function is an override for the C function, this is the an edited version of the original description:**
607-
///
608-
/// A callback function to be called when an internal consistency check
609-
/// fails. **This will cause a panic**.
610-
///
611-
/// This can only trigger in case of a hardware failure, miscompilation,
612-
/// memory corruption, serious bug in the library, or other error would can
613-
/// otherwise result in undefined behaviour. It will not trigger due to mere
614-
/// incorrect usage of the API (see secp256k1_default_illegal_callback_fn
615-
/// for that). After this callback returns, anything may happen, including
616-
/// crashing.
617-
///
618-
/// See also secp256k1_default_illegal_callback_fn.
619-
///
620-
#[no_mangle]
621-
#[cfg(not(rust_secp_no_symbol_renaming))]
622-
pub unsafe extern "C" fn rustsecp256k1_v0_4_0_default_error_callback_fn(message: *const c_char, _data: *mut c_void) {
623-
use core::str;
624-
let msg_slice = slice::from_raw_parts(message as *const u8, strlen(message));
625-
let msg = str::from_utf8_unchecked(msg_slice);
626-
panic!("[libsecp256k1] internal consistency check failed {}", msg);
627-
}
628-
629-
#[no_mangle]
630-
#[cfg(not(rust_secp_no_symbol_renaming))]
631-
unsafe fn strlen(mut str_ptr: *const c_char) -> usize {
632-
let mut ctr = 0;
633-
while *str_ptr != '\0' as c_char {
634-
ctr += 1;
635-
str_ptr = str_ptr.offset(1);
636-
}
637-
ctr
638-
}
639-
640-
641578
/// A trait for producing pointers that will always be valid in C. (assuming NULL pointer is a valid no-op)
642579
/// Rust doesn't promise what pointers does it give to ZST (https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts)
643580
/// In case the type is empty this trait will give a NULL pointer, which should be handled in C.
@@ -759,19 +696,3 @@ mod fuzz_dummy {
759696
#[cfg(rust_secp_fuzz)]
760697
pub use self::fuzz_dummy::*;
761698

762-
#[cfg(test)]
763-
mod tests {
764-
#[no_mangle]
765-
#[cfg(not(rust_secp_no_symbol_renaming))]
766-
#[test]
767-
fn test_strlen() {
768-
use std::ffi::CString;
769-
use super::strlen;
770-
771-
let orig = "test strlen \t \n";
772-
let test = CString::new(orig).unwrap();
773-
774-
assert_eq!(orig.len(), unsafe {strlen(test.as_ptr())});
775-
}
776-
}
777-

0 commit comments

Comments
 (0)