Replace CHECKs for no_precomp ctx by ARG_CHECKs without a return
This commit is contained in:
parent
6c36de7a33
commit
6095a863fa
|
@ -27,6 +27,12 @@
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
#define ARG_CHECK_NO_RETURN(cond) do { \
|
||||
if (EXPECT(!(cond), 0)) { \
|
||||
secp256k1_callback_call(&ctx->illegal_callback, #cond); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static void default_illegal_callback_fn(const char* str, void* data) {
|
||||
(void)data;
|
||||
fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str);
|
||||
|
@ -162,7 +168,7 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
|
|||
}
|
||||
|
||||
void secp256k1_context_preallocated_destroy(secp256k1_context* ctx) {
|
||||
CHECK(ctx != secp256k1_context_no_precomp);
|
||||
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_no_precomp);
|
||||
if (ctx != NULL) {
|
||||
secp256k1_ecmult_context_clear(&ctx->ecmult_ctx);
|
||||
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
|
||||
|
@ -177,7 +183,7 @@ void secp256k1_context_destroy(secp256k1_context* ctx) {
|
|||
}
|
||||
|
||||
void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
|
||||
CHECK(ctx != secp256k1_context_no_precomp);
|
||||
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_no_precomp);
|
||||
if (fun == NULL) {
|
||||
fun = default_illegal_callback_fn;
|
||||
}
|
||||
|
@ -186,7 +192,7 @@ void secp256k1_context_set_illegal_callback(secp256k1_context* ctx, void (*fun)(
|
|||
}
|
||||
|
||||
void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(const char* message, void* data), const void* data) {
|
||||
CHECK(ctx != secp256k1_context_no_precomp);
|
||||
ARG_CHECK_NO_RETURN(ctx != secp256k1_context_no_precomp);
|
||||
if (fun == NULL) {
|
||||
fun = default_error_callback_fn;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue