Fix defects detected by static analysis tool 47/230547/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 6 Apr 2020 10:16:18 +0000 (19:16 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 10 Apr 2020 11:08:18 +0000 (20:08 +0900)
Change-Id: I9af8980b3d3f15ded3fa261ec957debe7adc5365

inc/multi_assistant_config.h
inc/multi_assistant_main.h
inc/multi_assistant_service_client.h
inc/multi_wakeup_recognizer.h
plugins/wakeup-manager/inc/wakeup_manager.h
plugins/wakeup-manager/src/wakeup_manager.cpp
src/multi_assistant_service.c

index a5810ac..2999533 100644 (file)
 #include <tizen.h>
 #include <tzplatform_config.h>
 
+#include "multi_assistant_main.h"
+
 #ifdef __cplusplus
 extern "C"
 {
 #endif
 
-#define MAX_WAKEUP_LIST_NUM 32
-#define MAX_SUPPORTED_LANGUAGE_NUM 128
-
 /**************************************************************************************
  *** Definitions for xml file
  *************************************************************************************/
@@ -57,21 +56,14 @@ extern "C"
 #define VOICE_KEY_SUPPORT_MODE_STRING_TAP_TO_TALK "tap_to_talk"
 #define VOICE_KEY_SUPPORT_MODE_STRING_ALL "all"
 
-typedef enum {
-       VOICE_KEY_SUPPORT_MODE_NONE,
-       VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK,
-       VOICE_KEY_SUPPORT_MODE_TAP_TO_TALK,
-       VOICE_KEY_SUPPORT_MODE_ALL,
-} VOICE_KEY_SUPPORT_MODE;
-
 typedef struct {
        const char* app_id;
        const char* name;
        const char* icon_path;
-       const char* wakeup_list[MAX_WAKEUP_LIST_NUM];
-       const char* wakeup_language[MAX_WAKEUP_LIST_NUM];
+       const char* wakeup_list[MAX_WAKEUP_WORDS_NUM];
+       const char* wakeup_language[MAX_WAKEUP_WORDS_NUM];
        int cnt_wakeup;
-       const char* supported_lang[MAX_SUPPORTED_LANGUAGE_NUM];
+       const char* supported_lang[MAX_SUPPORTED_LANGUAGES_NUM];
        int cnt_lang;
        const char* wakeup_engine;
        bool custom_ui_option;
index 27250ef..016c5a4 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __MULTI_ASSISTANT_SERVICE_H__
-#define __MULTI_ASSISTANT_SERVICE_H__
+#ifndef __MULTI_ASSISTANT_MAIN_H__
+#define __MULTI_ASSISTANT_MAIN_H__
 
 #include <app.h>
 #include <glib.h>
 #define MAS_UI_METHOD_SEND_RECOGNITION_RESULT          "mas_ui_method_send_recognition_result"
 #define MAS_UI_METHOD_ENABLE_COMMON_UI                         "mas_ui_method_enable_common_ui"
 
-#endif /* __MULTI_ASSISTANT_SERVICE_H__ */
+#define MAX_WAKEUP_WORDS_NUM 255
+#define MAX_WAKEUP_WORD_LEN 32
+#define MAX_SUPPORTED_LANGUAGES_NUM 255
+#define MAX_SUPPORTED_LANGUAGE_LEN 16
+
+#define MAX_APPID_LEN 255
+
+typedef enum {
+       VOICE_KEY_SUPPORT_MODE_NONE,
+       VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK,
+       VOICE_KEY_SUPPORT_MODE_TAP_TO_TALK,
+       VOICE_KEY_SUPPORT_MODE_ALL,
+} VOICE_KEY_SUPPORT_MODE;
+
+#endif /* __MULTI_ASSISTANT_MAIN_H__ */
index be2e984..76a9392 100644 (file)
  */
 
 
-#ifndef _MULTI_ASSISTANT_SERVICE_H_
-#define _MULTI_ASSISTANT_SERVICE_H_
+#ifndef _MULTI_ASSISTANT_SERVICE_CLIENT_H_
+#define _MULTI_ASSISTANT_SERVICE_CLIENT_H_
 
 #include <dlog/dlog.h>
 
+#include "multi_assistant_main.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define MAX_APPID_LEN 255
-
 typedef enum {
        CLIENT_LAUNCH_MODE_ACTIVATION,
        CLIENT_LAUNCH_MODE_PRELAUNCH,
@@ -119,9 +118,23 @@ int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event);
 
 int mas_update_voice_key_support_mode();
 
+typedef struct {
+       bool used;
+       char appid[MAX_APPID_LEN];
+       char wakeup_word[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
+       char wakeup_language[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+       char wakeup_engine[MAX_APPID_LEN];
+       char supported_language[MAX_SUPPORTED_LANGUAGES_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+       bool custom_ui_option;
+       VOICE_KEY_SUPPORT_MODE voice_key_support_mode;
+       float voice_key_tap_duration;
+
+       ma_preprocessing_allow_mode_e preprocessing_allow_mode;
+       char preprocessing_allow_appid[MAX_APPID_LEN];
+} ma_client_info;
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _MULTI_ASSISTANT_SERVICE_H_ */
+#endif /* _MULTI_ASSISTANT_SERVICE_CLIENT_H_ */
index d5f8fb0..a9f4b45 100644 (file)
@@ -28,9 +28,9 @@
 extern "C" {
 #endif
 
-typedef void (*wakeup_service_wakeup_event_cb)(mas_wakeup_event_info wakeup_info, const char* wakeup_word, void* user_data);
+typedef void (*wakeup_service_wakeup_event_cb)(mas_wakeup_event_info wakeup_info, void* user_data);
 
-typedef void (*wakeup_service_speech_streaming_cb)(mas_speech_streaming_event_e event, unsigned char* buffer, int len, void *user_data);
+typedef void (*wakeup_service_speech_streaming_cb)(mas_speech_streaming_event_e event, void* buffer, int len, void *user_data);
 
 typedef void (*wakeup_service_speech_status_cb)(mas_speech_status_e status, void *user_data);
 
index 0f2d6ed..de7cb11 100644 (file)
@@ -225,7 +225,8 @@ private:
        bool mVoiceKeyPressed{false};
        string mCurrentLanguage;
        string mCurrentDefaultAssistant;
-       VOICE_KEY_SUPPORT_MODE mCurrentVoiceKeySupportMode;
+       /* Assume Push-to-talk is the default mode */
+       VOICE_KEY_SUPPORT_MODE mCurrentVoiceKeySupportMode{VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK};
 
        STREAMING_MODE mStreamingMode{STREAMING_MODE::NONE};
        Ecore_Timer* mStreamingDurationTimer{nullptr};
@@ -238,4 +239,4 @@ private:
 } // wakeup
 } // multiassistant
 
-#endif /* _WAKEUP_MANAGER_H_ */
\ No newline at end of file
+#endif /* _WAKEUP_MANAGER_H_ */
index ab2b8a4..b0ddfd1 100644 (file)
@@ -499,6 +499,7 @@ bool CWakeupManager::change_voice_key_status(ma_voice_key_status_e status) {
                MA_VOICE_KEY_STATUS_RELEASED_AFTER_TAP == status) {
                mVoiceKeyPressed = false;
        }
+       return true;
 }
 
 bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data, int len)
index bc84cc1..fcbd186 100644 (file)
@@ -45,24 +45,6 @@ static const char *g_current_lang = "en_US";
 #define WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE "db/multi-assistant/prelaunch_mode"
 
 #define MAX_MACLIENT_INFO_NUM 16
-#define MAX_WAKEUP_WORDS_NUM 255
-#define MAX_WAKEUP_WORD_LEN 32
-#define MAX_SUPPORTED_LANGUAGES_NUM 255
-#define MAX_SUPPORTED_LANGUAGE_LEN 16
-typedef struct {
-       bool used;
-       char appid[MAX_APPID_LEN];
-       char wakeup_word[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
-       char wakeup_language[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
-       char wakeup_engine[MAX_APPID_LEN];
-       char supported_language[MAX_SUPPORTED_LANGUAGES_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
-       bool custom_ui_option;
-       VOICE_KEY_SUPPORT_MODE voice_key_support_mode;
-       float voice_key_tap_duration;
-
-       ma_preprocessing_allow_mode_e preprocessing_allow_mode;
-       char preprocessing_allow_appid[MAX_APPID_LEN];
-} ma_client_info;
 
 static ma_client_info g_maclient_info[MAX_MACLIENT_INFO_NUM];
 
@@ -770,7 +752,7 @@ static int init_plugin(void)
                                                }
                                        }
                                }
-                               for (inner_loop = 0; inner_loop < MAX_SUPPORTED_LANGUAGE_NUM; inner_loop++) {
+                               for (inner_loop = 0; inner_loop < MAX_SUPPORTED_LANGUAGES_NUM; inner_loop++) {
                                        if (0 < strlen(g_maclient_info[loop].supported_language[inner_loop])) {
                                                MAS_LOGD("Adding language %s for app %s",
                                                        g_maclient_info[loop].supported_language[inner_loop], g_maclient_info[loop].appid);