Modify the parameter type of runtime_info_app_usage_get_count 86/133986/1
authorKichan Kwon <k_c.kwon@samsung.com>
Wed, 14 Jun 2017 06:20:32 +0000 (15:20 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Wed, 14 Jun 2017 06:29:46 +0000 (15:29 +0900)
- 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 <k_c.kwon@samsung.com>
include/runtime_info.h
include/runtime_info_private.h
src/runtime_info_usage.c

index cd5a0ae..d49b6e4 100644 (file)
@@ -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;
index 6486d94..104f738 100644 (file)
@@ -60,7 +60,7 @@ struct app_usage_s {
 };
 
 struct app_usages_s {
-       unsigned int len;
+       int len;
        struct app_usage_s *list;
 };
 
index bb63755..1adaec8 100644 (file)
@@ -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;