1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cortex-m4_common: Minor fixes for string handling in core_panic()

This commit is contained in:
Joakim Gebart 2015-02-10 13:33:30 +01:00
parent 0b7a929ec6
commit 7829a55a8c

View File

@ -24,8 +24,10 @@
#include "lpm.h"
#include "crash.h"
#define PANIC_STR_SIZE 80
/* "public" variables holding the crash data */
char panic_str[80];
char panic_str[PANIC_STR_SIZE];
int panic_code;
/* flag preventing "recursive crash printing loop" */
@ -36,7 +38,9 @@ NORETURN void core_panic(int crash_code, const char *message)
{
/* copy panic datas to "public" global variables */
panic_code = crash_code;
strncpy(panic_str, message, 80);
strncpy(panic_str, message, sizeof(panic_str));
/* strncpy does not add any null-termination. */
panic_str[sizeof(panic_str)-1] = '\0';
/* print panic message to console (if possible) */
if (crashed == 0) {
crashed = 1;