if (d) {
while (NULL != (dir = readdir(d))) {
- if (suffix && dir->d_name && strlen(suffix) <= strlen(dir->d_name)) {
+ if (suffix && strlen(suffix) <= strlen(dir->d_name)) {
if (0 == strcmp(dir->d_name + strlen(dir->d_name) - strlen(suffix), suffix)) {
char fullpath[_POSIX_PATH_MAX];
snprintf(fullpath, _POSIX_PATH_MAX - 1, "%s/%s", MA_ASSISTANT_INFO, dir->d_name);
return g_temp_speech_data_requested;
}
-int ma_client_create(ma_client_s info)
+int ma_client_create(ma_client_s *info)
{
+ if (NULL == info) {
+ MAS_LOGE("Input parameter is NULL"); //LCOV_EXCL_LINE
+ return -1;
+ }
+
ma_client_s* data = NULL;
data = (ma_client_s*)calloc(1, sizeof(ma_client_s));
return -1;// MA_ERROR_OUT_OF_MEMORY;
}
- *data = info;
+ *data = *info;
g_client_list = g_slist_append(g_client_list, data);
new_client.pid = pid;
strncpy(new_client.appid, appid, MAX_APPID_LEN);
new_client.appid[MAX_APPID_LEN - 1] = '\0';
- ma_client_create(new_client);
+ ma_client_create(&new_client);
const char *current_maclient_appid = NULL;
if (g_current_maclient_info >= 0 && g_current_maclient_info < MAX_MACLIENT_INFO_NUM) {
{
MAS_LOGD("[Enter]");
+ if (NULL == appid) {
+ MAS_LOGE("NULL parameter");
+ return -1;
+ }
+
/* We are going to terminate existing clients for testing purpose */
int pid = mas_get_current_client_pid();
- if (pid != -1 && appid) {
+ if (pid != -1) {
ma_client_s *client = ma_client_find_by_pid(pid);
if (client && strncmp(appid, client->appid, MAX_APPID_LEN) != 0) {
int ret = aul_terminate_pid(pid);
int first = 1;
size_t size;
while (size = fread(content, 1, 640, fp)) {
- wakeup_service_speech_streaming_event_e event;
+ wakeup_service_speech_streaming_event_e new_event;
if (size == 640) {
- event = (first ? WAKEUP_SPEECH_STREAMING_EVENT_START : WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE);
+ new_event = (first ? WAKEUP_SPEECH_STREAMING_EVENT_START : WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE);
} else {
- event = WAKEUP_SPEECH_STREAMING_EVENT_FINISH;
+ new_event = WAKEUP_SPEECH_STREAMING_EVENT_FINISH;
}
- int ret = masc_dbus_send_speech_data(pid, event, content, size);
+ int ret = masc_dbus_send_speech_data(pid, new_event, content, size);
if (0 != ret) {
MAS_LOGE("[ERROR] Fail to send speech data, ret(%d)", ret);
}