Remove unused resource type argument from acquire and release functions in mm_radio_rm.c 24/317424/2 accepted/tizen_unified accepted/tizen_unified_dev accepted/tizen_unified_toolchain accepted/tizen_unified_x accepted/tizen_unified_x_asan accepted/tizen/unified/20240919.163732 accepted/tizen/unified/dev/20240920.060429 accepted/tizen/unified/toolchain/20241004.101642 accepted/tizen/unified/x/20240920.053153 accepted/tizen/unified/x/asan/20241014.000001
authorGilbok Lee <gilbok.lee@samsung.com>
Tue, 10 Sep 2024 05:59:24 +0000 (14:59 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Tue, 10 Sep 2024 07:17:35 +0000 (16:17 +0900)
- In the current implementation of the mm_radio_rm.c file, the RM_CATEGORY_RADIO is the only category used for radio resources.
  Therefore, the resource type argument passed to the acquire
  and release functions is redundant and can be removed without affecting the functionality of the code.
- This change simplifies the function signatures and removes unnecessary code complexity.

[Version] 0.3.2
[Issue Type] Fix Coverity issue

Change-Id: I260fefc1a021eb823af0c65374eb9c200125201f

packaging/libmm-radio.spec
src/include/mm_radio_rm.h
src/mm_radio_priv_emulator.c
src/mm_radio_priv_hal.c
src/mm_radio_rm.c

index 029e971..e1c4aca 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-radio
 Summary:    Multimedia Framework Radio Library
-Version:    0.3.2
+Version:    0.3.3
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index a3f6510..be7dea3 100644 (file)
 #include <rm_type.h>
 #include "mm_radio_utils.h"
 
-typedef enum {
-       MM_RADIO_RES_TYPE_RADIO,     /**< ID of radio resource type */
-       MM_RADIO_RES_TYPE_MAX,        /**< Used to iterate on resource types only */
-} MMRadioResourceTypes;
-
 typedef struct _radio_resource_s {
        int rm_h;
-       rm_device_return_s returned_devices[MM_RADIO_RES_TYPE_MAX];
+       rm_device_return_s returned_devices;
        rm_consumer_info rci;
-       gboolean need_to_acquire[MM_RADIO_RES_TYPE_MAX];
        GMutex rm_callback_lock;
        GMutex rm_control_lock;
 } radio_resource_s;
 
 int mm_radio_rm_register(MMHandleType hradio);
-int mm_radio_rm_acquire(MMHandleType hradio, MMRadioResourceTypes type);
-int mm_radio_rm_release(MMHandleType hradio, MMRadioResourceTypes type);
+int mm_radio_rm_acquire(MMHandleType hradio);
+int mm_radio_rm_release(MMHandleType hradio);
 int mm_radio_rm_unregister(MMHandleType hradio);
 
 
index 6dbb695..55342fa 100644 (file)
@@ -581,7 +581,7 @@ int _mmradio_start(mm_radio_t * radio)
        MMRADIO_SLOG_DEBUG("now tune to frequency : %d", radio->freq);
 
        radio->interrupted_by_resource_conflict = FALSE;
-       ret = mm_radio_rm_acquire((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+       ret = mm_radio_rm_acquire((MMHandleType)radio);
        if (ret != MM_ERROR_NONE) {
                MMRADIO_LOG_ERROR("resource manager acquire fail");
                return MM_ERROR_RADIO_INTERNAL;
@@ -618,7 +618,7 @@ int _mmradio_stop(mm_radio_t * radio)
        /*      return MM_ERROR_RADIO_NOT_INITIALIZED; */
 
        if (!radio->interrupted_by_resource_conflict) {
-               ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+               ret = mm_radio_rm_release((MMHandleType)radio);
                if (ret != MM_ERROR_NONE)
                        MMRADIO_LOG_ERROR("resource manager release fail");
        }
index bb0b7d8..e310793 100644 (file)
@@ -610,7 +610,7 @@ error:
        hal_radio_unprepare(radio->hal_radio);
 
        if (!radio->interrupted_by_resource_conflict) {
-               ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+               ret = mm_radio_rm_release((MMHandleType)radio);
                if (ret != MM_ERROR_NONE)
                        MMRADIO_LOG_ERROR("resource manager release fail");
        }
@@ -673,7 +673,7 @@ int _mmradio_stop(mm_radio_t *radio)
                }
 
                if (!radio->interrupted_by_resource_conflict) {
-                       ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+                       ret = mm_radio_rm_release((MMHandleType)radio);
                        if (ret != MM_ERROR_NONE)
                                MMRADIO_LOG_ERROR("resource manager release fail");
                }
@@ -1649,7 +1649,7 @@ static int __mmradio_prepare_radio_device(mm_radio_t *radio)
        }
 
        radio->interrupted_by_resource_conflict = FALSE;
-       ret = mm_radio_rm_acquire((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+       ret = mm_radio_rm_acquire((MMHandleType)radio);
        if (ret != MM_ERROR_NONE) {
                MMRADIO_LOG_ERROR("failed to acquire resource manager");
                return ret;
@@ -1695,7 +1695,7 @@ error1:
 error2:
        hal_radio_unprepare(radio->hal_radio);
 
-       ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+       ret = mm_radio_rm_release((MMHandleType)radio);
        if (ret != MM_ERROR_NONE)
                MMRADIO_LOG_ERROR("resource manager release fail");
 
@@ -1723,7 +1723,7 @@ static void __mmradio_close_radio_device(mm_radio_t *radio)
        if (ret)
                __convert_error_code(ret, (char *)__FUNCTION__);
 
-       ret = mm_radio_rm_release((MMHandleType)radio, MM_RADIO_RES_TYPE_RADIO);
+       ret = mm_radio_rm_release((MMHandleType)radio);
        if (ret != MM_ERROR_NONE)
                MMRADIO_LOG_ERROR("resource manager release fail");
 
index 28b6992..69b0764 100644 (file)
  */
 
 #include "mm_radio_rm.h"
+#ifdef TIZEN_FEATURE_RADIO_HAL
 #include "mm_radio_priv_hal.h"
+#else
+#include "mm_radio_priv_emul.h"
+#endif
 #include <mm_error.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -138,15 +142,13 @@ int mm_radio_rm_register(MMHandleType hradio)
 
 }
 
-int mm_radio_rm_acquire(MMHandleType hradio, MMRadioResourceTypes type)
+int mm_radio_rm_acquire(MMHandleType hradio)
 {
        int ret = RM_OK;
        int idx = 0;
        int category_option = 0;
-       rm_rsc_category_e category_id = RM_CATEGORY_NONE;
-       rm_requests_resource_state_e state;
        rm_category_request_s request_resources;
-       rm_device_return_s *returned_device;
+       rm_device_return_s *returned_device = NULL;
        g_autoptr(GMutexLocker) locker = NULL;
        mm_radio_t *radio = (mm_radio_t *)hradio;
 
@@ -156,29 +158,20 @@ int mm_radio_rm_acquire(MMHandleType hradio, MMRadioResourceTypes type)
 
        locker = g_mutex_locker_new(&radio->resource.rm_control_lock);
 
-       MMRADIO_LOG_INFO("app id : %s type %d", radio->resource.rci.app_id, type);
+       MMRADIO_LOG_INFO("app id : %s", radio->resource.rci.app_id);
        memset(&request_resources, 0x0, sizeof(rm_category_request_s));
 
-       returned_device = &radio->resource.returned_devices[type];
+       returned_device = &radio->resource.returned_devices;
        memset(returned_device, 0x0, sizeof(rm_device_return_s));
 
-       switch (type) {
-       case MM_RADIO_RES_TYPE_RADIO:
-               state = RM_STATE_EXCLUSIVE;
-               category_id = RM_CATEGORY_RADIO;
-               break;
-       default:
-               MMRADIO_LOG_ERROR("category id can't set");
-               return MM_ERROR_RADIO_INTERNAL;
-       }
-
-       category_option = rc_get_capable_category_id(radio->resource.rm_h, radio->resource.rci.app_id, category_id);
+       category_option = rc_get_capable_category_id(radio->resource.rm_h, radio->resource.rci.app_id, RM_CATEGORY_RADIO);
 
        request_resources.request_num = 1;
-       request_resources.state[0] = state;
-       request_resources.category_id[0] = category_id;
+       request_resources.state[0] = RM_STATE_EXCLUSIVE;
+       request_resources.category_id[0] = RM_CATEGORY_RADIO;
        request_resources.category_option[0] = category_option;
-       MMRADIO_LOG_INFO("state %d category id 0x%x category option %d", state, category_id, category_option);
+       MMRADIO_LOG_INFO("state %d category id 0x%x category option %d", request_resources.state[0],
+                       request_resources.category_id[0], request_resources.category_option[0]);
 
        ret = rm_allocate_resources(radio->resource.rm_h, &request_resources, returned_device);
        if (ret != RM_OK) {
@@ -196,7 +189,7 @@ int mm_radio_rm_acquire(MMHandleType hradio, MMRadioResourceTypes type)
        return MM_ERROR_NONE;
 }
 
-int mm_radio_rm_release(MMHandleType hradio, MMRadioResourceTypes type)
+int mm_radio_rm_release(MMHandleType hradio)
 {
        int rm_ret = RM_OK;
        int idx = 0;
@@ -212,9 +205,9 @@ int mm_radio_rm_release(MMHandleType hradio, MMRadioResourceTypes type)
 
        locker = g_mutex_locker_new(&radio->resource.rm_control_lock);
 
-       r_devices = &radio->resource.returned_devices[type];
+       r_devices = &radio->resource.returned_devices;
 
-       MMRADIO_LOG_INFO("[%p] #%d (type %d) alloc num %d", r_devices, idx, type, r_devices->allocated_num);
+       MMRADIO_LOG_INFO("[%p] #%d alloc num %d", r_devices, idx, r_devices->allocated_num);
 
        if (r_devices->allocated_num > 0) {
                memset(&requested, 0x0, sizeof(rm_device_request_s));