le_device_db_tlv: log_error if tlv isn't initialized, try not to crash

This commit is contained in:
Matthias Ringwald 2018-06-22 11:43:37 +02:00
parent bc71fcbb5e
commit dba24ced98

View File

@ -110,6 +110,7 @@ static uint32_t le_device_db_tlv_tag_for_index(uint8_t index){
// @returns success
// @param index = entry_pos
static int le_device_db_tlv_fetch(int index, le_device_db_entry_t * entry){
if (!le_device_db_tlv_btstack_tlv_impl) return 0;
if (index < 0 || index >= NVM_NUM_DEVICE_DB_ENTRIES){
log_error("le_device_db_tlv_fetch called with invalid index %d", index);
return 0;
@ -122,6 +123,7 @@ static int le_device_db_tlv_fetch(int index, le_device_db_entry_t * entry){
// @returns success
// @param index = entry_pos
static int le_device_db_tlv_store(int index, le_device_db_entry_t * entry){
if (!le_device_db_tlv_btstack_tlv_impl) return 0;
if (index < 0 || index >= NVM_NUM_DEVICE_DB_ENTRIES){
log_error("le_device_db_tlv_store called with invalid index %d", index);
return 0;
@ -133,6 +135,7 @@ static int le_device_db_tlv_store(int index, le_device_db_entry_t * entry){
// @param index = entry_pos
static int le_device_db_tlv_delete(int index){
if (!le_device_db_tlv_btstack_tlv_impl) return 0;
if (index < 0 || index >= NVM_NUM_DEVICE_DB_ENTRIES){
log_error("le_device_db_tlv_delete called with invalid index %d", index);
return 0;
@ -158,6 +161,9 @@ static void le_device_db_tlv_scan(void){
}
void le_device_db_init(void){
if (!le_device_db_tlv_btstack_tlv_impl) {
log_error("btstack_tlv not initialized");
}
}
// not used