Merge "A2DP profile multiple source support" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / test / gatt-test / bluetooth-gatt-test.c
index 7e1a8d9..cb7ef22 100755 (executable)
@@ -28,8 +28,6 @@
 #include <stdint.h>
 #include <string.h>
 #include <glib.h>
-#include <dbus/dbus-glib.h>
-
 #include "bluetooth-api.h"
 
 
 
 GMainLoop *main_loop = NULL;
 
-typedef struct
-{
+typedef struct {
        const char *tc_name;
        int tc_code;
 } tc_table_t;
 
-tc_table_t tc_table[] =
-{
+tc_table_t tc_table[] = {
        {"Send alert to remote le device"               , 1},
        {"Set Link loss alert"          , 2},
 
@@ -59,7 +55,7 @@ tc_table_t tc_table[] =
 };
 
 #define tc_result(success, tc_index) \
-       TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS)?"Success":"Failed"));
+       TC_PRT("Test case [%d - %s] %s", tc_table[tc_index].tc_code, tc_table[tc_index].tc_name, ((success == TC_PASS) ? "Success" : "Failed"));
 
 char *g_alert_char_handle = NULL;
 guint8 g_alert_level = 0;
@@ -114,11 +110,6 @@ char * get_bd_from_file(char *filename)
        }
 
        buf = g_malloc0(20);
-       /* Fix : NULL_RETURNS */
-       if (buf == NULL) {
-               close(fd);
-               return NULL;
-       }
 
        if (read(fd, buf, 17) < 17) {
                perror("Can't load firmware");
@@ -139,7 +130,7 @@ static void __accept_bdaddress(bluetooth_device_address_t *device_address)
 
        addr = get_bd_from_file(BD_ADDR_FILE);
        if (addr) {
-               TC_PRT("Remote bd adress from file: %s", addr);
+               TC_PRT("Remote bd address from file: %s", addr);
                convert_addr_string_to_addr_type(device_address, addr);
                g_free(addr);
                return;
@@ -227,14 +218,13 @@ void startup()
 
        dbus_threads_init_default();
 
-       g_type_init();
        main_loop = g_main_loop_new(NULL, FALSE);
 }
 
 void cleanup()
 {
        TC_PRT("bluetooth framework TC cleanup");
-       if ( main_loop != NULL)
+       if (main_loop != NULL)
                g_main_loop_unref(main_loop);
 }
 
@@ -273,7 +263,7 @@ void bt_event_callback(int event, bluetooth_event_param_t* param,
 {
        TC_PRT(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        TC_PRT("bt event callback 0x%04x", event);
-       switch(event) {
+       switch (event) {
        case BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID:
        {
                TC_PRT("BLUETOOTH_EVENT_GATT_GET_CHAR_FROM_UUID");
@@ -300,12 +290,12 @@ static gboolean key_event_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
        unsigned int len = 0;
        int test_id;
 
-       if (g_io_channel_read_chars(chan, buf, sizeof(buf), 
+       if (g_io_channel_read_chars(chan, buf, sizeof(buf),
                        &len, NULL) ==  G_IO_STATUS_ERROR) {
                printf("IO Channel read error");
                return FALSE;
        }
-       printf("%s\n",buf);
+       printf("%s\n", buf);
        tc_usage_print();
 
        test_id = atoi(buf);