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
|
@ -87,8 +87,9 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
DWORD must_exist, truncate;
|
||||
int a_mode;
|
||||
|
||||
if (!context)
|
||||
return -1; /* failed (invalid call) */
|
||||
if (context == NULL) {
|
||||
return -1; /* failed (invalid call) */
|
||||
}
|
||||
|
||||
context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
|
||||
context->hidden.windowsio.buffer.data = NULL;
|
||||
|
@ -110,8 +111,10 @@ windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
w_right = (a_mode || SDL_strchr(mode, '+')
|
||||
|| truncate) ? GENERIC_WRITE : 0;
|
||||
|
||||
if (!r_right && !w_right) /* inconsistent mode */
|
||||
return -1; /* failed (invalid call) */
|
||||
if (!r_right && !w_right) {
|
||||
return -1; /* inconsistent mode */
|
||||
}
|
||||
/* failed (invalid call) */
|
||||
|
||||
context->hidden.windowsio.buffer.data =
|
||||
(char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
|
||||
|
@ -155,7 +158,7 @@ windows_file_size(SDL_RWops * context)
|
|||
{
|
||||
LARGE_INTEGER size;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
return SDL_SetError("windows_file_size: invalid context/file not opened");
|
||||
}
|
||||
|
||||
|
@ -172,7 +175,7 @@ windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
|
|||
DWORD windowswhence;
|
||||
LARGE_INTEGER windowsoffset;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
|
||||
return SDL_SetError("windows_file_seek: invalid context/file not opened");
|
||||
}
|
||||
|
||||
|
@ -213,7 +216,7 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
|
||||
total_need = size * maxnum;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) {
|
||||
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -254,7 +257,7 @@ windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
}
|
||||
total_read += byte_read;
|
||||
}
|
||||
return (total_read / size);
|
||||
return total_read / size;
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
|
@ -268,7 +271,7 @@ windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
|||
|
||||
total_bytes = size * num;
|
||||
|
||||
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) {
|
||||
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -501,7 +504,7 @@ mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
|
||||
context->hidden.mem.here += total_bytes;
|
||||
|
||||
return (total_bytes / size);
|
||||
return total_bytes / size;
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
|
@ -538,7 +541,7 @@ SDL_RWops *
|
|||
SDL_RWFromFile(const char *file, const char *mode)
|
||||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
if (!file || !*file || !mode || !*mode) {
|
||||
if (file == NULL || !*file || mode == NULL || !*mode) {
|
||||
SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -571,8 +574,10 @@ SDL_RWFromFile(const char *file, const char *mode)
|
|||
|
||||
/* Try to open the file from the asset system */
|
||||
rwops = SDL_AllocRW();
|
||||
if (!rwops)
|
||||
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
|
||||
if (rwops == NULL) {
|
||||
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
|
||||
}
|
||||
|
||||
if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
|
||||
SDL_FreeRW(rwops);
|
||||
return NULL;
|
||||
|
@ -586,8 +591,10 @@ SDL_RWFromFile(const char *file, const char *mode)
|
|||
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
rwops = SDL_AllocRW();
|
||||
if (!rwops)
|
||||
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
|
||||
if (rwops == NULL) {
|
||||
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
|
||||
}
|
||||
|
||||
if (windows_file_open(rwops, file, mode) < 0) {
|
||||
SDL_FreeRW(rwops);
|
||||
return NULL;
|
||||
|
@ -655,7 +662,7 @@ SDL_RWops *
|
|||
SDL_RWFromMem(void *mem, int size)
|
||||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
if (!mem) {
|
||||
if (mem == NULL) {
|
||||
SDL_InvalidParamError("mem");
|
||||
return rwops;
|
||||
}
|
||||
|
@ -683,7 +690,7 @@ SDL_RWops *
|
|||
SDL_RWFromConstMem(const void *mem, int size)
|
||||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
if (!mem) {
|
||||
if (mem == NULL) {
|
||||
SDL_InvalidParamError("mem");
|
||||
return rwops;
|
||||
}
|
||||
|
@ -736,7 +743,7 @@ SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, int freesrc)
|
|||
size_t size_read, size_total;
|
||||
void *data = NULL, *newdata;
|
||||
|
||||
if (!src) {
|
||||
if (src == NULL) {
|
||||
SDL_InvalidParamError("src");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -752,7 +759,7 @@ SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, int freesrc)
|
|||
if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) {
|
||||
size = (size_total + FILE_CHUNK_SIZE);
|
||||
newdata = SDL_realloc(data, (size_t)(size + 1));
|
||||
if (!newdata) {
|
||||
if (newdata == NULL) {
|
||||
SDL_free(data);
|
||||
data = NULL;
|
||||
SDL_OutOfMemory();
|
||||
|
@ -890,49 +897,49 @@ SDL_ReadBE64(SDL_RWops * src)
|
|||
size_t
|
||||
SDL_WriteU8(SDL_RWops * dst, Uint8 value)
|
||||
{
|
||||
return SDL_RWwrite(dst, &value, sizeof (value), 1);
|
||||
return SDL_RWwrite(dst, &value, sizeof(value), 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_WriteLE16(SDL_RWops * dst, Uint16 value)
|
||||
{
|
||||
const Uint16 swapped = SDL_SwapLE16(value);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_WriteBE16(SDL_RWops * dst, Uint16 value)
|
||||
{
|
||||
const Uint16 swapped = SDL_SwapBE16(value);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_WriteLE32(SDL_RWops * dst, Uint32 value)
|
||||
{
|
||||
const Uint32 swapped = SDL_SwapLE32(value);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_WriteBE32(SDL_RWops * dst, Uint32 value)
|
||||
{
|
||||
const Uint32 swapped = SDL_SwapBE32(value);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_WriteLE64(SDL_RWops * dst, Uint64 value)
|
||||
{
|
||||
const Uint64 swapped = SDL_SwapLE64(value);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_WriteBE64(SDL_RWops * dst, Uint64 value)
|
||||
{
|
||||
const Uint64 swapped = SDL_SwapBE64(value);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1);
|
||||
return SDL_RWwrite(dst, &swapped, sizeof(swapped), 1);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue