Unify equality checker functions return value
The equality checker functions always return 0 or 1 value, thus the type of return value can be the same dispite of the size of the parameters. Signed-off-by: gabor-mezei-arm <gabor.mezei@arm.com>
This commit is contained in:
parent
9cb55698aa
commit
b11a56e34c
2 changed files with 5 additions and 5 deletions
|
@ -168,8 +168,8 @@ size_t mbedtls_cf_size_mask_ge( size_t x,
|
||||||
* This function is implemented without using comparison operators, as those
|
* This function is implemented without using comparison operators, as those
|
||||||
* might be translated to branches by some compilers on some platforms.
|
* might be translated to branches by some compilers on some platforms.
|
||||||
*/
|
*/
|
||||||
size_t mbedtls_cf_size_bool_eq( size_t x,
|
unsigned mbedtls_cf_size_bool_eq( size_t x,
|
||||||
size_t y )
|
size_t y )
|
||||||
{
|
{
|
||||||
/* diff = 0 if x == y, non-zero otherwise */
|
/* diff = 0 if x == y, non-zero otherwise */
|
||||||
const size_t diff = x ^ y;
|
const size_t diff = x ^ y;
|
||||||
|
@ -189,7 +189,7 @@ size_t mbedtls_cf_size_bool_eq( size_t x,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* diff1 = (x != y) ? 1 : 0 */
|
/* diff1 = (x != y) ? 1 : 0 */
|
||||||
const size_t diff1 = diff_msb >> ( sizeof( diff_msb ) * 8 - 1 );
|
const unsigned diff1 = diff_msb >> ( sizeof( diff_msb ) * 8 - 1 );
|
||||||
|
|
||||||
return( 1 ^ diff1 );
|
return( 1 ^ diff1 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ size_t mbedtls_cf_size_mask_lt( size_t x,
|
||||||
size_t mbedtls_cf_size_mask_ge( size_t x,
|
size_t mbedtls_cf_size_mask_ge( size_t x,
|
||||||
size_t y );
|
size_t y );
|
||||||
|
|
||||||
size_t mbedtls_cf_size_bool_eq( size_t x,
|
unsigned mbedtls_cf_size_bool_eq( size_t x,
|
||||||
size_t y );
|
size_t y );
|
||||||
|
|
||||||
unsigned mbedtls_cf_size_gt( size_t x,
|
unsigned mbedtls_cf_size_gt( size_t x,
|
||||||
size_t y );
|
size_t y );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue