Fixed warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2).
This commit is contained in:
@@ -589,7 +589,7 @@ static SDL_bool HIDAPI_DriverPS4_LoadOfficialCalibrationData(SDL_HIDAPI_Device *
|
|||||||
SDL_Log("calibration[%d] bias = %d, sensitivity = %f\n", i, ctx->calibration[i].bias, ctx->calibration[i].scale);
|
SDL_Log("calibration[%d] bias = %d, sensitivity = %f\n", i, ctx->calibration[i].bias, ctx->calibration[i].scale);
|
||||||
#endif
|
#endif
|
||||||
/* Some controllers have a bad calibration */
|
/* Some controllers have a bad calibration */
|
||||||
if (SDL_abs(ctx->calibration[i].bias) > 1024 || SDL_fabs(1.0f - ctx->calibration[i].scale) > 0.5f) {
|
if (SDL_abs(ctx->calibration[i].bias) > 1024 || SDL_fabsf(1.0f - ctx->calibration[i].scale) > 0.5f) {
|
||||||
#ifdef DEBUG_PS4_CALIBRATION
|
#ifdef DEBUG_PS4_CALIBRATION
|
||||||
SDL_Log("invalid calibration, ignoring\n");
|
SDL_Log("invalid calibration, ignoring\n");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -629,7 +629,7 @@ static void HIDAPI_DriverPS5_LoadCalibrationData(SDL_HIDAPI_Device *device)
|
|||||||
SDL_Log("calibration[%d] bias = %d, sensitivity = %f\n", i, ctx->calibration[i].bias, ctx->calibration[i].sensitivity);
|
SDL_Log("calibration[%d] bias = %d, sensitivity = %f\n", i, ctx->calibration[i].bias, ctx->calibration[i].sensitivity);
|
||||||
#endif
|
#endif
|
||||||
/* Some controllers have a bad calibration */
|
/* Some controllers have a bad calibration */
|
||||||
if ((SDL_abs(ctx->calibration[i].bias) > 1024) || (SDL_fabs(1.0f - ctx->calibration[i].sensitivity / divisor) > 0.5f)) {
|
if ((SDL_abs(ctx->calibration[i].bias) > 1024) || (SDL_fabsf(1.0f - ctx->calibration[i].sensitivity / divisor) > 0.5f)) {
|
||||||
#ifdef DEBUG_PS5_CALIBRATION
|
#ifdef DEBUG_PS5_CALIBRATION
|
||||||
SDL_Log("invalid calibration, ignoring\n");
|
SDL_Log("invalid calibration, ignoring\n");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user