Avoid useless comparisons

This commit is contained in:
Frank Denis 2017-03-12 18:02:46 +01:00
parent d4dbf0cc4f
commit bbcb8bd33b
2 changed files with 6 additions and 2 deletions

View File

@ -422,9 +422,11 @@ randombytes_salsa20_random_buf(void * const buf, const size_t size)
randombytes_salsa20_random_stir_if_needed(); randombytes_salsa20_random_stir_if_needed();
COMPILER_ASSERT(sizeof stream.nonce == crypto_stream_salsa20_NONCEBYTES); COMPILER_ASSERT(sizeof stream.nonce == crypto_stream_salsa20_NONCEBYTES);
#ifdef ULONG_LONG_MAX #if defined(ULONG_LONG_MAX) && defined(SIZE_MAX)
# if SIZE_MAX > ULONG_LONG_MAX
/* coverity[result_independent_of_operands] */ /* coverity[result_independent_of_operands] */
assert(size <= ULONG_LONG_MAX); assert(size <= ULONG_LONG_MAX);
# endif
#endif #endif
ret = crypto_stream_salsa20((unsigned char *) buf, (unsigned long long) size, ret = crypto_stream_salsa20((unsigned char *) buf, (unsigned long long) size,
(unsigned char *) &stream.nonce, stream.key); (unsigned char *) &stream.nonce, stream.key);

View File

@ -313,9 +313,11 @@ static void
randombytes_sysrandom_buf(void * const buf, const size_t size) randombytes_sysrandom_buf(void * const buf, const size_t size)
{ {
randombytes_sysrandom_stir_if_needed(); randombytes_sysrandom_stir_if_needed();
#ifdef ULONG_LONG_MAX #if defined(ULONG_LONG_MAX) && defined(SIZE_MAX)
# if SIZE_MAX > ULONG_LONG_MAX
/* coverity[result_independent_of_operands] */ /* coverity[result_independent_of_operands] */
assert(size <= ULONG_LONG_MAX); assert(size <= ULONG_LONG_MAX);
# endif
#endif #endif
#ifndef _WIN32 #ifndef _WIN32
# if defined(SYS_getrandom) && defined(__NR_getrandom) # if defined(SYS_getrandom) && defined(__NR_getrandom)