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:
Sylvain Becker
2022-11-27 17:38:43 +01:00
committed by GitHub
parent 4958dafdc3
commit 6a2200823c
387 changed files with 6094 additions and 4633 deletions

View File

@@ -57,7 +57,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma
/* Create a new one */
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
if (! surface) {
if (surface == NULL) {
return -1;
}
@@ -98,21 +98,16 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma
*
* In 12 bpp machines the table has 16 entries.
*/
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 8)
{
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 8) {
phdata->NGAGE_FrameBuffer += 512;
}
else
{
} else {
phdata->NGAGE_FrameBuffer += 32;
}
#if 0
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12)
{
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12) {
phdata->NGAGE_FrameBuffer += 16 * 2;
}
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16)
{
if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16) {
phdata->NGAGE_FrameBuffer += 16 * 2;
}
#endif
@@ -154,14 +149,12 @@ int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect
SDL_Surface *surface;
surface = (SDL_Surface *) SDL_GetWindowData(window, NGAGE_SURFACE);
if (! surface)
{
if (surface == NULL) {
return SDL_SetError("Couldn't find ngage surface for window");
}
/* Send the data to the display */
if (SDL_getenv("SDL_VIDEO_NGAGE_SAVE_FRAMES"))
{
if (SDL_getenv("SDL_VIDEO_NGAGE_SAVE_FRAMES")) {
char file[128];
SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
(int)SDL_GetWindowID(window), ++frame_number);
@@ -231,8 +224,7 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
/* Render the rectangles in the list */
for (i = 0; i < numrects; ++i)
{
for (i = 0; i < numrects; ++i) {
const SDL_Rect& currentRect = rects[i];
SDL_Rect rect2;
rect2.x = currentRect.x;
@@ -240,8 +232,7 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
rect2.w = currentRect.w;
rect2.h = currentRect.h;
if (rect2.w <= 0 || rect2.h <= 0) /* Sanity check */
{
if (rect2.w <= 0 || rect2.h <= 0) /* Sanity check */ {
continue;
}
@@ -250,8 +241,7 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
/* Check rects validity, i.e. upper and lower bounds */
TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1);
TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1);
if (maxX < 0 || maxY < 0) /* sanity check */
{
if (maxX < 0 || maxY < 0) /* sanity check */ {
continue;
}
/* Clip from bottom */
@@ -274,22 +264,19 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
TUint16* bitmapLine = (TUint16*)screen->pixels + sourceStartOffset;
TUint16* screenMemory = screenBuffer + targetStartOffset;
if (skipValue == 1)
{
for(TInt y = 0 ; y < sourceRectHeight ; y++)
if (skipValue == 1) {
for (TInt y = 0 ; y < sourceRectHeight ; y++)
{
Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes);
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
else
{
for(TInt y = 0 ; y < sourceRectHeight ; y++)
} else {
for (TInt y = 0 ; y < sourceRectHeight ; y++)
{
TUint16* bitmapPos = bitmapLine; /* 2 bytes per pixel */
TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
for(TInt x = 0 ; x < sourceRectWidth ; x++)
for (TInt x = 0 ; x < sourceRectWidth ; x++)
{
__ASSERT_DEBUG(screenMemory < (screenBuffer + phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
@@ -308,17 +295,16 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
// 256 color paletted mode: 8 bpp --> 12 bpp
default:
{
if(phdata->NGAGE_BytesPerPixel <= 2)
{
if (phdata->NGAGE_BytesPerPixel <= 2) {
TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset;
TUint16* screenMemory = screenBuffer + targetStartOffset;
for(TInt y = 0 ; y < sourceRectHeight ; y++)
for (TInt y = 0 ; y < sourceRectHeight ; y++)
{
TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
TUint16* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
/* Convert each pixel from 256 palette to 4k color values */
for(TInt x = 0 ; x < sourceRectWidth ; x++)
for (TInt x = 0 ; x < sourceRectWidth ; x++)
{
__ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt));
@@ -329,17 +315,15 @@ void DirectDraw(_THIS, int numrects, SDL_Rect *rects, TUint16* screenBuffer)
bitmapLine += sourceScanlineLength;
screenMemory += targetScanlineLength;
}
}
else
{
} else {
TUint8* bitmapLine = (TUint8*)screen->pixels + sourceStartOffset;
TUint32* screenMemory = reinterpret_cast<TUint32*>(screenBuffer + targetStartOffset);
for(TInt y = 0 ; y < sourceRectHeight ; y++)
for (TInt y = 0 ; y < sourceRectHeight ; y++)
{
TUint8* bitmapPos = bitmapLine; /* 1 byte per pixel */
TUint32* screenMemoryLinePos = screenMemory; /* 2 bytes per pixel */
/* Convert each pixel from 256 palette to 4k color values */
for(TInt x = 0 ; x < sourceRectWidth ; x++)
for (TInt x = 0 ; x < sourceRectWidth ; x++)
{
__ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast<TUint32*>(screenBuffer) + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt));
__ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast<TUint32*>(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt));
@@ -360,8 +344,7 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
{
SDL_VideoData *phdata = (SDL_VideoData*)_this->driverdata;
if (! phdata->NGAGE_IsWindowFocused)
{
if (! phdata->NGAGE_IsWindowFocused) {
SDL_PauseAudio(1);
SDL_Delay(1000);
return;
@@ -372,18 +355,15 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer;
#if 0
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270)
{
if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) {
// ...
}
else
} else
#endif
{
DirectDraw(_this, numrects, rects, screenBuffer);
}
for (int i = 0; i < numrects; ++i)
{
for (int i = 0; i < numrects; ++i) {
TInt aAx = rects[i].x;
TInt aAy = rects[i].y;
TInt aBx = rects[i].w;