From: Kichan Kwon Date: Wed, 14 Jun 2017 06:20:32 +0000 (+0900) Subject: Modify the parameter type of runtime_info_app_usage_get_count X-Git-Tag: submit/tizen/20170620.010939~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F133986%2F1;p=platform%2Fcore%2Fapi%2Fruntime-info.git Modify the parameter type of runtime_info_app_usage_get_count - Modify the variable "count" from unsigned int to int - Other app usage APIs use int for indexing - "count" can be used for iteration which "int i" is usually used - e.g. for (i = 0; i < count; i ++) Change-Id: I2685199c3e401c0875602e1c78253f383da77a6f Signed-off-by: Kichan Kwon --- diff --git a/include/runtime_info.h b/include/runtime_info.h index cd5a0ae..d49b6e4 100644 --- a/include/runtime_info.h +++ b/include/runtime_info.h @@ -424,7 +424,7 @@ int runtime_info_app_usage_destroy(app_usage_h handle); * @see runtime_info_get_all_apps_memory_usage() * @see runtime_info_get_all_apps_cpu_rate() */ -int runtime_info_app_usage_get_count(app_usage_h handle, unsigned int *count); +int runtime_info_app_usage_get_count(app_usage_h handle, int *count); /** @@ -489,7 +489,7 @@ int runtime_info_app_usage_get_usage(app_usage_h handle, int index, unsigned int * void print_memory_usage(void) * { * int i; - * unsigned int count; + * int count; * app_usage_h mem_usage_handle; * char *appid; * unsigned int usage; @@ -534,7 +534,7 @@ int runtime_info_get_all_apps_memory_usage(app_usage_h *usage); * void print_cpu_usage(void) * { * int i; - * unsigned int count; + * int count; * app_usage_h cpu_rate_handle; * char *appid; * unsigned int rate; diff --git a/include/runtime_info_private.h b/include/runtime_info_private.h index 6486d94..104f738 100644 --- a/include/runtime_info_private.h +++ b/include/runtime_info_private.h @@ -60,7 +60,7 @@ struct app_usage_s { }; struct app_usages_s { - unsigned int len; + int len; struct app_usage_s *list; }; diff --git a/src/runtime_info_usage.c b/src/runtime_info_usage.c index bb63755..1adaec8 100644 --- a/src/runtime_info_usage.c +++ b/src/runtime_info_usage.c @@ -220,6 +220,11 @@ static int runtime_info_get_all_apps_usage(runtime_info_usage_type_e type, /* Populate the entries of info array using the data received from resourced */ len = g_variant_n_children(reply); + if (len <= 0) { + _E("NO_DATA(0x%08x) : there is no registered app", RUNTIME_INFO_ERROR_NO_DATA); + g_variant_unref(reply); + return RUNTIME_INFO_ERROR_NO_DATA; + } usages = calloc(1, sizeof(struct app_usages_s)); if (!usages) { @@ -228,7 +233,7 @@ static int runtime_info_get_all_apps_usage(runtime_info_usage_type_e type, return RUNTIME_INFO_ERROR_OUT_OF_MEMORY; } - usages->len = len; + usages->len = (int)len; usages->list = calloc(len, sizeof(struct app_usage_s)); if (!usages->list) { @@ -636,7 +641,7 @@ API int runtime_info_app_usage_destroy(app_usage_h handle) return RUNTIME_INFO_ERROR_NONE; } -API int runtime_info_app_usage_get_count(app_usage_h handle, unsigned int *count) +API int runtime_info_app_usage_get_count(app_usage_h handle, int *count) { struct app_usages_s *usages = handle;