1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

trezorhal: use attribute format for printf functions

This commit is contained in:
Pavol Rusnak 2017-05-02 17:35:39 +02:00
parent 11917920e7
commit 6fd52dd36e
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 21 additions and 21 deletions

View File

@ -39,10 +39,10 @@ void display_vendor(const uint8_t *vimg, const char *vstr, uint32_t vstr_len, ui
display_text_center(120, 192, vstr, vstr_len, FONT_BOLD, COLOR_WHITE, COLOR_BLACK); display_text_center(120, 192, vstr, vstr_len, FONT_BOLD, COLOR_WHITE, COLOR_BLACK);
char ver_str[32]; char ver_str[32];
mini_snprintf(ver_str, sizeof(ver_str), "%d.%d.%d.%d", mini_snprintf(ver_str, sizeof(ver_str), "%d.%d.%d.%d",
fw_version & 0xFF, (int)(fw_version & 0xFF),
(fw_version >> 8) & 0xFF, (int)((fw_version >> 8) & 0xFF),
(fw_version >> 16) & 0xFF, (int)((fw_version >> 16) & 0xFF),
(fw_version >> 24) & 0xFF (int)((fw_version >> 24) & 0xFF)
); );
display_text_center(120, 215, ver_str, -1, FONT_BOLD, COLOR_GRAY64, COLOR_BLACK); display_text_center(120, 215, ver_str, -1, FONT_BOLD, COLOR_GRAY64, COLOR_BLACK);
display_refresh(); display_refresh();

View File

@ -54,7 +54,7 @@ void display_icon(int x, int y, int w, int h, const void *data, int datalen, uin
#ifndef TREZOR_PRINT_DISABLE #ifndef TREZOR_PRINT_DISABLE
void display_print_color(uint16_t fgcolor, uint16_t bgcolor); void display_print_color(uint16_t fgcolor, uint16_t bgcolor);
void display_print(const char *text, int textlen); void display_print(const char *text, int textlen);
void display_printf(const char *fmt, ...); void display_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
#endif #endif
void display_text(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor); void display_text(int x, int y, const char *text, int textlen, uint8_t font, uint16_t fgcolor, uint16_t bgcolor);

View File

@ -37,8 +37,8 @@ extern "C" {
#include <stdarg.h> #include <stdarg.h>
int mini_vsnprintf(char* buffer, unsigned int buffer_len, const char *fmt, va_list va); int mini_vsnprintf(char* buffer, unsigned int buffer_len, const char *fmt, va_list va) __attribute__ ((__format__ (__printf__, 3, 0)));
int mini_snprintf(char* buffer, unsigned int buffer_len, const char *fmt, ...); int mini_snprintf(char* buffer, unsigned int buffer_len, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -105,25 +105,25 @@ void HardFault_C_Handler(ExceptionRegisters_t *regs) {
display_printf("HardFault\n"); display_printf("HardFault\n");
display_printf("R0 %08x\n", regs->r0); display_printf("R0 %08x\n", (unsigned int)regs->r0);
display_printf("R1 %08x\n", regs->r1); display_printf("R1 %08x\n", (unsigned int)regs->r1);
display_printf("R2 %08x\n", regs->r2); display_printf("R2 %08x\n", (unsigned int)regs->r2);
display_printf("R3 %08x\n", regs->r3); display_printf("R3 %08x\n", (unsigned int)regs->r3);
display_printf("R12 %08x\n", regs->r12); display_printf("R12 %08x\n", (unsigned int)regs->r12);
display_printf("SP %08x\n", (uint32_t)regs); display_printf("SP %08x\n", (unsigned int)regs);
display_printf("LR %08x\n", regs->lr); display_printf("LR %08x\n", (unsigned int)regs->lr);
display_printf("PC %08x\n", regs->pc); display_printf("PC %08x\n", (unsigned int)regs->pc);
display_printf("XPSR %08x\n", regs->xpsr); display_printf("XPSR %08x\n", (unsigned int)regs->xpsr);
uint32_t cfsr = SCB->CFSR; uint32_t cfsr = SCB->CFSR;
display_printf("HFSR %08x\n", SCB->HFSR); display_printf("HFSR %08x\n", (unsigned int)SCB->HFSR);
display_printf("CFSR %08x\n", cfsr); display_printf("CFSR %08x\n", (unsigned int)cfsr);
if (cfsr & 0x80) { if (cfsr & 0x80) {
display_printf("MMFAR %08x\n", SCB->MMFAR); display_printf("MMFAR %08x\n", (unsigned int)SCB->MMFAR);
} }
if (cfsr & 0x8000) { if (cfsr & 0x8000) {
display_printf("BFAR %08x\n", SCB->BFAR); display_printf("BFAR %08x\n", (unsigned int)SCB->BFAR);
} }
if ((void*)&_ram_start <= (void*)regs && (void*)regs < (void*)&_ram_end) { if ((void*)&_ram_start <= (void*)regs && (void*)regs < (void*)&_ram_end) {
@ -134,7 +134,7 @@ void HardFault_C_Handler(ExceptionRegisters_t *regs) {
stack_top = (uint32_t*)regs + 32; stack_top = (uint32_t*)regs + 32;
} }
for (uint32_t *sp = (uint32_t*)regs; sp < stack_top; ++sp) { for (uint32_t *sp = (uint32_t*)regs; sp < stack_top; ++sp) {
display_printf(" %08x %08x\n", (uint32_t)sp, *sp); display_printf(" %08x %08x\n", (unsigned int)sp, (unsigned int)*sp);
} }
} }