[PSDK] Do not compare to max value if we can make sure that the value fits in target type

This fixes clang warning -Wtautological-constant-out-of-range-compare
This commit is contained in:
Jérôme Gardou 2021-04-12 10:28:11 +02:00 committed by Jérôme Gardou
parent a4138329a1
commit 7513cc9fca

View file

@ -259,7 +259,7 @@ INTSAFE_NAME(_Name)( \
_In_ _TypeFrom Input, \
_Out_ _Deref_out_range_(==, Input) _TypeTo *pOutput) \
{ \
if (Input <= _TypeTo ## _MAX) \
if ((sizeof(_TypeFrom) < sizeof(_TypeTo)) || (Input <= _TypeTo ## _MAX)) \
{ \
*pOutput = (_TypeTo)Input; \
return INTSAFE_SUCCESS; \