From 60deadba599967e57bd7f4043c5e76ee63bfb7f4 Mon Sep 17 00:00:00 2001 From: pionere Date: Mon, 17 Jan 2022 17:22:30 +0100 Subject: [PATCH] re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory --- src/SDL.c | 3 +- src/audio/SDL_audio.c | 3 +- src/audio/coreaudio/SDL_coreaudio.m | 3 +- src/haptic/windows/SDL_dinputhaptic.c | 6 +-- src/haptic/windows/SDL_xinputhaptic.c | 3 +- src/joystick/hidapi/SDL_hidapi_gamecube.c | 3 +- src/joystick/hidapi/SDL_hidapi_switch.c | 3 +- src/joystick/hidapi/SDL_hidapijoystick.c | 18 +++---- src/render/direct3d/SDL_render_d3d.c | 15 ++---- src/render/direct3d11/SDL_render_d3d11.c | 57 ++++++++--------------- src/render/psp/SDL_render_psp.c | 4 +- src/render/software/SDL_render_sw.c | 3 +- src/thread/stdcpp/SDL_systhread.cpp | 6 +-- src/video/SDL_surface.c | 3 +- src/video/SDL_video.c | 9 ++-- src/video/nacl/SDL_naclwindow.c | 3 +- src/video/vita/SDL_vitavideo.c | 3 +- src/video/winrt/SDL_winrtvideo.cpp | 9 ++-- 18 files changed, 52 insertions(+), 102 deletions(-) diff --git a/src/SDL.c b/src/SDL.c index d3d60fbf0..dfc4572f4 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -153,8 +153,7 @@ SDL_InitSubSystem(Uint32 flags) Uint32 flags_initialized = 0; if (!SDL_MainIsReady) { - SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"); - return -1; + return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"); } /* Clear the error message */ diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 53c099a02..ad4a201de 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -1523,8 +1523,7 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained) /* SDL_OpenAudio() is legacy and can only act on Device ID #1. */ if (open_devices[0] != NULL) { - SDL_SetError("Audio device is already opened"); - return -1; + return SDL_SetError("Audio device is already opened"); } if (obtained) { diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index cd886615c..c72ce1e40 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -1135,8 +1135,7 @@ COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) this->hidden->ready_semaphore = NULL; if ((this->hidden->thread != NULL) && (this->hidden->thread_error != NULL)) { - SDL_SetError("%s", this->hidden->thread_error); - return -1; + return SDL_SetError("%s", this->hidden->thread_error); } return (this->hidden->thread != NULL) ? 0 : -1; diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 0ae71f4a9..f10c369af 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -492,8 +492,7 @@ SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) ++index; } - SDL_SetError("Couldn't find joystick in haptic device list"); - return -1; + return SDL_SetError("Couldn't find joystick in haptic device list"); } void @@ -959,8 +958,7 @@ SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SD REFGUID type = SDL_SYS_HapticEffectType(base); if (type == NULL) { - SDL_SetError("Haptic: Unknown effect type."); - return -1; + return SDL_SetError("Haptic: Unknown effect type."); } /* Get the effect. */ diff --git a/src/haptic/windows/SDL_xinputhaptic.c b/src/haptic/windows/SDL_xinputhaptic.c index 2e1da5987..9212fbf32 100644 --- a/src/haptic/windows/SDL_xinputhaptic.c +++ b/src/haptic/windows/SDL_xinputhaptic.c @@ -246,8 +246,7 @@ SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) ++index; } - SDL_SetError("Couldn't find joystick in haptic device list"); - return -1; + return SDL_SetError("Couldn't find joystick in haptic device list"); } void diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index 5af93da60..ec1b029d5 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -454,8 +454,7 @@ HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo } /* Should never get here! */ - SDL_SetError("Couldn't find joystick"); - return -1; + return SDL_SetError("Couldn't find joystick"); } static int diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index d97e1f9c8..912d613ed 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -1023,8 +1023,7 @@ HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16 ctx->m_bRumbleActive = (low_frequency_rumble || high_frequency_rumble) ? SDL_TRUE : SDL_FALSE; if (!WriteRumble(ctx)) { - SDL_SetError("Couldn't send rumble packet"); - return -1; + return SDL_SetError("Couldn't send rumble packet"); } return 0; } diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 959b72414..55d9a1353 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -309,8 +309,7 @@ HIDAPI_JoystickInit(void) #endif if (SDL_hid_init() < 0) { - SDL_SetError("Couldn't initialize hidapi"); - return -1; + return SDL_SetError("Couldn't initialize hidapi"); } for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) { @@ -871,8 +870,7 @@ HIDAPI_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint1 result = device->driver->RumbleJoystick(device, joystick, low_frequency_rumble, high_frequency_rumble); } else { - SDL_SetError("Rumble failed, device disconnected"); - result = -1; + result = SDL_SetError("Rumble failed, device disconnected"); } return result; @@ -888,8 +886,7 @@ HIDAPI_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 result = device->driver->RumbleJoystickTriggers(device, joystick, left_rumble, right_rumble); } else { - SDL_SetError("Rumble failed, device disconnected"); - result = -1; + result = SDL_SetError("Rumble failed, device disconnected"); } return result; @@ -919,8 +916,7 @@ HIDAPI_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue result = device->driver->SetJoystickLED(device, joystick, red, green, blue); } else { - SDL_SetError("SetLED failed, device disconnected"); - result = -1; + result = SDL_SetError("SetLED failed, device disconnected"); } return result; @@ -936,8 +932,7 @@ HIDAPI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) result = device->driver->SendJoystickEffect(device, joystick, data, size); } else { - SDL_SetError("SendEffect failed, device disconnected"); - result = -1; + result = SDL_SetError("SendEffect failed, device disconnected"); } return result; @@ -953,8 +948,7 @@ HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) result = device->driver->SetJoystickSensorsEnabled(device, joystick, enabled); } else { - SDL_SetError("SetSensorsEnabled failed, device disconnected"); - result = -1; + result = SDL_SetError("SetSensorsEnabled failed, device disconnected"); } return result; diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index deb324c7d..ec986b345 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -584,8 +584,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; if (!texturedata) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) { @@ -621,8 +620,7 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; if (!texturedata) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { @@ -647,8 +645,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, IDirect3DDevice9 *device = data->device; if (!texturedata) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } texturedata->locked_rect = *rect; @@ -756,8 +753,7 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) texturedata = (D3D_TextureData *)texture->driverdata; if (!texturedata) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } /* Make sure the render target is updated if it was locked and written to */ @@ -942,8 +938,7 @@ SetupTextureState(D3D_RenderData *data, SDL_Texture * texture, LPDIRECT3DPIXELSH SDL_assert(*shader == NULL); if (!texturedata) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } UpdateTextureScaleMode(data, texturedata, 0); diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index cbce5b8b7..dcab009c2 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -1114,8 +1114,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); } if (texture->format == SDL_PIXELFORMAT_YV12 || @@ -1132,8 +1131,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); } result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, @@ -1143,8 +1141,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); } } @@ -1165,8 +1162,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); } } @@ -1181,8 +1177,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); } if (textureData->yuv) { @@ -1193,8 +1188,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); } result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, (ID3D11Resource *)textureData->mainTextureV, @@ -1203,8 +1197,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); } } @@ -1220,8 +1213,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); } } @@ -1237,8 +1229,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) &textureData->mainTextureRenderTargetView); if (FAILED(result)) { D3D11_DestroyTexture(renderer, texture); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result); } } @@ -1295,8 +1286,7 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex NULL, &stagingTexture); if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); } /* Get a write-only pointer to data in the staging texture: */ @@ -1308,9 +1298,8 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex &textureMemory ); if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); SAFE_RELEASE(stagingTexture); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); } src = (const Uint8 *)pixels; @@ -1362,8 +1351,7 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; if (!textureData) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) { @@ -1408,8 +1396,7 @@ D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; if (!textureData) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { @@ -1434,8 +1421,7 @@ D3D11_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; if (!textureData) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { @@ -1460,8 +1446,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, D3D11_MAPPED_SUBRESOURCE textureMemory; if (!textureData) { - SDL_SetError("Texture is not currently available"); - return -1; + return SDL_SetError("Texture is not currently available"); } if (textureData->yuv || textureData->nv12) { @@ -1505,8 +1490,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, NULL, &textureData->stagingTexture); if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); } /* Get a write-only pointer to data in the staging texture: */ @@ -1518,9 +1502,8 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, &textureMemory ); if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); SAFE_RELEASE(textureData->stagingTexture); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); } /* Make note of where the staging texture will be written to @@ -1718,8 +1701,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, &mappedResource ); if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result); } SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes); ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexBuffers[vbidx], 0); @@ -1746,8 +1728,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, &rendererData->vertexBuffers[vbidx] ); if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result); - return -1; + return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result); } rendererData->vertexBufferSizes[vbidx] = dataSizeInBytes; diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 9431b929b..8f6ee08b5 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -442,8 +442,8 @@ TextureSpillLRU(PSP_RenderData* data, size_t wanted) { } LRUTargetRemove(data, lru); } else { - SDL_SetError("Could not spill more VRAM to system memory. VRAM : %dKB,(%dKB), wanted %dKB", vmemavail()/1024, vlargestblock()/1024, wanted/1024); - return -1; //Asked to spill but there nothing to spill + // Asked to spill but there nothing to spill + return SDL_SetError("Could not spill more VRAM to system memory. VRAM : %dKB,(%dKB), wanted %dKB", vmemavail()/1024, vlargestblock()/1024, wanted/1024); } return 0; } diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 4d4d44644..5afa4fa44 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -99,8 +99,7 @@ SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) return 0; } - SDL_SetError("Software renderer doesn't have an output surface"); - return -1; + return SDL_SetError("Software renderer doesn't have an output surface"); } static int diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp index 086a1fde2..3d818ac56 100644 --- a/src/thread/stdcpp/SDL_systhread.cpp +++ b/src/thread/stdcpp/SDL_systhread.cpp @@ -52,11 +52,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread) thread->handle = (void *) new std::thread(std::move(cpp_thread)); return 0; } catch (std::system_error & ex) { - SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what()); - return -1; + return SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what()); } catch (std::bad_alloc &) { - SDL_OutOfMemory(); - return -1; + return SDL_OutOfMemory(); } } diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index dc6c4c27d..ec981a29c 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -1404,8 +1404,7 @@ int SDL_ConvertPixels(int width, int height, } #else if (SDL_ISPIXELFORMAT_FOURCC(src_format) || SDL_ISPIXELFORMAT_FOURCC(dst_format)) { - SDL_SetError("SDL not built with YUV support"); - return -1; + return SDL_SetError("SDL not built with YUV support"); } #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 2b7e025e3..00f84efbc 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1879,18 +1879,15 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) } if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) { - SDL_SetError("Vulkan and OpenGL not supported on same window"); - return -1; + return SDL_SetError("Vulkan and OpenGL not supported on same window"); } if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) { - SDL_SetError("Metal and OpenGL not supported on same window"); - return -1; + return SDL_SetError("Metal and OpenGL not supported on same window"); } if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) { - SDL_SetError("Metal and Vulkan not supported on same window"); - return -1; + return SDL_SetError("Metal and Vulkan not supported on same window"); } if (need_gl_unload) { diff --git a/src/video/nacl/SDL_naclwindow.c b/src/video/nacl/SDL_naclwindow.c index 255ac084b..f0245aef2 100644 --- a/src/video/nacl/SDL_naclwindow.c +++ b/src/video/nacl/SDL_naclwindow.c @@ -35,8 +35,7 @@ NACL_CreateWindow(_THIS, SDL_Window * window) SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; if (driverdata->window) { - SDL_SetError("NaCl only supports one window"); - return -1; + return SDL_SetError("NaCl only supports one window"); } driverdata->window = window; diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index ad9e559a3..778a87073 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -259,8 +259,7 @@ VITA_CreateWindow(_THIS, SDL_Window * window) // Vita can only have one window if (Vita_Window != NULL) { - SDL_SetError("Only one window supported"); - return -1; + return SDL_SetError("Only one window supported"); } Vita_Window = window; diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index 0b231b792..5b917dbb4 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -478,8 +478,7 @@ WINRT_InitModes(_THIS) hr = CreateDXGIFactory1(SDL_IID_IDXGIFactory2, (void **)&dxgiFactory2); if (FAILED(hr)) { - WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr); - return -1; + return WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr); } for (int adapterIndex = 0; ; ++adapterIndex) { @@ -630,14 +629,12 @@ WINRT_CreateWindow(_THIS, SDL_Window * window) // Make sure that only one window gets created, at least until multimonitor // support is added. if (WINRT_GlobalSDLWindow != NULL) { - SDL_SetError("WinRT only supports one window"); - return -1; + return SDL_SetError("WinRT only supports one window"); } SDL_WindowData *data = new SDL_WindowData; /* use 'new' here as SDL_WindowData may use WinRT/C++ types */ if (!data) { - SDL_OutOfMemory(); - return -1; + return SDL_OutOfMemory(); } window->driverdata = data; data->sdlWindow = window;