Fix SVACE issues 62/141362/2 accepted/tizen/4.0/unified/20170816.013639 accepted/tizen/4.0/unified/20170828.223802 accepted/tizen/unified/20170803.075301 submit/tizen/20170801.090209 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170828.100002
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 31 Jul 2017 06:39:11 +0000 (15:39 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 1 Aug 2017 07:15:36 +0000 (16:15 +0900)
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 <sc11.lee@samsung.com>
packaging/capi-media-sound-manager.spec
src/sound_manager.c
src/sound_manager_internal.c
test/sound_manager_test.c

index d0a3d4da6769f90a89f01ed1a9bf7c8f6f7b3955..840910df2b38b62d37c440535afdd0d126040934 100644 (file)
@@ -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
index 13e72776625a5bd10626a07b3b9664ed944150d0..113a2d02aa2d71e1f4cc2d03e3223f247e00d0a6 100644 (file)
@@ -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;
        }
index ff159c6361caf49e54dae28152dac9d9fdd550f8..68a41854b1f5dd077e36dc91569e87b1e561e0ed 100644 (file)
@@ -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;
                }
index 7799705c07a359bb04e96c1fb7cc105504faaf17..4399a2ccdcf65c9349dbcd188f6519dc693c4d2e 100644 (file)
@@ -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)