forked from M-Labs/artiq
1
0
Fork 0

runtime/flash_storage: use log not printf

This commit is contained in:
Sebastien Bourdeauducq 2015-06-27 22:47:36 +02:00
parent 7d3acf4d10
commit 2d475e146b
1 changed files with 7 additions and 6 deletions

View File

@ -9,6 +9,7 @@
#include <generated/mem.h>
#include <generated/csr.h>
#include "log.h"
#include "flash_storage.h"
#if (defined CSR_SPIFLASH_BASE && defined SPIFLASH_PAGE_SIZE)
@ -62,21 +63,21 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
return 0;
if(record->size < 6) {
printf("flash_storage might be corrupted: record size is %u (<6) at address %08x\n", record->size, record->raw_record);
log("flash_storage might be corrupted: record size is %u (<6) at address %08x", record->size, record->raw_record);
if(fatal)
*fatal = 1;
return 0;
}
if(is->seek > is->buf_len - sizeof(record->size) - 2) { /* 2 is the minimum key length */
printf("flash_storage might be corrupted: END_MARKER missing at the end of the storage sector\n");
log("flash_storage might be corrupted: END_MARKER missing at the end of the storage sector");
if(fatal)
*fatal = 1;
return 0;
}
if(record->size > is->buf_len - is->seek) {
printf("flash_storage might be corrupted: invalid record_size %d at address %08x\n", record->size, record->raw_record);
log("flash_storage might be corrupted: invalid record_size %d at address %08x", record->size, record->raw_record);
if(fatal)
*fatal = 1;
return 0;
@ -86,7 +87,7 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
record->key_len = strnlen(record->key, record->size - sizeof(record->size)) + 1;
if(record->key_len == record->size - sizeof(record->size) + 1) {
printf("flash_storage might be corrupted: invalid key length at address %08x\n", record->raw_record);
log("flash_storage might be corrupted: invalid key length at address %08x", record->raw_record);
if(fatal)
*fatal = 1;
return 0;
@ -258,7 +259,7 @@ int fs_write(char *key, void *buffer, unsigned int buf_len)
return 0; // Storage is definitely full.
fatal_error:
printf("fatal error: flash storage might be corrupted\n");
log("fatal error: flash storage might be corrupted");
return 0;
}
@ -289,7 +290,7 @@ unsigned int fs_read(char *key, void *buffer, unsigned int buf_len, unsigned int
}
if(fatal)
printf("fatal error: flash storage might be corrupted\n");
log("fatal error: flash storage might be corrupted");
return read_length;
}