From 2bd0a241077da03d40a71388d3b00113318613f7 Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Sat, 24 Nov 2018 18:10:48 +0300 Subject: [PATCH] Monitor: simplify gamma range check Assertions and tests in glfwSetGamma verify that user-supplied gamma is a positive finite value, but tests for error reporting are redundant given the preceding asserts (however asserts allow gamma == 0, which is probably not intended). Remove the asserts and simplify the range check. Alternatively, it may be spelled as 'isfinite(gamma) && gamma > 0'. --- src/monitor.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/monitor.c b/src/monitor.c index f7de5500f..9ae3ac924 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -431,13 +431,10 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) unsigned short values[256]; GLFWgammaramp ramp; assert(handle != NULL); - assert(gamma == gamma); - assert(gamma >= 0.f); - assert(gamma <= FLT_MAX); _GLFW_REQUIRE_INIT(); - if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX) + if (!(gamma > 0.f && 1.f / gamma != 0.f)) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma); return;