Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this... if (Failed) { SDL_SetError("We failed"); return -1; } ...into this... if (Failed) { return SDL_SetError("We failed"); } Fixes Bugzilla #1778.
This commit is contained in:
parent
8c6b9f4743
commit
4f438b70a2
106 changed files with 616 additions and 1189 deletions
|
@ -89,8 +89,7 @@ WIN_SetClipboardText(_THIS, const char *text)
|
|||
|
||||
EmptyClipboard();
|
||||
if (!SetClipboardData(TEXT_FORMAT, hMem)) {
|
||||
WIN_SetError("Couldn't set clipboard data");
|
||||
result = -1;
|
||||
result = WIN_SetError("Couldn't set clipboard data");
|
||||
}
|
||||
data->clipboard_count = GetClipboardSequenceNumber();
|
||||
}
|
||||
|
@ -98,8 +97,7 @@ WIN_SetClipboardText(_THIS, const char *text)
|
|||
|
||||
CloseClipboard();
|
||||
} else {
|
||||
WIN_SetError("Couldn't open clipboard");
|
||||
result = -1;
|
||||
result = WIN_SetError("Couldn't open clipboard");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -809,12 +809,11 @@ SDL_RegisterApp(char *name, Uint32 style, void *hInst)
|
|||
class.cbWndExtra = 0;
|
||||
class.cbClsExtra = 0;
|
||||
if (!RegisterClass(&class)) {
|
||||
SDL_SetError("Couldn't register application class");
|
||||
return (-1);
|
||||
return SDL_SetError("Couldn't register application class");
|
||||
}
|
||||
|
||||
app_registered = 1;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unregisters the windowclass registered in SDL_RegisterApp above. */
|
||||
|
|
|
@ -85,8 +85,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, voi
|
|||
SDL_stack_free(info);
|
||||
|
||||
if (!data->hbm) {
|
||||
WIN_SetError("Unable to create DIB");
|
||||
return -1;
|
||||
return WIN_SetError("Unable to create DIB");
|
||||
}
|
||||
SelectObject(data->mdc, data->hbm);
|
||||
|
||||
|
|
|
@ -214,8 +214,7 @@ WIN_InitModes(_THIS)
|
|||
}
|
||||
}
|
||||
if (_this->num_displays == 0) {
|
||||
SDL_SetError("No displays available");
|
||||
return -1;
|
||||
return SDL_SetError("No displays available");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -282,8 +281,7 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||
reason = "DISP_CHANGE_FAILED";
|
||||
break;
|
||||
}
|
||||
SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
||||
return -1;
|
||||
return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
||||
}
|
||||
EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
|
||||
return 0;
|
||||
|
|
|
@ -196,8 +196,7 @@ WIN_SetRelativeMouseMode(SDL_bool enabled)
|
|||
/* Only return an error when registering. If we unregister and fail, then
|
||||
it's probably that we unregistered twice. That's OK. */
|
||||
if(enabled) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|||
char message[1024];
|
||||
SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")",
|
||||
path);
|
||||
WIN_SetError(message);
|
||||
return -1;
|
||||
return WIN_SetError(message);
|
||||
}
|
||||
SDL_strlcpy(_this->gl_config.driver_path, path,
|
||||
SDL_arraysize(_this->gl_config.driver_path));
|
||||
|
@ -103,8 +102,7 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|||
sizeof(struct
|
||||
SDL_GLDriverData));
|
||||
if (!_this->gl_data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Load function pointers */
|
||||
|
@ -124,9 +122,8 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|||
!_this->gl_data->wglCreateContext ||
|
||||
!_this->gl_data->wglDeleteContext ||
|
||||
!_this->gl_data->wglMakeCurrent) {
|
||||
SDL_SetError("Could not retrieve OpenGL functions");
|
||||
SDL_UnloadObject(handle);
|
||||
return -1;
|
||||
return SDL_SetError("Could not retrieve OpenGL functions");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -512,12 +509,10 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window)
|
|||
pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd);
|
||||
}
|
||||
if (!pixel_format) {
|
||||
SDL_SetError("No matching GL pixel format available");
|
||||
return -1;
|
||||
return SDL_SetError("No matching GL pixel format available");
|
||||
}
|
||||
if (!SetPixelFormat(hdc, pixel_format, &pfd)) {
|
||||
WIN_SetError("SetPixelFormat()");
|
||||
return (-1);
|
||||
return WIN_SetError("SetPixelFormat()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -611,11 +606,9 @@ int
|
|||
WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
HDC hdc;
|
||||
int status;
|
||||
|
||||
if (!_this->gl_data) {
|
||||
SDL_SetError("OpenGL not initialized");
|
||||
return -1;
|
||||
return SDL_SetError("OpenGL not initialized");
|
||||
}
|
||||
|
||||
if (window) {
|
||||
|
@ -624,30 +617,24 @@ WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
hdc = NULL;
|
||||
}
|
||||
if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC) context)) {
|
||||
WIN_SetError("wglMakeCurrent()");
|
||||
status = -1;
|
||||
} else {
|
||||
status = 0;
|
||||
return WIN_SetError("wglMakeCurrent()");
|
||||
}
|
||||
return status;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GL_SetSwapInterval(_THIS, int interval)
|
||||
{
|
||||
int retval = -1;
|
||||
if ((interval < 0) && (!_this->gl_data->HAS_WGL_EXT_swap_control_tear)) {
|
||||
SDL_SetError("Negative swap interval unsupported in this GL");
|
||||
return SDL_SetError("Negative swap interval unsupported in this GL");
|
||||
} else if (_this->gl_data->wglSwapIntervalEXT) {
|
||||
if (_this->gl_data->wglSwapIntervalEXT(interval) == TRUE) {
|
||||
retval = 0;
|
||||
} else {
|
||||
WIN_SetError("wglSwapIntervalEXT()");
|
||||
if (_this->gl_data->wglSwapIntervalEXT(interval) != TRUE) {
|
||||
return WIN_SetError("wglSwapIntervalEXT()");
|
||||
}
|
||||
} else {
|
||||
SDL_Unsupported();
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
return retval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -75,10 +75,10 @@ WIN_CreateDevice(int devindex)
|
|||
data = NULL;
|
||||
}
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
if (device) {
|
||||
SDL_free(device);
|
||||
}
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = data;
|
||||
|
|
|
@ -82,8 +82,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
/* Allocate the window data */
|
||||
data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->window = window;
|
||||
data->hwnd = hwnd;
|
||||
|
@ -98,8 +97,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
|
||||
ReleaseDC(hwnd, data->hdc);
|
||||
SDL_free(data);
|
||||
WIN_SetError("SetProp() failed");
|
||||
return -1;
|
||||
return WIN_SetError("SetProp() failed");
|
||||
}
|
||||
|
||||
/* Set up the window proc function */
|
||||
|
@ -221,8 +219,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
|
||||
SDL_Instance, NULL);
|
||||
if (!hwnd) {
|
||||
WIN_SetError("Couldn't create window");
|
||||
return -1;
|
||||
return WIN_SetError("Couldn't create window");
|
||||
}
|
||||
|
||||
WIN_PumpEvents(_this);
|
||||
|
@ -635,8 +632,7 @@ SDL_HelperWindowCreate(void)
|
|||
/* Register the class. */
|
||||
SDL_HelperWindowClass = RegisterClass(&wce);
|
||||
if (SDL_HelperWindowClass == 0) {
|
||||
WIN_SetError("Unable to create Helper Window Class");
|
||||
return -1;
|
||||
return WIN_SetError("Unable to create Helper Window Class");
|
||||
}
|
||||
|
||||
/* Create the window. */
|
||||
|
@ -648,8 +644,7 @@ SDL_HelperWindowCreate(void)
|
|||
hInstance, NULL);
|
||||
if (SDL_HelperWindow == NULL) {
|
||||
UnregisterClass(SDL_HelperWindowClassName, hInstance);
|
||||
WIN_SetError("Unable to create Helper Window");
|
||||
return -1;
|
||||
return WIN_SetError("Unable to create Helper Window");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue