]> git.codecow.com Git - Monocypher.git/commitdiff
Use NULL instead of 0 for null pointers
authorLoup Vaillant <loup@loup-vaillant.fr>
Tue, 17 Oct 2023 04:35:39 +0000 (06:35 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Tue, 17 Oct 2023 04:35:39 +0000 (06:35 +0200)
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.

src/monocypher.c

index 6e323a8cf0908a3597a6703b4efab3477982d9a4..302635aca3199311c332d2122992278795e191e9 100644 (file)
@@ -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);