Add some missing assertions

Port from upstream glfw: 38ec7abd3baffdd3ec4e6f8cbb5384cda8882ae3
This commit is contained in:
Kovid Goyal 2025-08-16 07:38:54 +05:30
parent cb42fd82a4
commit caba27240b
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
10 changed files with 33 additions and 1 deletions

View file

@ -32,6 +32,7 @@
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <CoreVideo/CVBase.h>
@ -635,6 +636,8 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
return monitor->ns.displayID;
}

View file

@ -35,6 +35,7 @@
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
#include <float.h>
#include <string.h>
#include <assert.h>
#define debug debug_rendering
@ -3127,6 +3128,8 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
return window->ns.object;
}

4
glfw/egl_context.c vendored
View file

@ -790,6 +790,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
if (window->context.client == GLFW_NO_API)
@ -804,6 +806,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
if (window->context.client == GLFW_NO_API)

4
glfw/glx_context.c vendored
View file

@ -658,6 +658,8 @@ bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig UNUSED,
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (window->context.client == GLFW_NO_API)
@ -672,6 +674,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(None);
if (window->context.client == GLFW_NO_API)

View file

@ -27,6 +27,7 @@
//========================================================================
#include "internal.h"
#include <assert.h>
static void makeContextCurrentNSGL(_GLFWwindow* window)
@ -319,6 +320,8 @@ bool _glfwCreateContextNSGL(_GLFWwindow* window,
GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
if (window->context.client == GLFW_NO_API)

View file

@ -352,6 +352,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (window->context.client == GLFW_NO_API)

4
glfw/wl_monitor.c vendored
View file

@ -28,10 +28,10 @@
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
static void outputHandleGeometry(void* data,
@ -241,6 +241,8 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor UNUSED,
GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return monitor->wl.output;
}

3
glfw/wl_window.c vendored
View file

@ -40,6 +40,7 @@
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <assert.h>
#define debug debug_rendering
@ -2869,6 +2870,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void)
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->wl.surface;
}

5
glfw/x11_monitor.c vendored
View file

@ -33,6 +33,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
// Check whether the display mode should be included in enumeration
@ -593,6 +594,8 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(None);
return monitor->x11.crtc;
}
@ -600,6 +603,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
{
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
assert(monitor != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(None);
return monitor->x11.output;
}

3
glfw/x11_window.c vendored
View file

@ -41,6 +41,7 @@
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <assert.h>
// Action for EWMH client messages
#define _NET_WM_STATE_REMOVE 0
@ -3408,6 +3409,8 @@ GLFWAPI Display* glfwGetX11Display(void)
GLFWAPI unsigned long glfwGetX11Window(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(None);
return window->x11.handle;
}