Use the explicit NULL macro for pointer comparisons.

This makes it more clear that a null check is intended. Avoiding the
 use of a pointer as a test condition alse increases the type-safety
 of the comparisons.

(This is also MISRA C 2012 rules 14.4 and 11.9)
This commit is contained in:
Gregory Maxwell
2015-09-23 21:56:04 +00:00
parent 9e9051687c
commit 2b199de888
6 changed files with 18 additions and 18 deletions

View File

@@ -85,7 +85,7 @@ secp256k1_context* secp256k1_context_clone(const secp256k1_context* ctx) {
}
void secp256k1_context_destroy(secp256k1_context* ctx) {
if (ctx) {
if (ctx != NULL) {
secp256k1_ecmult_context_clear(&ctx->ecmult_ctx);
secp256k1_ecmult_gen_context_clear(&ctx->ecmult_gen_ctx);
@@ -94,7 +94,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) {
if (!fun) {
if (fun == NULL) {
fun = default_illegal_callback_fn;
}
ctx->illegal_callback.fn = fun;
@@ -102,7 +102,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) {
if (!fun) {
if (fun == NULL) {
fun = default_error_callback_fn;
}
ctx->error_callback.fn = fun;