Before calling global variable, it calls mutex lock first.
Some cases missed that, so it changed.
And, in that case, it doesn't have to check the variable value again. So, it removed that checking condition.
Change-Id: I6e585eaad94567ef629ff878d341cf1189d648ab
static int __vc_check_privilege()
{
- if (true == g_privilege_allowed)
- return VC_ERROR_NONE;
-
pthread_mutex_lock(&g_cynara_mutex);
- if (false == g_privilege_allowed) {
- bool ret = true;
- ret = __check_privilege_initialize();
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed");
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ if (true == g_privilege_allowed) {
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_NONE;
+ }
- char uid[32];
- snprintf(uid, 32, "%d", getuid());
- ret = true;
- ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
- __check_privilege_deinitialize();
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ bool ret = true;
+ ret = __check_privilege_initialize();
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed");
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
+ }
+ char uid[32];
+ snprintf(uid, 32, "%d", getuid());
+ ret = true;
+ ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
__check_privilege_deinitialize();
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
}
+ __check_privilege_deinitialize();
+
g_privilege_allowed = true;
pthread_mutex_unlock(&g_cynara_mutex);
return VC_ERROR_NONE;
int __vc_tts_check_privilege()
{
- if (true == g_vc_tts_privilege_allowed)
- return VC_ERROR_NONE;
-
pthread_mutex_lock(&g_cynara_mutex);
- if (false == g_vc_tts_privilege_allowed) {
- bool ret = true;
- ret = __check_privilege_initialize();
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed");
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ if (true == g_vc_tts_privilege_allowed) {
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_NONE;
+ }
- char uid[32];
- snprintf(uid, 32, "%d", getuid());
- ret = true;
- ret = __check_privilege(uid, VC_TTS_PRIVILEGE);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_TTS_PRIVILEGE, uid);
- __check_privilege_deinitialize();
- g_vc_tts_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ bool ret = true;
+ ret = __check_privilege_initialize();
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed");
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
+ }
+ char uid[32];
+ snprintf(uid, 32, "%d", getuid());
+ ret = true;
+ ret = __check_privilege(uid, VC_TTS_PRIVILEGE);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_TTS_PRIVILEGE, uid);
__check_privilege_deinitialize();
+ g_vc_tts_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
}
+ __check_privilege_deinitialize();
+
g_vc_tts_privilege_allowed = true;
pthread_mutex_unlock(&g_cynara_mutex);
return VC_ERROR_NONE;
static int __vc_mgr_check_privilege()
{
- if (true == g_privilege_allowed)
- return VC_ERROR_NONE;
-
pthread_mutex_lock(&g_cynara_mutex);
- if (false == g_privilege_allowed) {
- bool ret = true;
- ret = __check_privilege_initialize();
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] privilege initialize is failed");
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ if (true == g_privilege_allowed) {
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_NONE;
+ }
- char uid[32];
- snprintf(uid, 32, "%d", getuid());
- ret = true;
- ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
- __check_privilege_deinitialize();
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ bool ret = true;
+ ret = __check_privilege_initialize();
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] privilege initialize is failed");
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
+ }
- ret = __check_privilege(uid, VC_MGR_PRIVILEGE);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_MGR_PRIVILEGE, uid);
- __check_privilege_deinitialize();
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ char uid[32];
+ snprintf(uid, 32, "%d", getuid());
+ ret = true;
+ ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
+ __check_privilege_deinitialize();
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
+ }
+ ret = __check_privilege(uid, VC_MGR_PRIVILEGE);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_MGR_PRIVILEGE, uid);
__check_privilege_deinitialize();
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
}
+ __check_privilege_deinitialize();
+
g_privilege_allowed = true;
pthread_mutex_unlock(&g_cynara_mutex);
return VC_ERROR_NONE;
int vc_mgr_data_clear_feedback_data(vc_feedback_data_s** data)
{
- SLOG(LOG_INFO, TAG_VCM, "[DATA] clear feedback data, empty(%d)", g_feedback_data.empty());
-
pthread_mutex_lock(&g_feedback_data_mutex);
+ SLOG(LOG_INFO, TAG_VCM, "[DATA] clear feedback data, empty(%d)", g_feedback_data.empty());
+
if (NULL != *data) {
SLOG(LOG_INFO, TAG_VCM, "[DEBUG] pid(%d), utt_id(%d), data(%p) size(%d) rate(%d)", (*data)->pid, (*data)->utt_id, (*data)->data, (*data)->data_size, (*data)->rate);
static int __vc_cmd_check_privilege()
{
- if (true == g_privilege_allowed)
- return VC_ERROR_NONE;
-
pthread_mutex_lock(&g_cynara_mutex);
- if (false == g_privilege_allowed) {
- bool ret = true;
- ret = __check_privilege_initialize();
- if (false == ret) {
- SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] privilege initialize is failed");
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- }
+ if (true == g_privilege_allowed) {
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_NONE;
+ }
- char uid[32];
- snprintf(uid, 32, "%d", getuid());
- ret = true;
- ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
- __check_privilege_deinitialize();
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VC_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ bool ret = true;
+ ret = __check_privilege_initialize();
+ if (false == ret) {
+ SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] privilege initialize is failed");
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ }
+ char uid[32];
+ snprintf(uid, 32, "%d", getuid());
+ ret = true;
+ ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
__check_privilege_deinitialize();
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
}
+ __check_privilege_deinitialize();
+
g_privilege_allowed = true;
pthread_mutex_unlock(&g_cynara_mutex);
return VC_ERROR_NONE;
static int __vce_check_privilege()
{
- if (true == g_privilege_allowed)
- return VC_ERROR_NONE;
-
pthread_mutex_lock(&g_cynara_mutex);
- if (false == g_privilege_allowed) {
- bool ret = true;
- ret = __check_privilege_initialize();
- if (false == ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] privilege initialize is failed");
- pthread_mutex_unlock(&g_cynara_mutex);
- return VCE_ERROR_PERMISSION_DENIED;
- }
-
- char uid[32];
- snprintf(uid, 32, "%d", getuid());
- ret = true;
- ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
- __check_privilege_deinitialize();
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VCE_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ if (true == g_privilege_allowed) {
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VC_ERROR_NONE;
+ }
- ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR_LAUNCH);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR_LAUNCH, uid);
- __check_privilege_deinitialize();
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VCE_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ bool ret = true;
+ ret = __check_privilege_initialize();
+ if (false == ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] privilege initialize is failed");
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VCE_ERROR_PERMISSION_DENIED;
+ }
- ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING);
- if (false == ret) {
- //LCOV_EXCL_START
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid);
- __check_privilege_deinitialize();
- g_privilege_allowed = false;
- pthread_mutex_unlock(&g_cynara_mutex);
- return VCE_ERROR_PERMISSION_DENIED;
- //LCOV_EXCL_STOP
- }
+ char uid[32];
+ snprintf(uid, 32, "%d", getuid());
+ ret = true;
+ ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid);
+ __check_privilege_deinitialize();
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VCE_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
+ }
+ ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR_LAUNCH);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR_LAUNCH, uid);
__check_privilege_deinitialize();
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VCE_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
+ }
+ ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING);
+ if (false == ret) {
+ //LCOV_EXCL_START
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid);
+ __check_privilege_deinitialize();
+ g_privilege_allowed = false;
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return VCE_ERROR_PERMISSION_DENIED;
+ //LCOV_EXCL_STOP
}
+ __check_privilege_deinitialize();
+
g_privilege_allowed = true;
pthread_mutex_unlock(&g_cynara_mutex);
return VCE_ERROR_NONE;