re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory

This commit is contained in:
pionere 2022-01-17 17:22:30 +01:00 committed by Ryan C. Gordon
parent ebdd536676
commit 60deadba59
18 changed files with 52 additions and 102 deletions

View File

@ -153,8 +153,7 @@ SDL_InitSubSystem(Uint32 flags)
Uint32 flags_initialized = 0; Uint32 flags_initialized = 0;
if (!SDL_MainIsReady) { if (!SDL_MainIsReady) {
SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"); return SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
return -1;
} }
/* Clear the error message */ /* Clear the error message */

View File

@ -1523,8 +1523,7 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
/* SDL_OpenAudio() is legacy and can only act on Device ID #1. */ /* SDL_OpenAudio() is legacy and can only act on Device ID #1. */
if (open_devices[0] != NULL) { if (open_devices[0] != NULL) {
SDL_SetError("Audio device is already opened"); return SDL_SetError("Audio device is already opened");
return -1;
} }
if (obtained) { if (obtained) {

View File

@ -1135,8 +1135,7 @@ COREAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
this->hidden->ready_semaphore = NULL; this->hidden->ready_semaphore = NULL;
if ((this->hidden->thread != NULL) && (this->hidden->thread_error != NULL)) { if ((this->hidden->thread != NULL) && (this->hidden->thread_error != NULL)) {
SDL_SetError("%s", this->hidden->thread_error); return SDL_SetError("%s", this->hidden->thread_error);
return -1;
} }
return (this->hidden->thread != NULL) ? 0 : -1; return (this->hidden->thread != NULL) ? 0 : -1;

View File

@ -492,8 +492,7 @@ SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
++index; ++index;
} }
SDL_SetError("Couldn't find joystick in haptic device list"); return SDL_SetError("Couldn't find joystick in haptic device list");
return -1;
} }
void void
@ -959,8 +958,7 @@ SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SD
REFGUID type = SDL_SYS_HapticEffectType(base); REFGUID type = SDL_SYS_HapticEffectType(base);
if (type == NULL) { if (type == NULL) {
SDL_SetError("Haptic: Unknown effect type."); return SDL_SetError("Haptic: Unknown effect type.");
return -1;
} }
/* Get the effect. */ /* Get the effect. */

View File

@ -246,8 +246,7 @@ SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
++index; ++index;
} }
SDL_SetError("Couldn't find joystick in haptic device list"); return SDL_SetError("Couldn't find joystick in haptic device list");
return -1;
} }
void void

View File

@ -454,8 +454,7 @@ HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo
} }
/* Should never get here! */ /* Should never get here! */
SDL_SetError("Couldn't find joystick"); return SDL_SetError("Couldn't find joystick");
return -1;
} }
static int static int

View File

@ -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; ctx->m_bRumbleActive = (low_frequency_rumble || high_frequency_rumble) ? SDL_TRUE : SDL_FALSE;
if (!WriteRumble(ctx)) { if (!WriteRumble(ctx)) {
SDL_SetError("Couldn't send rumble packet"); return SDL_SetError("Couldn't send rumble packet");
return -1;
} }
return 0; return 0;
} }

View File

@ -309,8 +309,7 @@ HIDAPI_JoystickInit(void)
#endif #endif
if (SDL_hid_init() < 0) { if (SDL_hid_init() < 0) {
SDL_SetError("Couldn't initialize hidapi"); return SDL_SetError("Couldn't initialize hidapi");
return -1;
} }
for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) { 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); result = device->driver->RumbleJoystick(device, joystick, low_frequency_rumble, high_frequency_rumble);
} else { } else {
SDL_SetError("Rumble failed, device disconnected"); result = SDL_SetError("Rumble failed, device disconnected");
result = -1;
} }
return result; 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); result = device->driver->RumbleJoystickTriggers(device, joystick, left_rumble, right_rumble);
} else { } else {
SDL_SetError("Rumble failed, device disconnected"); result = SDL_SetError("Rumble failed, device disconnected");
result = -1;
} }
return result; 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); result = device->driver->SetJoystickLED(device, joystick, red, green, blue);
} else { } else {
SDL_SetError("SetLED failed, device disconnected"); result = SDL_SetError("SetLED failed, device disconnected");
result = -1;
} }
return result; return result;
@ -936,8 +932,7 @@ HIDAPI_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
result = device->driver->SendJoystickEffect(device, joystick, data, size); result = device->driver->SendJoystickEffect(device, joystick, data, size);
} else { } else {
SDL_SetError("SendEffect failed, device disconnected"); result = SDL_SetError("SendEffect failed, device disconnected");
result = -1;
} }
return result; return result;
@ -953,8 +948,7 @@ HIDAPI_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
result = device->driver->SetJoystickSensorsEnabled(device, joystick, enabled); result = device->driver->SetJoystickSensorsEnabled(device, joystick, enabled);
} else { } else {
SDL_SetError("SetSensorsEnabled failed, device disconnected"); result = SDL_SetError("SetSensorsEnabled failed, device disconnected");
result = -1;
} }
return result; return result;

View File

@ -584,8 +584,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
if (!texturedata) { if (!texturedata) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) { 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; D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
if (!texturedata) { if (!texturedata) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { 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; IDirect3DDevice9 *device = data->device;
if (!texturedata) { if (!texturedata) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
texturedata->locked_rect = *rect; texturedata->locked_rect = *rect;
@ -756,8 +753,7 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
texturedata = (D3D_TextureData *)texture->driverdata; texturedata = (D3D_TextureData *)texture->driverdata;
if (!texturedata) { if (!texturedata) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
/* Make sure the render target is updated if it was locked and written to */ /* 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); SDL_assert(*shader == NULL);
if (!texturedata) { if (!texturedata) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
UpdateTextureScaleMode(data, texturedata, 0); UpdateTextureScaleMode(data, texturedata, 0);

View File

@ -1114,8 +1114,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
return -1;
} }
if (texture->format == SDL_PIXELFORMAT_YV12 || if (texture->format == SDL_PIXELFORMAT_YV12 ||
@ -1132,8 +1131,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
return -1;
} }
result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
@ -1143,8 +1141,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
return -1;
} }
} }
@ -1165,8 +1162,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
return -1;
} }
} }
@ -1181,8 +1177,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
return -1;
} }
if (textureData->yuv) { if (textureData->yuv) {
@ -1193,8 +1188,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
return -1;
} }
result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
(ID3D11Resource *)textureData->mainTextureV, (ID3D11Resource *)textureData->mainTextureV,
@ -1203,8 +1197,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
return -1;
} }
} }
@ -1220,8 +1213,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
); );
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
return -1;
} }
} }
@ -1237,8 +1229,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
&textureData->mainTextureRenderTargetView); &textureData->mainTextureRenderTargetView);
if (FAILED(result)) { if (FAILED(result)) {
D3D11_DestroyTexture(renderer, texture); D3D11_DestroyTexture(renderer, texture);
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result);
return -1;
} }
} }
@ -1295,8 +1286,7 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex
NULL, NULL,
&stagingTexture); &stagingTexture);
if (FAILED(result)) { if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
return -1;
} }
/* Get a write-only pointer to data in the staging texture: */ /* Get a write-only pointer to data in the staging texture: */
@ -1308,9 +1298,8 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex
&textureMemory &textureMemory
); );
if (FAILED(result)) { if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result);
SAFE_RELEASE(stagingTexture); SAFE_RELEASE(stagingTexture);
return -1; return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result);
} }
src = (const Uint8 *)pixels; src = (const Uint8 *)pixels;
@ -1362,8 +1351,7 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
if (!textureData) { if (!textureData) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) { 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; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
if (!textureData) { if (!textureData) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { 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; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
if (!textureData) { if (!textureData) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { 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; D3D11_MAPPED_SUBRESOURCE textureMemory;
if (!textureData) { if (!textureData) {
SDL_SetError("Texture is not currently available"); return SDL_SetError("Texture is not currently available");
return -1;
} }
if (textureData->yuv || textureData->nv12) { if (textureData->yuv || textureData->nv12) {
@ -1505,8 +1490,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
NULL, NULL,
&textureData->stagingTexture); &textureData->stagingTexture);
if (FAILED(result)) { if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result);
return -1;
} }
/* Get a write-only pointer to data in the staging texture: */ /* Get a write-only pointer to data in the staging texture: */
@ -1518,9 +1502,8 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
&textureMemory &textureMemory
); );
if (FAILED(result)) { if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result);
SAFE_RELEASE(textureData->stagingTexture); 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 /* Make note of where the staging texture will be written to
@ -1718,8 +1701,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
&mappedResource &mappedResource
); );
if (FAILED(result)) { if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result);
return -1;
} }
SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes); SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes);
ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexBuffers[vbidx], 0); ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexBuffers[vbidx], 0);
@ -1746,8 +1728,7 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
&rendererData->vertexBuffers[vbidx] &rendererData->vertexBuffers[vbidx]
); );
if (FAILED(result)) { if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result); return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result);
return -1;
} }
rendererData->vertexBufferSizes[vbidx] = dataSizeInBytes; rendererData->vertexBufferSizes[vbidx] = dataSizeInBytes;

View File

@ -442,8 +442,8 @@ TextureSpillLRU(PSP_RenderData* data, size_t wanted) {
} }
LRUTargetRemove(data, lru); LRUTargetRemove(data, lru);
} else { } else {
SDL_SetError("Could not spill more VRAM to system memory. VRAM : %dKB,(%dKB), wanted %dKB", vmemavail()/1024, vlargestblock()/1024, wanted/1024); // Asked to spill but there nothing to spill
return -1; //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; return 0;
} }

View File

@ -99,8 +99,7 @@ SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
return 0; return 0;
} }
SDL_SetError("Software renderer doesn't have an output surface"); return SDL_SetError("Software renderer doesn't have an output surface");
return -1;
} }
static int static int

View File

@ -52,11 +52,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread)
thread->handle = (void *) new std::thread(std::move(cpp_thread)); thread->handle = (void *) new std::thread(std::move(cpp_thread));
return 0; return 0;
} catch (std::system_error & ex) { } catch (std::system_error & ex) {
SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what()); return SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what());
return -1;
} catch (std::bad_alloc &) { } catch (std::bad_alloc &) {
SDL_OutOfMemory(); return SDL_OutOfMemory();
return -1;
} }
} }

View File

@ -1404,8 +1404,7 @@ int SDL_ConvertPixels(int width, int height,
} }
#else #else
if (SDL_ISPIXELFORMAT_FOURCC(src_format) || SDL_ISPIXELFORMAT_FOURCC(dst_format)) { if (SDL_ISPIXELFORMAT_FOURCC(src_format) || SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
SDL_SetError("SDL not built with YUV support"); return SDL_SetError("SDL not built with YUV support");
return -1;
} }
#endif #endif

View File

@ -1879,18 +1879,15 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
} }
if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) { if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Vulkan and OpenGL not supported on same window"); return SDL_SetError("Vulkan and OpenGL not supported on same window");
return -1;
} }
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) { if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Metal and OpenGL not supported on same window"); return SDL_SetError("Metal and OpenGL not supported on same window");
return -1;
} }
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) { if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) {
SDL_SetError("Metal and Vulkan not supported on same window"); return SDL_SetError("Metal and Vulkan not supported on same window");
return -1;
} }
if (need_gl_unload) { if (need_gl_unload) {

View File

@ -35,8 +35,7 @@ NACL_CreateWindow(_THIS, SDL_Window * window)
SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata; SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata;
if (driverdata->window) { if (driverdata->window) {
SDL_SetError("NaCl only supports one window"); return SDL_SetError("NaCl only supports one window");
return -1;
} }
driverdata->window = window; driverdata->window = window;

View File

@ -259,8 +259,7 @@ VITA_CreateWindow(_THIS, SDL_Window * window)
// Vita can only have one window // Vita can only have one window
if (Vita_Window != NULL) if (Vita_Window != NULL)
{ {
SDL_SetError("Only one window supported"); return SDL_SetError("Only one window supported");
return -1;
} }
Vita_Window = window; Vita_Window = window;

View File

@ -478,8 +478,7 @@ WINRT_InitModes(_THIS)
hr = CreateDXGIFactory1(SDL_IID_IDXGIFactory2, (void **)&dxgiFactory2); hr = CreateDXGIFactory1(SDL_IID_IDXGIFactory2, (void **)&dxgiFactory2);
if (FAILED(hr)) { if (FAILED(hr)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr); return WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr);
return -1;
} }
for (int adapterIndex = 0; ; ++adapterIndex) { 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 // Make sure that only one window gets created, at least until multimonitor
// support is added. // support is added.
if (WINRT_GlobalSDLWindow != NULL) { if (WINRT_GlobalSDLWindow != NULL) {
SDL_SetError("WinRT only supports one window"); return SDL_SetError("WinRT only supports one window");
return -1;
} }
SDL_WindowData *data = new SDL_WindowData; /* use 'new' here as SDL_WindowData may use WinRT/C++ types */ SDL_WindowData *data = new SDL_WindowData; /* use 'new' here as SDL_WindowData may use WinRT/C++ types */
if (!data) { if (!data) {
SDL_OutOfMemory(); return SDL_OutOfMemory();
return -1;
} }
window->driverdata = data; window->driverdata = data;
data->sdlWindow = window; data->sdlWindow = window;