From 1ed40201cb15f7ab7419d10a3b1672025b096c3e Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Thu, 11 Mar 2021 13:30:39 +0900 Subject: [PATCH] Improve variable naming style Change-Id: I582cb9c6d65471afff8d4eba5c0fdf4dccb29a25 Signed-off-by: taemin.yeom --- src/runtime_info_system.c | 12 ++--- src/runtime_info_usage.c | 94 +++++++++++++++++++-------------------- src/runtime_info_vconf.c | 8 ++-- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/runtime_info_system.c b/src/runtime_info_system.c index 78b5348..bff1a7b 100644 --- a/src/runtime_info_system.c +++ b/src/runtime_info_system.c @@ -287,7 +287,7 @@ void runtime_info_charger_connected_unset_event_cb(void) runtime_info_vconf_unset_event_cb(VCONF_CHARGER_CONNECTED, 0); } -int runtime_info_get_frequency_cpufreq(int core_idx, char *type, int *cpu_freq) +int runtime_info_get_frequency_cpufreq(int core_idx, char *type, int *out_cpu_freq) { char path[256]; FILE *cpufreq_fp; @@ -296,7 +296,7 @@ int runtime_info_get_frequency_cpufreq(int core_idx, char *type, int *cpu_freq) if (core_idx < 0) return RUNTIME_INFO_ERROR_INVALID_PARAMETER; - if (!type || !cpu_freq) + if (!type || !out_cpu_freq) return RUNTIME_INFO_ERROR_INVALID_PARAMETER; snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_%s_freq", @@ -330,13 +330,13 @@ int runtime_info_get_frequency_cpufreq(int core_idx, char *type, int *cpu_freq) //LCOV_EXCL_STOP } - *cpu_freq = result / 1000; + *out_cpu_freq = result / 1000; fclose(cpufreq_fp); return RUNTIME_INFO_ERROR_NONE; } //LCOV_EXCL_START : fallback routine -int runtime_info_get_frequency_cpuinfo(int core_idx, int *cpu_freq) +int runtime_info_get_frequency_cpuinfo(int core_idx, int *out_cpu_freq) { FILE *cpuinfo_fp; char line[128]; @@ -347,7 +347,7 @@ int runtime_info_get_frequency_cpuinfo(int core_idx, int *cpu_freq) if (core_idx < 0) return RUNTIME_INFO_ERROR_INVALID_PARAMETER; - if (!cpu_freq) + if (!out_cpu_freq) return RUNTIME_INFO_ERROR_INVALID_PARAMETER; cpuinfo_fp = fopen("/proc/cpuinfo", "r"); @@ -369,7 +369,7 @@ int runtime_info_get_frequency_cpuinfo(int core_idx, int *cpu_freq) ++start; } - *cpu_freq = acc_freq; + *out_cpu_freq = acc_freq; fclose(cpuinfo_fp); return RUNTIME_INFO_ERROR_NONE; } diff --git a/src/runtime_info_usage.c b/src/runtime_info_usage.c index 4f2e7fa..d86a2de 100644 --- a/src/runtime_info_usage.c +++ b/src/runtime_info_usage.c @@ -89,10 +89,10 @@ static GVariant *runtime_info_append_args(int *args, int size) static GVariant *runtime_info_dbus_request_usage_info(runtime_info_usage_type_e type, int *pid, int size, int *error) { - int ret; + int ret_dbus; GVariant *args_in = NULL; - GVariant *args_out = NULL; - GVariant *usage; + GVariant *reply = NULL; + GVariant *ret; /* Check parameter */ switch (type) { @@ -154,13 +154,13 @@ static GVariant *runtime_info_dbus_request_usage_info(runtime_info_usage_type_e _D("Process %d: Sending dbus message to resourced for %s info", getpid(), dbus_info[type].caption); - ret = dbus_handle_method_sync_with_reply_var(RESOURCED_BUS_NAME, + ret_dbus = dbus_handle_method_sync_with_reply_var(RESOURCED_BUS_NAME, RESOURCED_USAGE_OBJECT_NAME, RESOURCED_USAGE_INTERFACE_NAME, dbus_info[type].method_name, - args_in, &args_out); + args_in, &reply); - if (ret < 0) { + if (ret_dbus < 0) { //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: not able to send message"); @@ -168,10 +168,10 @@ static GVariant *runtime_info_dbus_request_usage_info(runtime_info_usage_type_e //LCOV_EXCL_STOP } - usage = g_variant_get_child_value(args_out, 0); - g_variant_unref(args_out); + ret = g_variant_get_child_value(reply, 0); + g_variant_unref(reply); - return usage; + return ret; } static int runtime_info_get_all_apps_usage(runtime_info_usage_type_e type, @@ -308,7 +308,7 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ { int i; int error; - GVariant *usages; + GVariant *reply; GVariantIter iter; if (!pid || size <= 0) { @@ -326,8 +326,8 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ *info = NULL; /* Get the needed information from resourced daemon using dbus */ - usages = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_MEMORY, pid, size, &error); - if (!usages) { + reply = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_MEMORY, pid, size, &error); + if (!reply) { //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: call to resourced not successful"); return error; @@ -335,11 +335,11 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ } /* Check whether the received usage has expected format or not */ - if (g_strcmp0(g_variant_get_type_string(usages), "a(iiiiiii)") || - g_variant_n_children(usages) != size) { + if (g_strcmp0(g_variant_get_type_string(reply), "a(iiiiiii)") || + g_variant_n_children(reply) != size) { //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: received dbus message is not in expected format"); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_REMOTE_IO; //LCOV_EXCL_STOP } @@ -348,11 +348,11 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ *info = (process_memory_info_s *)malloc(size * sizeof(process_memory_info_s)); if (!(*info)) { _E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; } - g_variant_iter_init(&iter, usages); + g_variant_iter_init(&iter, reply); for (i = 0; i < size; i++) g_variant_iter_next(&iter, "(iiiiiii)", &((*info)[i].vsz), @@ -363,7 +363,7 @@ API int runtime_info_get_process_memory_info(int *pid, int size, process_memory_ &((*info)[i].private_clean), &((*info)[i].private_dirty)); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_NONE; } @@ -393,24 +393,24 @@ static runtime_info_error_e hal_error_to_runtime_info_error(int err) static int get_process_memory_info_direct(int *pid, int size, process_memory_info_key_e key, int **info) { - int ret, i; + int ret_hal, i; struct gpu_info gpu_info; struct gem_info gem_info; int *result; - int err = RUNTIME_INFO_ERROR_NONE; + int ret = RUNTIME_INFO_ERROR_NONE; result = (int *)calloc(size, sizeof(int)); if (!result) { - err = RUNTIME_INFO_ERROR_OUT_OF_MEMORY; + ret = RUNTIME_INFO_ERROR_OUT_OF_MEMORY; goto out; } switch (key) { case RUNTIME_INFO_PROC_MEMORY_GPU: for (i = 0; i < size; ++i) { - ret = hal_device_memory_get_gpu_info(pid[i], &gpu_info); - if (ret != 0) { - err = hal_error_to_runtime_info_error(ret); + ret_hal = hal_device_memory_get_gpu_info(pid[i], &gpu_info); + if (ret_hal != 0) { + ret = hal_error_to_runtime_info_error(ret_hal); goto out; } result[i] = gpu_info.used_pages; @@ -419,9 +419,9 @@ static int get_process_memory_info_direct(int *pid, int size, process_memory_inf break; case RUNTIME_INFO_PROC_MEMORY_GEM_RSS: for (i = 0; i < size; ++i) { - ret = hal_device_memory_get_gem_info(pid[i], &gem_info); + ret_hal = hal_device_memory_get_gem_info(pid[i], &gem_info); if (ret != 0) { - err = hal_error_to_runtime_info_error(ret); + ret = hal_error_to_runtime_info_error(ret_hal); goto out; } result[i] = gem_info.rss; @@ -429,22 +429,22 @@ static int get_process_memory_info_direct(int *pid, int size, process_memory_inf *info = result; break; default: - err = RUNTIME_INFO_ERROR_INVALID_PARAMETER; + ret = RUNTIME_INFO_ERROR_INVALID_PARAMETER; break; } out: - if (err != RUNTIME_INFO_ERROR_NONE) + if (ret != RUNTIME_INFO_ERROR_NONE) free(result); - return err; + return ret; } static int get_process_memory_swap_info(int *pid, int size, int **info) { int i, temp; int error; - GVariant *usages; + GVariant *reply; GVariantIter iter; if (!pid || size <= 0) { @@ -462,8 +462,8 @@ static int get_process_memory_swap_info(int *pid, int size, int **info) *info = NULL; /* Get the needed information from resourced daemon using dbus */ - usages = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_SWAP, pid, size, &error); - if (!usages) { + reply = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_SWAP, pid, size, &error); + if (!reply) { //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: call to resourced not successful"); return error; @@ -471,11 +471,11 @@ static int get_process_memory_swap_info(int *pid, int size, int **info) } /* Check whether the received usage has expected format or not */ - if (g_strcmp0(g_variant_get_type_string(usages), "a(i)") || - g_variant_n_children(usages) != size) { + if (g_strcmp0(g_variant_get_type_string(reply), "a(i)") || + g_variant_n_children(reply) != size) { //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: received dbus message is not in expected format"); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_REMOTE_IO; //LCOV_EXCL_STOP } @@ -484,17 +484,17 @@ static int get_process_memory_swap_info(int *pid, int size, int **info) *info = (int *)malloc(size * sizeof(int)); if (!(*info)) { _E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; } - g_variant_iter_init(&iter, usages); + g_variant_iter_init(&iter, reply); for (i = 0; i < size; i++) { g_variant_iter_next(&iter, "(i)", &temp); (*info)[i] = temp; } - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_NONE; } @@ -639,7 +639,7 @@ API int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage { int i; int error; - GVariant *usages; + GVariant *reply; GVariantIter iter; if (!pid || size <= 0) { @@ -657,8 +657,8 @@ API int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage *usage = NULL; /* Get the needed information from resourced daemon using dbus */ - usages = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_CPU, pid, size, &error); - if (!usages) { + reply = runtime_info_dbus_request_usage_info(USAGE_TYPE_PROCESS_CPU, pid, size, &error); + if (!reply) { //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: call to resourced not successful"); return error; @@ -666,11 +666,11 @@ API int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage } /* Check whether the received usage has expected format or not */ - if (g_strcmp0(g_variant_get_type_string(usages), "a(ii)") || - g_variant_n_children(usages) != size) { + if (g_strcmp0(g_variant_get_type_string(reply), "a(ii)") || + g_variant_n_children(reply) != size) { //LCOV_EXCL_START : system error _E("DBUS_METHOD_CALL: received dbus message is not in expected format"); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_REMOTE_IO; //LCOV_EXCL_STOP } @@ -680,16 +680,16 @@ API int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage if (!(*usage)) { //LCOV_EXCL_START : system error _E("OUT_OF_MEMORY(0x%08x)", RUNTIME_INFO_ERROR_OUT_OF_MEMORY); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_STOP } - g_variant_iter_init(&iter, usages); + g_variant_iter_init(&iter, reply); for (i = 0; i < size; i++) g_variant_iter_next(&iter, "(ii)", &((*usage)[i].utime), &((*usage)[i].stime)); - g_variant_unref(usages); + g_variant_unref(reply); return RUNTIME_INFO_ERROR_NONE; } diff --git a/src/runtime_info_vconf.c b/src/runtime_info_vconf.c index d60a241..8bbab66 100644 --- a/src/runtime_info_vconf.c +++ b/src/runtime_info_vconf.c @@ -43,16 +43,16 @@ } \ } while (0); -int runtime_info_vconf_get_value_int(const char *vconf_key, int *value) +int runtime_info_vconf_get_value_int(const char *vconf_key, int *out_value) { - int ret = vconf_get_int(vconf_key, value); + int ret = vconf_get_int(vconf_key, out_value); CHECK_VCONF_RESULT(ret); return ret; } -int runtime_info_vconf_get_value_bool(const char *vconf_key, int *value) +int runtime_info_vconf_get_value_bool(const char *vconf_key, int *out_value) { - int ret = vconf_get_bool(vconf_key, value); + int ret = vconf_get_bool(vconf_key, out_value); CHECK_VCONF_RESULT(ret); return ret; } -- 2.34.1