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'.
This commit is contained in:
Alexander Monakov 2018-11-24 18:10:48 +03:00
parent bb2ca1da13
commit 2bd0a24107

View File

@ -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;