diff options
-rw-r--r-- | inc/launchpad_common.h | 2 | ||||
-rwxr-xr-x | src/launchpad.c | 16 | ||||
-rw-r--r-- | src/launchpad_common.c | 15 |
3 files changed, 20 insertions, 13 deletions
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 63a9de3..93ba100 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -105,7 +105,7 @@ void _appinfo_free(appinfo_t *menu_info); char *_appinfo_get_app_path(appinfo_t *menu_info); int _proc_get_attr_by_pid(int pid, char *buf, int size); int _close_all_fds(void); -void _get_cpu_idle(long long *total, long long *idle); +void _get_cpu_idle(unsigned long long *total, unsigned long long *idle); int _setup_stdio(const char *ident); #endif /* __LAUNCHPAD_COMMON_H__ */ diff --git a/src/launchpad.c b/src/launchpad.c index 9177a5f..2c38f2b 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -74,8 +74,8 @@ typedef struct { char *loader_extra; int detection_method; int timeout_val; - long long cpu_total_time; - long long cpu_idle_time; + unsigned long long cpu_total_time; + unsigned long long cpu_idle_time; guint idle_checker; } candidate_process_context_t; @@ -1082,8 +1082,8 @@ static gboolean __handle_label_monitor(gpointer data) static gboolean __handle_idle_checker(gpointer data) { - long long total = 0; - long long idle = 0; + unsigned long long total = 0; + unsigned long long idle = 0; int per; candidate_process_context_t *cpc = data; @@ -1109,8 +1109,8 @@ static int __dispatch_cmd_hint(bundle *kb, int detection_method) { candidate_process_context_t *cpc; GList *iter = candidate_slot_list; - long long total = 0; - long long idle = 0; + unsigned long long total = 0; + unsigned long long idle = 0; _W("cmd hint %d", detection_method); while (iter) { @@ -1575,8 +1575,8 @@ static void __add_slot_from_info(gpointer data, gpointer user_data) candidate_process_context_t *cpc; bundle_raw *extra = NULL; int len; - long long total = 0; - long long idle = 0; + unsigned long long total = 0; + unsigned long long idle = 0; if (!strcmp(info->exe, "null")) { cpc = __add_slot(LAUNCHPAD_TYPE_USER + user_slot_offset, diff --git a/src/launchpad_common.c b/src/launchpad_common.c index e71c511..a92e5b6 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -72,13 +72,13 @@ static int __read_proc(const char *path, char *buf, int size) return ret; } -void _get_cpu_idle(long long *total, long long *idle) +void _get_cpu_idle(unsigned long long *total, unsigned long long *idle) { FILE *fp; int i; - long long sum = 0; - long long val; - long long iv = 0; + unsigned long long sum = 0; + unsigned long long val; + unsigned long long iv = 0; char buf[4] = { 0, }; fp = fopen("/proc/stat", "rt"); @@ -96,6 +96,13 @@ void _get_cpu_idle(long long *total, long long *idle) fclose(fp); return; } + + if (sum + val < sum) { + _E("overflow"); + fclose(fp); + return; + } + sum += val; if (i == 3) /* idle */ iv = val; |