Fix the coverity issues
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-event-handler.c
index 09691d8..bef35df 100644 (file)
@@ -4366,8 +4366,17 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data)
        const char *path;
        const char *interface = BT_EVENT_SERVICE;
 
-       if (is_initialized == FALSE)
-               _bt_init_event_handler();
+       if (is_initialized == FALSE) {
+               int ret;
+
+               ret = _bt_init_event_handler();
+
+               if (ret != BLUETOOTH_ERROR_NONE &&
+                               ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED) {
+                       BT_ERR("Fail to init the event handler");
+                       return ret;
+               }
+       }
 
        if (__bt_event_is_registered(event_type) == TRUE) {
                BT_ERR("The event is already registed");