mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
added explicit casts for btstack mallocs
This commit is contained in:
parent
d1845e3403
commit
fe739638d3
@ -93,7 +93,7 @@ static void put_link_key(bd_addr_t *bd_addr, link_key_t *link_key){
|
||||
if ( get_link_key(bd_addr, link_key) ) return;
|
||||
|
||||
// Record not found, create new one for this device
|
||||
db_mem_device_link_key_t * newItem = btstack_memory_db_mem_device_link_key_get();
|
||||
db_mem_device_link_key_t * newItem = (db_mem_device_link_key_t *)btstack_memory_db_mem_device_link_key_get();
|
||||
|
||||
if (!newItem) return;
|
||||
|
||||
@ -115,7 +115,7 @@ static void put_name(bd_addr_t *bd_addr, device_name_t *device_name){
|
||||
if (get_name(bd_addr, device_name)) return;
|
||||
|
||||
// Record not found, create a new one for this device
|
||||
db_mem_device_name_t * newItem = btstack_memory_db_mem_device_name_get();
|
||||
db_mem_device_name_t * newItem = (db_mem_device_name_t *) btstack_memory_db_mem_device_name_get();
|
||||
|
||||
if (!newItem) return;
|
||||
|
||||
@ -144,7 +144,7 @@ static uint8_t persistent_rfcomm_channel(char *serviceName){
|
||||
}
|
||||
|
||||
// Allocate new persistant channel
|
||||
db_mem_service_t * newItem = btstack_memory_db_mem_service_get();
|
||||
db_mem_service_t * newItem = (db_mem_service_t *) btstack_memory_db_mem_service_get();
|
||||
|
||||
if (!newItem) return 0;
|
||||
|
||||
|
@ -1,12 +1,17 @@
|
||||
CC=gcc
|
||||
CPPFLAGS=-I../include -I../src -g
|
||||
CC=g++
|
||||
CPPUTEST_HOME = /usr/local/cpputest
|
||||
|
||||
CPPFLAGS=-I../include -I../src -I$(CPPUTEST_HOME)/include -g
|
||||
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt
|
||||
|
||||
VPATH=../src
|
||||
|
||||
DEPS = remote_device_db_memory.h
|
||||
OBJ = remote_device_db_memory_test.o remote_device_db_memory.o btstack_memory.o linked_list.o
|
||||
|
||||
remote_device_db_memory_test: $(OBJ)
|
||||
$(CC) $(CPPFLAGS) -o $@ $^
|
||||
remote-memory: $(OBJ)
|
||||
$(CC) $(CPPFLAGS) -o $@ $^ $(LD_LIBRARIES)
|
||||
|
||||
clean:
|
||||
rm -f remote_device_db_memory_test *.o
|
||||
rm -f remote-memory *.o
|
||||
|
||||
|
@ -1,63 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
#include "remote_device_db.h"
|
||||
|
||||
bd_addr_t addr = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
|
||||
device_name_t device_name = {'m', 'a', 't', 't'};
|
||||
link_key_t link_key = {'h', 'i', 'a', 's'};
|
||||
TEST_GROUP(RemoteDeviceDB){
|
||||
bd_addr_t addr;
|
||||
device_name_t device_name;
|
||||
link_key_t link_key;
|
||||
|
||||
void testPutGetDeleteName(void){
|
||||
void setup(){
|
||||
bd_addr_t addr = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
|
||||
strcpy((char*)device_name, "matthias");
|
||||
strcpy((char*)link_key, "matthias");
|
||||
}
|
||||
|
||||
void teardown(){}
|
||||
};
|
||||
|
||||
TEST(RemoteDeviceDB, PutGetDeleteName){
|
||||
remote_device_db_memory.put_name(&addr, &device_name);
|
||||
if (remote_device_db_memory.get_name(&addr, &device_name)) {
|
||||
printf("OK ------> found device \n");
|
||||
} else {
|
||||
printf("ERROR ------> device not found \n");
|
||||
};
|
||||
CHECK(remote_device_db_memory.get_name(&addr, &device_name));
|
||||
|
||||
remote_device_db_memory.delete_name(&addr);
|
||||
if (remote_device_db_memory.get_name(&addr, &device_name)) {
|
||||
printf("ERROR ------> device not deleted \n");
|
||||
} else {
|
||||
printf("OK ------> device deleted \n");
|
||||
};
|
||||
|
||||
remote_device_db_memory.put_link_key(&addr, &link_key);
|
||||
if (remote_device_db_memory.get_name(&addr, &device_name)) {
|
||||
printf("ERROR ------> no device with such name\n");
|
||||
} else {
|
||||
printf("OK ------> device with such name does not exist \n");
|
||||
};
|
||||
|
||||
CHECK(!remote_device_db_memory.get_name(&addr, &device_name));
|
||||
}
|
||||
|
||||
void testPutGetDeleteKey(void){
|
||||
remote_device_db_memory.put_link_key(&addr, &link_key);
|
||||
if (remote_device_db_memory.get_link_key(&addr, &link_key)) {
|
||||
printf("OK ------> found key \n");
|
||||
} else {
|
||||
printf("ERROR ------> key not found \n");
|
||||
};
|
||||
TEST(RemoteDeviceDB, PutGetDeleteKey){
|
||||
remote_device_db_memory.put_link_key(&addr, &link_key);
|
||||
CHECK(remote_device_db_memory.get_link_key(&addr, &link_key));
|
||||
|
||||
remote_device_db_memory.delete_link_key(&addr);
|
||||
if (remote_device_db_memory.get_link_key(&addr, &link_key)) {
|
||||
printf("ERROR ------> key not deleted \n");
|
||||
} else {
|
||||
printf("OK ------> key deleted \n");
|
||||
};
|
||||
|
||||
remote_device_db_memory.put_name(&addr, &device_name);
|
||||
if (remote_device_db_memory.get_link_key(&addr, &link_key)) {
|
||||
printf("ERROR ------> no device with such link key\n");
|
||||
} else {
|
||||
printf("OK ------> device with such link key does not exist \n");
|
||||
};
|
||||
CHECK(!remote_device_db_memory.get_link_key(&addr, &link_key));
|
||||
}
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
printf("\n<remote_device_db_memory_test> \n");
|
||||
testPutGetDeleteName();
|
||||
testPutGetDeleteKey();
|
||||
printf("</remote_device_db_memory_test> \n\n");
|
||||
|
||||
return 0;
|
||||
return CommandLineTestRunner::RunAllTests(argc, argv);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user