From: Loup Vaillant Date: Tue, 17 Oct 2023 04:35:39 +0000 (+0200) Subject: Use NULL instead of 0 for null pointers X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=9a2c0d4478f4e0a94b59b478bfc6e058a0f20adf;p=Monocypher.git Use NULL instead of 0 for null pointers Turns out the standard guarantees that NULL is defined in `stddef.h`. Contrary to what I used to believe, using it doesn't induce any further dependency. `0` is also guaranteed by the standard to work, but it's less explicit and in some cases more error prone. --- diff --git a/src/monocypher.c b/src/monocypher.c index 6e323a8..302635a 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -232,7 +232,7 @@ u64 crypto_chacha20_djb(u8 *cipher_text, const u8 *plain_text, size_t nb_blocks = text_size >> 6; FOR (i, 0, nb_blocks) { chacha20_rounds(pool, input); - if (plain_text != 0) { + if (plain_text != NULL) { FOR (j, 0, 16) { u32 p = pool[j] + input[j]; store32_le(cipher_text, p ^ load32_le(plain_text)); @@ -255,7 +255,7 @@ u64 crypto_chacha20_djb(u8 *cipher_text, const u8 *plain_text, // Last (incomplete) block if (text_size > 0) { - if (plain_text == 0) { + if (plain_text == NULL) { plain_text = zero; } chacha20_rounds(pool, input);