I'm trying to understand this function sodium_is_zero from the cryptography library libsodium (https://github.com/jedisct1/libsodium):
https://github.com/jedisct1/libsodium/blob/master/src/libsodium/sodium/utils.c#L256-L266
int
sodium_is_zero(const unsigned char *n, const size_t nlen)
{
size_t i;
volatile unsigned char d = 0U;
for (i = 0U; i < nlen; i++) {
d |= n[i];
}
return 1 & ((d - 1) >> 8);
}
Could anyone explain to me why d
is volatile and what purpose volatile is serving here?