From: Sangchul Lee Date: Mon, 31 Jul 2017 06:39:11 +0000 (+0900) Subject: Fix SVACE issues X-Git-Tag: submit/tizen/20170801.090209^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F141362%2F2;p=platform%2Fcore%2Fapi%2Fsound-manager.git Fix SVACE issues Some range checking codes that are "always false which may be caused by a logical error" are fixed. [Version] 0.4.17 [Issue Type] Enhancement Change-Id: I13d800f1e90b2fde67a3eac2fc798ca3c453c9f5 Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index d0a3d4d..840910d 100644 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.4.16 +Version: 0.4.17 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index 13e7277..113a2d0 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -51,7 +51,7 @@ int sound_manager_get_max_volume(sound_type_e type, int *max) int ret = MM_ERROR_NONE; SM_NULL_ARG_CHECK(max); - if (type >= SOUND_TYPE_NUM || type < 0) + if (type >= SOUND_TYPE_NUM) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); ret = _convert_sound_type(type, &volume_type); @@ -68,7 +68,7 @@ int sound_manager_set_volume(sound_type_e type, int volume) { int ret = MM_ERROR_NONE; - if (type >= SOUND_TYPE_NUM || type < 0) + if (type >= SOUND_TYPE_NUM) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); if (volume < 0) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); @@ -84,7 +84,7 @@ int sound_manager_get_volume(sound_type_e type, int *volume) int ret = MM_ERROR_NONE; unsigned int uvolume; - if (type >= SOUND_TYPE_NUM || type < 0) + if (type >= SOUND_TYPE_NUM) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); if (volume == NULL) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); @@ -103,7 +103,7 @@ int sound_manager_set_current_sound_type(sound_type_e type) int ret = MM_ERROR_NONE; LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__); - if (type >= SOUND_TYPE_NUM || type < 0) + if (type >= SOUND_TYPE_NUM) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); ret = mm_sound_volume_primary_type_set(type); @@ -265,15 +265,15 @@ int sound_manager_destroy_stream_information(sound_stream_info_h stream_info) SM_INSTANCE_CHECK(stream_h); - SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL); SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL); ret = _destroy_pa_connection_and_unregister_focus(stream_h); SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex); if (ret == MM_ERROR_NONE) { SM_SAFE_FREE(stream_h); + SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL); SM_UNREF_FOR_STREAM_INFO(g_stream_info_count); + SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex); } - SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex); LOGD("cnt(%d)", g_stream_info_count); @@ -826,7 +826,7 @@ int sound_manager_set_session_type(sound_session_type_e type) LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__); LOGI(">> enter : type=%d", type); - if (type < SOUND_SESSION_TYPE_MEDIA || type > SOUND_SESSION_TYPE_VOIP) + if (type > SOUND_SESSION_TYPE_VOIP) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); /* If session type is VOIP but MIC is not enabled, return false */ @@ -998,9 +998,9 @@ int sound_manager_set_media_session_option(sound_session_option_for_starting_e s LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__); LOGI(">> enter : option for starting=%d, for during play=%d", s_option, d_option); - if (s_option < 0 || s_option > SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START) + if (s_option > SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); - if (d_option < 0 || d_option > SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY) + if (d_option > SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); ret = mm_session_get_current_information(&session, &session_option); @@ -1124,7 +1124,7 @@ int sound_manager_set_media_session_resumption_option(sound_session_option_for_r LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__); LOGI(">> enter : option for resumption=%d (0:by system, 1:by system or media paused)", option); - if (option < SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM || option > SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED) + if (option > SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED) return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT); ret = mm_session_get_current_information(&session, &session_option); @@ -1233,7 +1233,7 @@ int sound_manager_set_voip_session_mode(sound_session_voip_mode_e mode) goto LEAVE; } - if (mode < SOUND_SESSION_VOIP_MODE_RINGTONE || mode > SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH) { + if (mode > SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH) { ret = MM_ERROR_INVALID_ARGUMENT; goto LEAVE; } diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index ff159c6..68a4185 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -403,7 +403,7 @@ static int _check_valid_filter_preset(sound_filter_e filter, sound_filter_preset { switch (filter) { case SOUND_FILTER_LOW_PASS: - if (preset < SOUND_FILTER_PRESET_LOW_PASS_NONE || preset > SOUND_FILTER_PRESET_LOW_PASS_UNDER_480HZ) { + if (preset > SOUND_FILTER_PRESET_LOW_PASS_UNDER_480HZ) { LOGE("invalid preset(%d) for low pass filter", preset); goto ERROR_INVALID_ARGS; } diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index 7799705..4399a2c 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -858,14 +858,14 @@ static void interpret(char *cmd) switch (cnt) { case 0: option_s = (sound_session_option_for_starting_e)atoi(cmd); - if (SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START > option_s || SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START < option_s) + if (SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START < option_s) g_print("not supported option type\n"); else cnt++; break; case 1: option_d = (sound_session_option_for_during_play_e)atoi(cmd); - if (SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY > option_d || SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY < option_d) + if (SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY < option_d) g_print("not supported option type\n"); else { if (sound_manager_set_media_session_option(option_s, option_d) != SOUND_MANAGER_ERROR_NONE) @@ -904,7 +904,7 @@ static void interpret(char *cmd) g_print("fail to set media session type\n"); else { option_r = (sound_session_option_for_resumption_e)atoi(cmd); - if (SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM > option_r || SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED < option_r) + if (SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED < option_r) g_print("not supported option type\n"); else { if (sound_manager_set_media_session_resumption_option(option_r) != SOUND_MANAGER_ERROR_NONE)