Check NULL pointers or not...

Matthias St. Pierre Matthias.St.Pierre at ncp-e.com
Fri Nov 29 10:29:39 UTC 2019



On 29.11.19 10:22, Matt Caswell wrote:
>
>      if (!ossl_assert(ptr != NULL)) {
>          ERR_raise(ERR_LIB_WHATEVER, ERR_R_PASSED_NULL_PARAMETER);
>          return 0;
>      }
>

I still dislike the odd way in which the assertion needs to be formulated,
with the double negation. With the `ossl_is_null()` macro, which I proposed
in #7218, the same condition would read

     if (ossl_is_null(ptr)) {
         ERR_raise(ERR_LIB_WHATEVER, ERR_R_PASSED_NULL_PARAMETER);
         return 0;
     }


Isn't that much better readable and easier to understand?


For more examples like that, see the change set

https://github.com/openssl/openssl/pull/7218/files


Matthias




More information about the openssl-project mailing list