Add more assertions

This commit is contained in:
Camilla Löwy 2017-02-23 17:47:41 +01:00
parent 2ba461e348
commit 3817b4e1c5
3 changed files with 23 additions and 0 deletions

View File

@ -363,6 +363,10 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
int i; int i;
unsigned short values[256]; unsigned short values[256];
GLFWgammaramp ramp; GLFWgammaramp ramp;
assert(handle != NULL);
assert(gamma == gamma);
assert(gamma >= 0.f);
assert(gamma <= FLT_MAX);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
@ -414,6 +418,7 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
_GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL); assert(monitor != NULL);
assert(ramp != NULL); assert(ramp != NULL);
assert(ramp->size > 0);
assert(ramp->red != NULL); assert(ramp->red != NULL);
assert(ramp->green != NULL); assert(ramp->green != NULL);
assert(ramp->blue != NULL); assert(ramp->blue != NULL);

View File

@ -234,6 +234,8 @@ GLFWAPI int glfwVulkanSupported(void)
GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count) GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
{ {
assert(count != NULL);
*count = 0; *count = 0;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@ -252,6 +254,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
const char* procname) const char* procname)
{ {
GLFWvkproc proc; GLFWvkproc proc;
assert(procname != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@ -277,6 +280,9 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
VkPhysicalDevice device, VkPhysicalDevice device,
uint32_t queuefamily) uint32_t queuefamily)
{ {
assert(instance != VK_NULL_HANDLE);
assert(device != VK_NULL_HANDLE);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER)) if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
@ -300,6 +306,7 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
VkSurfaceKHR* surface) VkSurfaceKHR* surface)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(instance != VK_NULL_HANDLE);
assert(window != NULL); assert(window != NULL);
assert(surface != NULL); assert(surface != NULL);

View File

@ -130,6 +130,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
_GLFWwindow* previous; _GLFWwindow* previous;
assert(title != NULL); assert(title != NULL);
assert(width >= 0);
assert(height >= 0);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
@ -508,6 +510,8 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
assert(width >= 0);
assert(height >= 0);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
@ -566,6 +570,8 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL); assert(window != NULL);
assert(numer != 0);
assert(denom != 0);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
@ -808,6 +814,8 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
_GLFWwindow* window = (_GLFWwindow*) wh; _GLFWwindow* window = (_GLFWwindow*) wh;
_GLFWmonitor* monitor = (_GLFWmonitor*) mh; _GLFWmonitor* monitor = (_GLFWmonitor*) mh;
assert(window != NULL); assert(window != NULL);
assert(width >= 0);
assert(height >= 0);
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
@ -961,6 +969,9 @@ GLFWAPI void glfwWaitEvents(void)
GLFWAPI void glfwWaitEventsTimeout(double timeout) GLFWAPI void glfwWaitEventsTimeout(double timeout)
{ {
_GLFW_REQUIRE_INIT(); _GLFW_REQUIRE_INIT();
assert(timeout == timeout);
assert(timeout >= 0.0);
assert(timeout <= DBL_MAX);
if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX) if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX)
{ {