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
|
@ -82,9 +82,8 @@ int
|
|||
SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
|
||||
{
|
||||
if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
|
||||
SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumRenderDrivers() - 1);
|
||||
return -1;
|
||||
return SDL_SetError("index must be in the range of 0 - %d",
|
||||
SDL_GetNumRenderDrivers() - 1);
|
||||
}
|
||||
*info = render_drivers[index]->info;
|
||||
return 0;
|
||||
|
@ -695,8 +694,7 @@ SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
rect->w, rect->h, temp_pixels, temp_pitch);
|
||||
|
@ -732,8 +730,7 @@ SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (!temp_pixels) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
texture->format, pixels, pitch,
|
||||
|
@ -800,8 +797,7 @@ SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
|
||||
SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
}
|
||||
|
||||
if (!rect) {
|
||||
|
@ -897,8 +893,7 @@ int
|
|||
SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
if (!SDL_RenderTargetSupported(renderer)) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
if (texture == renderer->target) {
|
||||
/* Nothing to do! */
|
||||
|
@ -909,12 +904,10 @@ SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
if (texture) {
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
if (texture->access != SDL_TEXTUREACCESS_TARGET) {
|
||||
SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
|
||||
return -1;
|
||||
return SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
|
||||
}
|
||||
if (texture->native) {
|
||||
/* Always render to the native texture */
|
||||
|
@ -979,8 +972,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
|
|||
SDL_GetWindowSize(renderer->window, &w, &h);
|
||||
} else {
|
||||
/* FIXME */
|
||||
SDL_SetError("Internal error: No way to get output resolution");
|
||||
return -1;
|
||||
return SDL_SetError("Internal error: No way to get output resolution");
|
||||
}
|
||||
|
||||
want_aspect = (float)renderer->logical_w / renderer->logical_h;
|
||||
|
@ -1198,8 +1190,7 @@ RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
frects[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1226,8 +1217,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1243,8 +1233,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
|
||||
fpoints = SDL_stack_alloc(SDL_FPoint, count);
|
||||
if (!fpoints) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
fpoints[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1282,8 +1271,7 @@ RenderDrawLinesWithRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count-1);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
status = 0;
|
||||
|
@ -1338,8 +1326,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
|
||||
}
|
||||
if (count < 2) {
|
||||
return 0;
|
||||
|
@ -1355,8 +1342,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
|
||||
fpoints = SDL_stack_alloc(SDL_FPoint, count);
|
||||
if (!fpoints) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
fpoints[i].x = points[i].x * renderer->scale.x;
|
||||
|
@ -1408,8 +1394,7 @@ SDL_RenderDrawRects(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1455,8 +1440,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
|
||||
return -1;
|
||||
return SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
return 0;
|
||||
|
@ -1468,8 +1452,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
|
||||
frects = SDL_stack_alloc(SDL_FRect, count);
|
||||
if (!frects) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
frects[i].x = rects[i].x * renderer->scale.x;
|
||||
|
@ -1497,8 +1480,7 @@ SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
|
@ -1566,12 +1548,10 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (renderer != texture->renderer) {
|
||||
SDL_SetError("Texture was not created with this renderer");
|
||||
return -1;
|
||||
return SDL_SetError("Texture was not created with this renderer");
|
||||
}
|
||||
if (!renderer->RenderCopyEx) {
|
||||
SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
return -1;
|
||||
return SDL_SetError("Renderer does not support RenderCopyEx");
|
||||
}
|
||||
|
||||
real_srcrect.x = 0;
|
||||
|
@ -1623,8 +1603,7 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!renderer->RenderReadPixels) {
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
if (!format) {
|
||||
|
@ -1729,8 +1708,7 @@ int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
|
|||
return renderer->GL_BindTexture(renderer, texture, texw, texh);
|
||||
}
|
||||
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
int SDL_GL_UnbindTexture(SDL_Texture *texture)
|
||||
|
@ -1743,8 +1721,7 @@ int SDL_GL_UnbindTexture(SDL_Texture *texture)
|
|||
return renderer->GL_UnbindTexture(renderer, texture);
|
||||
}
|
||||
|
||||
SDL_Unsupported();
|
||||
return -1;
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue