mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-22 20:58:29 +00:00
Cleanup add brace (#6545)
* Add braces after if conditions
* More add braces after if conditions
* Add braces after while() conditions
* Fix compilation because of macro being modified
* Add braces to for loop
* Add braces after if/goto
* Move comments up
* Remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements after merge
* Fix inconsistent patterns are xxx == NULL vs !xxx
* More "{}" for "if() break;" and "if() continue;"
* More "{}" after if() short statement
* More "{}" after "if () return;" statement
* More fix inconsistent patterns are xxx == NULL vs !xxx
* Revert some modificaion on SDL_RLEaccel.c
* SDL_RLEaccel: no short statement
* Cleanup 'if' where the bracket is in a new line
* Cleanup 'while' where the bracket is in a new line
* Cleanup 'for' where the bracket is in a new line
* Cleanup 'else' where the bracket is in a new line
(cherry picked from commit 6a2200823c
to reduce conflicts merging between SDL2 and SDL3)
This commit is contained in:
parent
0739d237ad
commit
fb0ce375f0
386 changed files with 6103 additions and 4637 deletions
|
@ -336,7 +336,7 @@ AllocateRenderCommand(SDL_Renderer *renderer)
|
|||
retval->next = NULL;
|
||||
} else {
|
||||
retval = SDL_calloc(1, sizeof (*retval));
|
||||
if (!retval) {
|
||||
if (retval == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
|||
Android_ActivityMutex_Lock_Running();
|
||||
#endif
|
||||
|
||||
if (!window) {
|
||||
if (window == NULL) {
|
||||
SDL_InvalidParamError("window");
|
||||
goto error;
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
|||
}
|
||||
}
|
||||
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
for (index = 0; index < n; ++index) {
|
||||
const SDL_RenderDriver *driver = render_drivers[index];
|
||||
|
||||
|
@ -1019,7 +1019,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_SetError("Couldn't find matching render driver");
|
||||
goto error;
|
||||
}
|
||||
|
@ -1032,7 +1032,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
|||
/* Create a new renderer instance */
|
||||
renderer = render_drivers[index]->CreateRenderer(window, flags);
|
||||
batching = SDL_FALSE;
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -1257,7 +1257,7 @@ static SDL_ScaleMode SDL_GetScaleMode(void)
|
|||
{
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
|
||||
|
||||
if (!hint || SDL_strcasecmp(hint, "nearest") == 0) {
|
||||
if (hint == NULL || SDL_strcasecmp(hint, "nearest") == 0) {
|
||||
return SDL_ScaleModeNearest;
|
||||
} else if (SDL_strcasecmp(hint, "linear") == 0) {
|
||||
return SDL_ScaleModeLinear;
|
||||
|
@ -1299,7 +1299,7 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int
|
|||
return NULL;
|
||||
}
|
||||
texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
|
||||
if (!texture) {
|
||||
if (texture == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1391,7 +1391,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, NULL);
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
SDL_InvalidParamError("SDL_CreateTextureFromSurface(): surface");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1455,7 +1455,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
|||
|
||||
texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
|
||||
surface->w, surface->h);
|
||||
if (!texture) {
|
||||
if (texture == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1499,7 +1499,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
|||
|
||||
/* Set up a destination surface for the texture update */
|
||||
dst_fmt = SDL_AllocFormat(format);
|
||||
if (!dst_fmt) {
|
||||
if (dst_fmt == NULL) {
|
||||
SDL_DestroyTexture(texture);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1730,7 +1730,7 @@ SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
|
@ -1771,7 +1771,7 @@ SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
|
@ -1792,7 +1792,7 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (!pixels) {
|
||||
if (pixels == NULL) {
|
||||
return SDL_InvalidParamError("pixels");
|
||||
}
|
||||
if (!pitch) {
|
||||
|
@ -1867,7 +1867,7 @@ SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
|
@ -1918,7 +1918,7 @@ SDL_UpdateTextureNVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
|
@ -1944,19 +1944,19 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (!Yplane) {
|
||||
if (Yplane == NULL) {
|
||||
return SDL_InvalidParamError("Yplane");
|
||||
}
|
||||
if (!Ypitch) {
|
||||
return SDL_InvalidParamError("Ypitch");
|
||||
}
|
||||
if (!Uplane) {
|
||||
if (Uplane == NULL) {
|
||||
return SDL_InvalidParamError("Uplane");
|
||||
}
|
||||
if (!Upitch) {
|
||||
return SDL_InvalidParamError("Upitch");
|
||||
}
|
||||
if (!Vplane) {
|
||||
if (Vplane == NULL) {
|
||||
return SDL_InvalidParamError("Vplane");
|
||||
}
|
||||
if (!Vpitch) {
|
||||
|
@ -2010,13 +2010,13 @@ int SDL_UpdateNVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (!Yplane) {
|
||||
if (Yplane == NULL) {
|
||||
return SDL_InvalidParamError("Yplane");
|
||||
}
|
||||
if (!Ypitch) {
|
||||
return SDL_InvalidParamError("Ypitch");
|
||||
}
|
||||
if (!UVplane) {
|
||||
if (UVplane == NULL) {
|
||||
return SDL_InvalidParamError("UVplane");
|
||||
}
|
||||
if (!UVpitch) {
|
||||
|
@ -2095,7 +2095,7 @@ SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
|||
return SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
}
|
||||
|
||||
if (!rect) {
|
||||
if (rect == NULL) {
|
||||
full_rect.x = 0;
|
||||
full_rect.y = 0;
|
||||
full_rect.w = texture->w;
|
||||
|
@ -2230,7 +2230,7 @@ SDL_UnlockTexture(SDL_Texture * texture)
|
|||
SDL_bool
|
||||
SDL_RenderTargetSupported(SDL_Renderer *renderer)
|
||||
{
|
||||
if (!renderer || !renderer->SetRenderTarget) {
|
||||
if (renderer == NULL || !renderer->SetRenderTarget) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0;
|
||||
|
@ -2344,7 +2344,7 @@ UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd)
|
|||
}
|
||||
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE);
|
||||
if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)) {
|
||||
if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)) {
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
SDL_bool overscan_supported = SDL_TRUE;
|
||||
/* Unfortunately, Direct3D 9 doesn't support negative viewport numbers
|
||||
|
@ -2742,7 +2742,7 @@ RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
|||
}
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
|
@ -2771,7 +2771,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawPoints(): points");
|
||||
}
|
||||
if (count < 1) {
|
||||
|
@ -2789,7 +2789,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
|||
retval = RenderDrawPointsWithRects(renderer, points, count);
|
||||
} else {
|
||||
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
|
||||
if (!fpoints) {
|
||||
if (fpoints == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
|
@ -2818,7 +2818,7 @@ RenderDrawPointsWithRectsF(SDL_Renderer * renderer,
|
|||
}
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
|
@ -2844,7 +2844,7 @@ SDL_RenderDrawPointsF(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawPointsF(): points");
|
||||
}
|
||||
if (count < 1) {
|
||||
|
@ -2938,7 +2938,7 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x
|
|||
}
|
||||
|
||||
points = SDL_small_alloc(SDL_FPoint, numpixels, &isstack);
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < numpixels; ++i) {
|
||||
|
@ -2982,7 +2982,7 @@ RenderDrawLinesWithRectsF(SDL_Renderer * renderer,
|
|||
SDL_bool draw_last = SDL_FALSE;
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count-1, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
|
@ -3053,7 +3053,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawLines(): points");
|
||||
}
|
||||
if (count < 2) {
|
||||
|
@ -3068,7 +3068,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
|||
#endif
|
||||
|
||||
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
|
||||
if (!fpoints) {
|
||||
if (fpoints == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
|
@ -3092,7 +3092,7 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawLinesF(): points");
|
||||
}
|
||||
if (count < 2) {
|
||||
|
@ -3266,7 +3266,7 @@ SDL_RenderDrawRectF(SDL_Renderer * renderer, const SDL_FRect * rect)
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (!rect) {
|
||||
if (rect == NULL) {
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
|
@ -3292,7 +3292,7 @@ SDL_RenderDrawRects(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawRects(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
|
@ -3322,7 +3322,7 @@ SDL_RenderDrawRectsF(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawRectsF(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
|
@ -3371,7 +3371,7 @@ SDL_RenderFillRectF(SDL_Renderer * renderer, const SDL_FRect * rect)
|
|||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (!rect) {
|
||||
if (rect == NULL) {
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
|
@ -3389,7 +3389,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderFillRects(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
|
@ -3404,7 +3404,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
|||
#endif
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
|
@ -3432,7 +3432,7 @@ SDL_RenderFillRectsF(SDL_Renderer * renderer,
|
|||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderFillRectsF(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
|
@ -3447,7 +3447,7 @@ SDL_RenderFillRectsF(SDL_Renderer * renderer,
|
|||
#endif
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
|
@ -3999,7 +3999,7 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||
x2 = xy2_[0]; y2 = xy2_[1];
|
||||
|
||||
/* Check if triangle A B C is rectangle */
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)){
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) {
|
||||
/* ok */
|
||||
} else {
|
||||
is_quad = 0;
|
||||
|
@ -4012,7 +4012,7 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||
x2 = xy2_[0]; y2 = xy2_[1];
|
||||
|
||||
/* Check if triangle A B C2 is rectangle */
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)){
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) {
|
||||
/* ok */
|
||||
} else {
|
||||
is_quad = 0;
|
||||
|
@ -4121,7 +4121,7 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||
prev[1] = k1;
|
||||
prev[2] = k2;
|
||||
}
|
||||
} /* End for(), next triangle */
|
||||
} /* End for (), next triangle */
|
||||
|
||||
if (prev[0] != -1) {
|
||||
/* flush the last triangle */
|
||||
|
@ -4173,15 +4173,15 @@ SDL_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||
}
|
||||
}
|
||||
|
||||
if (!xy) {
|
||||
if (xy == NULL) {
|
||||
return SDL_InvalidParamError("xy");
|
||||
}
|
||||
|
||||
if (!color) {
|
||||
if (color == NULL) {
|
||||
return SDL_InvalidParamError("color");
|
||||
}
|
||||
|
||||
if (texture && !uv) {
|
||||
if (texture && uv == NULL) {
|
||||
return SDL_InvalidParamError("uv");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue