Fixes for several implicit cast warnings. ZD 10848.

This commit is contained in:
David Garske
2020-08-27 13:51:55 -07:00
parent d077efcbb3
commit 0d2e37cc42
5 changed files with 132 additions and 133 deletions

View File

@@ -335,67 +335,67 @@ WC_STATIC WC_INLINE word32 btoi(byte b)
/* Constant time - mask set when a > b. */
WC_STATIC WC_INLINE byte ctMaskGT(int a, int b)
{
return ((byte)(((word32)a - b - 1) >> 31) - 1);
return (byte)((((word32)a - b - 1) >> 31) - 1);
}
/* Constant time - mask set when a >= b. */
WC_STATIC WC_INLINE byte ctMaskGTE(int a, int b)
{
return (((word32)a - b ) >> 31) - 1;
return (byte)((((word32)a - b ) >> 31) - 1);
}
/* Constant time - mask set when a >= b. */
WC_STATIC WC_INLINE int ctMaskIntGTE(int a, int b)
{
return (((word32)a - b ) >> 31) - 1;
return (int)((((word32)a - b ) >> 31) - 1);
}
/* Constant time - mask set when a < b. */
WC_STATIC WC_INLINE byte ctMaskLT(int a, int b)
{
return (((word32)b - a - 1) >> 31) - 1;
return (byte)((((word32)b - a - 1) >> 31) - 1);
}
/* Constant time - mask set when a <= b. */
WC_STATIC WC_INLINE byte ctMaskLTE(int a, int b)
{
return (((word32)b - a ) >> 31) - 1;
return (byte)((((word32)b - a ) >> 31) - 1);
}
/* Constant time - mask set when a == b. */
WC_STATIC WC_INLINE byte ctMaskEq(int a, int b)
{
return (~ctMaskGT(a, b)) & (~ctMaskLT(a, b));
return (byte)(~ctMaskGT(a, b)) & (byte)(~ctMaskLT(a, b));
}
/* Constant time - sets 16 bit integer mask when a > b */
WC_STATIC WC_INLINE word16 ctMask16GT(int a, int b)
{
return (((word32)a - b - 1) >> 31) - 1;
return (word16)((((word32)a - b - 1) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a < b. */
WC_STATIC WC_INLINE word16 ctMask16LT(int a, int b)
{
return (((word32)b - a - 1) >> 31) - 1;
return (word16)((((word32)b - a - 1) >> 31) - 1);
}
/* Constant time - sets 16 bit integer mask when a == b. */
WC_STATIC WC_INLINE word16 ctMask16Eq(int a, int b)
{
return (~ctMask16GT(a, b)) & (~ctMask16LT(a, b));
return (word16)(~ctMask16GT(a, b)) & (word16)(~ctMask16LT(a, b));
}
/* Constant time - mask set when a != b. */
WC_STATIC WC_INLINE byte ctMaskNotEq(int a, int b)
{
return ctMaskGT(a, b) | ctMaskLT(a, b);
return (byte)ctMaskGT(a, b) | (byte)ctMaskLT(a, b);
}
/* Constant time - select a when mask is set and b otherwise. */
WC_STATIC WC_INLINE byte ctMaskSel(byte m, byte a, byte b)
{
return (b & ((byte)~(word32)m)) | (a & m);
return (byte)((b & ((byte)~(word32)m)) | (a & m));
}
/* Constant time - select integer a when mask is set and integer b otherwise. */
@@ -408,7 +408,7 @@ WC_STATIC WC_INLINE int ctMaskSelInt(byte m, int a, int b)
/* Constant time - bit set when a <= b. */
WC_STATIC WC_INLINE byte ctSetLTE(int a, int b)
{
return ((word32)a - b - 1) >> 31;
return (byte)(((word32)a - b - 1) >> 31);
}
#endif