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/libultra_boot_O2/_Printf.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/libultra_boot_O2/_Printf.c')
| -rw-r--r-- | src/libultra_boot_O2/_Printf.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/libultra_boot_O2/_Printf.c b/src/libultra_boot_O2/_Printf.c index e8fa2c696..c9ac6c524 100644 --- a/src/libultra_boot_O2/_Printf.c +++ b/src/libultra_boot_O2/_Printf.c @@ -4,6 +4,7 @@ for (i = 0; *a >= '0' && *a <= '9'; a++) \ if (i < 999) \ i = *a + i * 10 - '0'; + #define _PROUT(fmt, _size) \ if (_size > 0) { \ arg = (void*)pfn(arg, fmt, _size); \ @@ -30,20 +31,19 @@ char zeroes[] = "00000000000000000000000000000000"; void _Putfld(_Pft*, va_list*, u8, u8*); -s32 _Printf(char* (*pfn)(char*, const char*, size_t), char* arg, const char* fmt, va_list ap) { +s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap) { _Pft x; x.nchar = 0; - while (1) { - const u8* s; - u8 c; - u8* t; - static const u8 fchar[] = " +-#0"; + while (true) { + static const char fchar[] = " +-#0"; static const u32 fbit[] = { FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0 }; + const u8* s = (u8*)fmt; + u8 c; + const char* t; u8 ac[0x20]; - s = (u8*)fmt; while ((c = *s) != 0 && c != '%') { s++; } @@ -105,7 +105,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->n0 = px->nz0 = px->n1 = px->nz1 = px->n2 = px->nz2 = 0; switch (code) { - case 'c': ac[px->n0++] = va_arg(*pap, u32); break; @@ -136,7 +135,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { _Litob(px, code); break; - case 'x': case 'X': case 'u': @@ -165,7 +163,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->s = (char*)&ac[px->n0]; _Litob(px, code); break; - case 'e': case 'f': case 'g': @@ -186,7 +183,6 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->s = (char*)&ac[px->n0]; _Ldtob(px, code); break; - case 'n': if (px->qual == 'h') { *(va_arg(*pap, u16*)) = px->nchar; @@ -200,11 +196,10 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { break; case 'p': - px->v.ll = (s64)va_arg(*pap, void*); + px->v.ll = va_arg(*pap, void*); px->s = (char*)&ac[px->n0]; _Litob(px, 'x'); break; - case 's': px->s = va_arg(*pap, char*); px->n1 = strlen(px->s); @@ -212,11 +207,9 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac) { px->n1 = px->prec; } break; - case '%': ac[px->n0++] = '%'; break; - default: ac[px->n0++] = code; break; |
