diff options
| author | Tharo <17233964+Thar0@users.noreply.github.com> | 2021-02-14 00:49:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-13 19:49:40 -0500 |
| commit | f9d96d9f73ac090245a518ec04f3fa0e50655d1e (patch) | |
| tree | 9dc905fce276cbfb07a05fc2bf0883bcedddcf23 /src/code/system_malloc.c | |
| parent | d615ec4f31563b939f8c0dce1c20c79e137c2043 (diff) | |
Fix most compiler warnings in the boot and code segments (#674)
* Less warnings in boot & code segments
* few more warnings gone
* Ran formatter
* z_view warning gone
* -> 1
* f31 -> 31
* Remove function casts
* Few more small improvements
* Separate declaration and assignment in func_80091738 and Item_Give
Co-authored-by: Thar0 <maximilianc64@gmail.com>
Diffstat (limited to 'src/code/system_malloc.c')
| -rw-r--r-- | src/code/system_malloc.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/code/system_malloc.c b/src/code/system_malloc.c index be55cb76c..7311ce102 100644 --- a/src/code/system_malloc.c +++ b/src/code/system_malloc.c @@ -8,7 +8,7 @@ s32 gSystemArenaLogSeverity = LOG_SEVERITY_NOLOG; Arena gSystemArena; void SystemArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action) { - if (!ptr) { + if (ptr == NULL) { if (gSystemArenaLogSeverity >= LOG_SEVERITY_ERROR) { // "%s: %u bytes %s failed\n" osSyncPrintf("%s: %u バイトの%sに失敗しました\n", name, size, action); @@ -22,29 +22,29 @@ void SystemArena_CheckPointer(void* ptr, u32 size, const char* name, const char* } void* SystemArena_Malloc(u32 size) { - void* ptr; - ptr = __osMalloc(&gSystemArena, size); + void* ptr = __osMalloc(&gSystemArena, size); + SystemArena_CheckPointer(ptr, size, "malloc", "確保"); // Secure return ptr; } void* SystemArena_MallocDebug(u32 size, const char* file, s32 line) { - void* ptr; - ptr = __osMallocDebug(&gSystemArena, size, file, line); + void* ptr = __osMallocDebug(&gSystemArena, size, file, line); + SystemArena_CheckPointer(ptr, size, "malloc_DEBUG", "確保"); // Secure return ptr; } void* SystemArena_MallocR(u32 size) { - void* ptr; - ptr = __osMallocR(&gSystemArena, size); + void* ptr = __osMallocR(&gSystemArena, size); + SystemArena_CheckPointer(ptr, size, "malloc_r", "確保"); // Secure return ptr; } void* SystemArena_MallocRDebug(u32 size, const char* file, s32 line) { - void* ptr; - ptr = __osMallocRDebug(&gSystemArena, size, file, line); + void* ptr = __osMallocRDebug(&gSystemArena, size, file, line); + SystemArena_CheckPointer(ptr, size, "malloc_r_DEBUG", "確保"); // Secure return ptr; } @@ -71,11 +71,10 @@ void SystemArena_FreeDebug(void* ptr, const char* file, s32 line) { void* SystemArena_Calloc(u32 num, u32 size) { void* ret; - u32 n; + u32 n = num * size; - n = num * size; ret = __osMalloc(&gSystemArena, n); - if (ret) { + if (ret != NULL) { bzero(ret, n); } @@ -83,7 +82,7 @@ void* SystemArena_Calloc(u32 num, u32 size) { return ret; } -void SystemArena_Display() { +void SystemArena_Display(void) { // System heap display osSyncPrintf("システムヒープ表示\n"); __osDisplayArena(&gSystemArena); @@ -93,7 +92,7 @@ void SystemArena_GetSizes(u32* outMaxFree, u32* outFree, u32* outAlloc) { ArenaImpl_GetSizes(&gSystemArena, outMaxFree, outFree, outAlloc); } -void SystemArena_Check() { +void SystemArena_Check(void) { __osCheckArena(&gSystemArena); } @@ -102,11 +101,11 @@ void SystemArena_Init(void* start, u32 size) { __osMallocInit(&gSystemArena, start, size); } -void SystemArena_Cleanup() { +void SystemArena_Cleanup(void) { gSystemArenaLogSeverity = LOG_SEVERITY_NOLOG; __osMallocCleanup(&gSystemArena); } -u8 SystemArena_IsInitalized() { +u8 SystemArena_IsInitalized(void) { return __osMallocIsInitalized(&gSystemArena); } |
