Check NULL pointers or not...

Matt Caswell matt at openssl.org
Fri Nov 29 10:35:20 UTC 2019



On 29/11/2019 10:29, Matthias St. Pierre wrote:
> 
> 
> 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?

Yes, I quite like that approach. This is just a refinement of the
"middle ground" option though.

Matt


More information about the openssl-project mailing list