mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-13 13:25:59 +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
This commit is contained in:
@@ -120,7 +120,7 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
|
||||
SDL_Palette *palette =
|
||||
SDL_AllocPalette((1 << surface->format->BitsPerPixel));
|
||||
if (!palette) {
|
||||
if (palette == NULL) {
|
||||
SDL_FreeSurface(surface);
|
||||
return NULL;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
|
||||
int
|
||||
SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette)
|
||||
{
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface");
|
||||
}
|
||||
if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
|
||||
@@ -307,7 +307,7 @@ SDL_SetSurfaceRLE(SDL_Surface * surface, int flag)
|
||||
{
|
||||
int flags;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ SDL_SetSurfaceRLE(SDL_Surface * surface, int flag)
|
||||
SDL_bool
|
||||
SDL_HasSurfaceRLE(SDL_Surface * surface)
|
||||
{
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
|
||||
{
|
||||
int flags;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return SDL_InvalidParamError("surface");
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
|
||||
SDL_bool
|
||||
SDL_HasColorKey(SDL_Surface * surface)
|
||||
{
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ SDL_HasColorKey(SDL_Surface * surface)
|
||||
int
|
||||
SDL_GetColorKey(SDL_Surface * surface, Uint32 * key)
|
||||
{
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return SDL_InvalidParamError("surface");
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha)
|
||||
{
|
||||
int x, y, bpp;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b)
|
||||
{
|
||||
int flags;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b)
|
||||
int
|
||||
SDL_GetSurfaceColorMod(SDL_Surface * surface, Uint8 * r, Uint8 * g, Uint8 * b)
|
||||
{
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ SDL_SetSurfaceAlphaMod(SDL_Surface * surface, Uint8 alpha)
|
||||
{
|
||||
int flags;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ SDL_SetSurfaceAlphaMod(SDL_Surface * surface, Uint8 alpha)
|
||||
int
|
||||
SDL_GetSurfaceAlphaMod(SDL_Surface * surface, Uint8 * alpha)
|
||||
{
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode)
|
||||
{
|
||||
int flags, status;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -615,11 +615,11 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode)
|
||||
int
|
||||
SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode)
|
||||
{
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!blendMode) {
|
||||
if (blendMode == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect)
|
||||
SDL_Rect full_rect;
|
||||
|
||||
/* Don't do anything if there's no surface to act on */
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect)
|
||||
full_rect.h = surface->h;
|
||||
|
||||
/* Set the clipping rectangle */
|
||||
if (!rect) {
|
||||
if (rect == NULL) {
|
||||
surface->clip_rect = full_rect;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
@@ -698,7 +698,7 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
(src->format->palette &&
|
||||
src->map->src_palette_version != src->format->palette->version)) {
|
||||
if (SDL_MapSurface(src, dst) < 0) {
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
/* just here for debugging */
|
||||
/* printf */
|
||||
@@ -706,7 +706,7 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
/* src, dst->flags, src->map->info.flags, dst, dst->flags, */
|
||||
/* dst->map->info.flags, src->map->blit); */
|
||||
}
|
||||
return (src->map->blit(src, srcrect, dst, dstrect));
|
||||
return src->map->blit(src, srcrect, dst, dstrect);
|
||||
}
|
||||
|
||||
|
||||
@@ -718,7 +718,7 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
int srcx, srcy, w, h;
|
||||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if (!src || !dst) {
|
||||
if (src == NULL || dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_UpperBlit(): src/dst");
|
||||
}
|
||||
if (src->locked || dst->locked) {
|
||||
@@ -745,8 +745,9 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
srcx = 0;
|
||||
}
|
||||
maxw = src->w - srcx;
|
||||
if (maxw < w)
|
||||
if (maxw < w) {
|
||||
w = maxw;
|
||||
}
|
||||
|
||||
srcy = srcrect->y;
|
||||
h = srcrect->h;
|
||||
@@ -756,8 +757,9 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
srcy = 0;
|
||||
}
|
||||
maxh = src->h - srcy;
|
||||
if (maxh < h)
|
||||
if (maxh < h) {
|
||||
h = maxh;
|
||||
}
|
||||
|
||||
} else {
|
||||
srcx = srcy = 0;
|
||||
@@ -777,8 +779,9 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
srcx += dx;
|
||||
}
|
||||
dx = dstrect->x + w - clip->x - clip->w;
|
||||
if (dx > 0)
|
||||
if (dx > 0) {
|
||||
w -= dx;
|
||||
}
|
||||
|
||||
dy = clip->y - dstrect->y;
|
||||
if (dy > 0) {
|
||||
@@ -787,8 +790,9 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
srcy += dy;
|
||||
}
|
||||
dy = dstrect->y + h - clip->y - clip->h;
|
||||
if (dy > 0)
|
||||
if (dy > 0) {
|
||||
h -= dy;
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch back to a fast blit if we were previously stretching */
|
||||
@@ -829,14 +833,14 @@ SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
int dst_w, dst_h;
|
||||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if (!src || !dst) {
|
||||
if (src == NULL || dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_UpperBlitScaled(): src/dst");
|
||||
}
|
||||
if (src->locked || dst->locked) {
|
||||
return SDL_SetError("Surfaces must not be locked during blit");
|
||||
}
|
||||
|
||||
if (NULL == srcrect) {
|
||||
if (srcrect == NULL) {
|
||||
src_w = src->w;
|
||||
src_h = src->h;
|
||||
} else {
|
||||
@@ -844,7 +848,7 @@ SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
src_h = srcrect->h;
|
||||
}
|
||||
|
||||
if (NULL == dstrect) {
|
||||
if (dstrect == NULL) {
|
||||
dst_w = dst->w;
|
||||
dst_h = dst->h;
|
||||
} else {
|
||||
@@ -860,7 +864,7 @@ SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
scaling_w = (double)dst_w / src_w;
|
||||
scaling_h = (double)dst_h / src_h;
|
||||
|
||||
if (NULL == dstrect) {
|
||||
if (dstrect == NULL) {
|
||||
dst_x0 = 0;
|
||||
dst_y0 = 0;
|
||||
dst_x1 = dst_w;
|
||||
@@ -872,7 +876,7 @@ SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
dst_y1 = dst_y0 + dst_h;
|
||||
}
|
||||
|
||||
if (NULL == srcrect) {
|
||||
if (srcrect == NULL) {
|
||||
src_x0 = 0;
|
||||
src_y0 = 0;
|
||||
src_x1 = src_w;
|
||||
@@ -1011,9 +1015,9 @@ SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
if ( !(src->map->info.flags & complex_copy_flags) &&
|
||||
src->format->format == dst->format->format &&
|
||||
!SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) {
|
||||
return SDL_SoftStretch( src, srcrect, dst, dstrect );
|
||||
return SDL_SoftStretch(src, srcrect, dst, dstrect);
|
||||
} else {
|
||||
return SDL_LowerBlit( src, srcrect, dst, dstrect );
|
||||
return SDL_LowerBlit(src, srcrect, dst, dstrect);
|
||||
}
|
||||
} else {
|
||||
if ( !(src->map->info.flags & complex_copy_flags) &&
|
||||
@@ -1117,7 +1121,7 @@ SDL_LockSurface(SDL_Surface * surface)
|
||||
++surface->locked;
|
||||
|
||||
/* Ready to go.. */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1167,11 +1171,11 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
Uint8 *palette_saved_alpha = NULL;
|
||||
int palette_saved_alpha_ncolors = 0;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
SDL_InvalidParamError("surface");
|
||||
return NULL;
|
||||
}
|
||||
if (!format) {
|
||||
if (format == NULL) {
|
||||
SDL_InvalidParamError("format");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1180,14 +1184,13 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
if (format->palette != NULL) {
|
||||
int i;
|
||||
for (i = 0; i < format->palette->ncolors; ++i) {
|
||||
if ((format->palette->colors[i].r != 0xFF) ||
|
||||
(format->palette->colors[i].g != 0xFF) ||
|
||||
(format->palette->colors[i].b != 0xFF))
|
||||
if ((format->palette->colors[i].r != 0xFF) || (format->palette->colors[i].g != 0xFF) || (format->palette->colors[i].b != 0xFF)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == format->palette->ncolors) {
|
||||
SDL_SetError("Empty destination palette");
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1197,7 +1200,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
format->Gmask, format->Bmask,
|
||||
format->Amask);
|
||||
if (convert == NULL) {
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Copy the palette if any */
|
||||
@@ -1383,7 +1386,7 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
|
||||
}
|
||||
|
||||
/* We're ready to go! */
|
||||
return (convert);
|
||||
return convert;
|
||||
}
|
||||
|
||||
SDL_Surface *
|
||||
@@ -1454,13 +1457,13 @@ int SDL_ConvertPixels(int width, int height,
|
||||
void *nonconst_src = (void *) src;
|
||||
int ret;
|
||||
|
||||
if (!src) {
|
||||
if (src == NULL) {
|
||||
return SDL_InvalidParamError("src");
|
||||
}
|
||||
if (!src_pitch) {
|
||||
return SDL_InvalidParamError("src_pitch");
|
||||
}
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("dst");
|
||||
}
|
||||
if (!dst_pitch) {
|
||||
@@ -1536,13 +1539,13 @@ int SDL_PremultiplyAlpha(int width, int height,
|
||||
Uint32 dstpixel;
|
||||
Uint32 dstR, dstG, dstB, dstA;
|
||||
|
||||
if (!src) {
|
||||
if (src == NULL) {
|
||||
return SDL_InvalidParamError("src");
|
||||
}
|
||||
if (!src_pitch) {
|
||||
return SDL_InvalidParamError("src_pitch");
|
||||
}
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("dst");
|
||||
}
|
||||
if (!dst_pitch) {
|
||||
|
Reference in New Issue
Block a user