Properly use float for constants where appropriate (bug 14401, bug 14403)
This commit is contained in:
@@ -93,8 +93,8 @@ init_timeout (void)
|
|||||||
|
|
||||||
xtm_task_manager_get_system_info (task_manager, &num_processes, &cpu, &memory_used, &memory_total, &swap_used, &swap_total);
|
xtm_task_manager_get_system_info (task_manager, &num_processes, &cpu, &memory_used, &memory_total, &swap_used, &swap_total);
|
||||||
|
|
||||||
memory_percent = (memory_total != 0) ? memory_used * 100 / (gdouble)memory_total : 0;
|
memory_percent = (memory_total != 0) ? ((memory_used * 100.0f) / (float)memory_total) : 0.0f;
|
||||||
swap_percent = (swap_total != 0) ? swap_used * 100 / (gdouble)swap_total : 0;
|
swap_percent = (swap_total != 0) ? ((swap_used * 100.0f) / (float)swap_total) : 0.0f;
|
||||||
|
|
||||||
g_object_get (settings, "show-memory-in-xbytes", &show_memory_in_xbytes, NULL);
|
g_object_get (settings, "show-memory-in-xbytes", &show_memory_in_xbytes, NULL);
|
||||||
if (show_memory_in_xbytes) {
|
if (show_memory_in_xbytes) {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ xtm_process_monitor_class_init (XtmProcessMonitorClass *klass)
|
|||||||
widget_class->expose_event = xtm_process_monitor_expose;
|
widget_class->expose_event = xtm_process_monitor_expose;
|
||||||
#endif
|
#endif
|
||||||
g_object_class_install_property (class, PROP_STEP_SIZE,
|
g_object_class_install_property (class, PROP_STEP_SIZE,
|
||||||
g_param_spec_float ("step-size", "StepSize", "Step size", 0.1, G_MAXFLOAT, 1, G_PARAM_CONSTRUCT|G_PARAM_READWRITE));
|
g_param_spec_float ("step-size", "StepSize", "Step size", 0.1f, G_MAXFLOAT, 1, G_PARAM_CONSTRUCT|G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (class, PROP_TYPE,
|
g_object_class_install_property (class, PROP_TYPE,
|
||||||
g_param_spec_int ("type", "Type", "Type of graph to render", 0, G_MAXINT, 0, G_PARAM_READWRITE));
|
g_param_spec_int ("type", "Type", "Type of graph to render", 0, G_MAXINT, 0, G_PARAM_READWRITE));
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ void
|
|||||||
xtm_process_monitor_add_peak (XtmProcessMonitor *monitor, gfloat peak)
|
xtm_process_monitor_add_peak (XtmProcessMonitor *monitor, gfloat peak)
|
||||||
{
|
{
|
||||||
g_return_if_fail (XTM_IS_PROCESS_MONITOR (monitor));
|
g_return_if_fail (XTM_IS_PROCESS_MONITOR (monitor));
|
||||||
g_return_if_fail (peak >= 0.0 && peak <= 1.0);
|
g_return_if_fail (peak >= 0.0f && peak <= 1.0f);
|
||||||
|
|
||||||
g_array_prepend_val (monitor->history, peak);
|
g_array_prepend_val (monitor->history, peak);
|
||||||
if (monitor->history->len > 1)
|
if (monitor->history->len > 1)
|
||||||
|
|||||||
@@ -565,12 +565,12 @@ xtm_process_window_set_system_info (XtmProcessWindow *window, guint num_processe
|
|||||||
|
|
||||||
g_object_set (window->statusbar, "num-processes", num_processes, "cpu", cpu, "memory", memory_str, "swap", swap_str, NULL);
|
g_object_set (window->statusbar, "num-processes", num_processes, "cpu", cpu, "memory", memory_str, "swap", swap_str, NULL);
|
||||||
|
|
||||||
xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->cpu_monitor), cpu / 100.0);
|
xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->cpu_monitor), cpu / 100.0f);
|
||||||
g_snprintf (value, sizeof(value), "%.0f", cpu);
|
g_snprintf (value, sizeof(value), "%.0f", cpu);
|
||||||
g_snprintf (text, sizeof(text), _("CPU: %s%%"), value);
|
g_snprintf (text, sizeof(text), _("CPU: %s%%"), value);
|
||||||
gtk_widget_set_tooltip_text (window->cpu_monitor, text);
|
gtk_widget_set_tooltip_text (window->cpu_monitor, text);
|
||||||
|
|
||||||
xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->mem_monitor), memory / 100.0);
|
xtm_process_monitor_add_peak (XTM_PROCESS_MONITOR (window->mem_monitor), memory / 100.0f);
|
||||||
g_snprintf (text, sizeof(text), _("Memory: %s"), memory_str);
|
g_snprintf (text, sizeof(text), _("Memory: %s"), memory_str);
|
||||||
gtk_widget_set_tooltip_text (window->mem_monitor, text);
|
gtk_widget_set_tooltip_text (window->mem_monitor, text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ gboolean get_task_list (GArray *task_list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.cpu_user = (100.0 * ((double) p.p_pctcpu / FSCALE));
|
t.cpu_user = (100.0 * ((double) p.p_pctcpu / FSCALE));
|
||||||
t.cpu_system = 0; /* TODO ? */
|
t.cpu_system = 0.0f; /* TODO ? */
|
||||||
/* get username from uid */
|
/* get username from uid */
|
||||||
passwdp = getpwuid(t.uid);
|
passwdp = getpwuid(t.uid);
|
||||||
if(passwdp != NULL && passwdp->pw_name != NULL)
|
if(passwdp != NULL && passwdp->pw_name != NULL)
|
||||||
@@ -208,8 +208,8 @@ gboolean get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system
|
|||||||
cur_system = cp_time[CP_SYS] + cp_time[CP_INTR];
|
cur_system = cp_time[CP_SYS] + cp_time[CP_INTR];
|
||||||
cur_total = cur_user + cur_system + cp_time[CP_IDLE];
|
cur_total = cur_user + cur_system + cp_time[CP_IDLE];
|
||||||
|
|
||||||
*cpu_user = (old_total > 0) ? (cur_user - old_user) * 100 / (gdouble)(cur_total - old_total) : 0;
|
*cpu_user = (old_total > 0) ? (((cur_user - old_user) * 100.0f) / (float)(cur_total - old_total)) : 0.0f;
|
||||||
*cpu_system = (old_total > 0) ? (cur_system - old_system) * 100 / (gdouble)(cur_total - old_total) : 0;
|
*cpu_system = (old_total > 0) ? (((cur_system - old_system) * 100.0f) / (float)(cur_total - old_total)) : 0.0f;
|
||||||
|
|
||||||
/* get #cpu */
|
/* get #cpu */
|
||||||
size = sizeof(&cpu_count);
|
size = sizeof(&cpu_count);
|
||||||
|
|||||||
@@ -104,11 +104,11 @@ get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
|
|||||||
cp_system = cpu_state[CP_SYS] + cpu_state[CP_INTR];
|
cp_system = cpu_state[CP_SYS] + cpu_state[CP_INTR];
|
||||||
cp_total = cpu_state[CP_IDLE] + cp_user + cp_system;
|
cp_total = cpu_state[CP_IDLE] + cp_user + cp_system;
|
||||||
|
|
||||||
*cpu_user = *cpu_system = 0.0;
|
*cpu_user = *cpu_system = 0.0f;
|
||||||
if (cp_total > cp_total_old)
|
if (cp_total > cp_total_old)
|
||||||
{
|
{
|
||||||
*cpu_user = (cp_user - cp_user_old) * 100 / (gdouble)(cp_total - cp_total_old);
|
*cpu_user = (((cp_user - cp_user_old) * 100.0f) / (float)(cp_total - cp_total_old));
|
||||||
*cpu_system = (cp_system - cp_system_old) * 100 / (gdouble)(cp_total - cp_total_old);
|
*cpu_system = (((cp_system - cp_system_old) * 100.0f) / (float)(cp_total - cp_total_old));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +125,8 @@ get_task_details (kvm_t *kd, struct kinfo_proc *kp, Task *task)
|
|||||||
bzero(task, sizeof(Task));
|
bzero(task, sizeof(Task));
|
||||||
task->pid = kp->ki_pid;
|
task->pid = kp->ki_pid;
|
||||||
task->ppid = kp->ki_ppid;
|
task->ppid = kp->ki_ppid;
|
||||||
task->cpu_user = 100 * ((double)kp->ki_pctcpu / FSCALE);
|
task->cpu_user = 100.0f * ((float)kp->ki_pctcpu / FSCALE);
|
||||||
task->cpu_system = 0;
|
task->cpu_system = 0.0f;
|
||||||
task->vsz = kp->ki_size;
|
task->vsz = kp->ki_size;
|
||||||
task->rss = kp->ki_rssize * getpagesize ();
|
task->rss = kp->ki_rssize * getpagesize ();
|
||||||
pw = getpwuid (kp->ki_uid);
|
pw = getpwuid (kp->ki_uid);
|
||||||
|
|||||||
@@ -98,12 +98,12 @@ get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
|
|||||||
jiffies_system = system;
|
jiffies_system = system;
|
||||||
jiffies_total = jiffies_user + jiffies_system + idle;
|
jiffies_total = jiffies_user + jiffies_system + idle;
|
||||||
|
|
||||||
*cpu_user = *cpu_system = 0.0;
|
*cpu_user = *cpu_system = 0.0f;
|
||||||
if (jiffies_total > jiffies_total_old)
|
if (jiffies_total > jiffies_total_old)
|
||||||
{
|
{
|
||||||
jiffies_total_delta = jiffies_total - jiffies_total_old;
|
jiffies_total_delta = jiffies_total - jiffies_total_old;
|
||||||
*cpu_user = (jiffies_user - jiffies_user_old) * 100 / (gdouble)(jiffies_total_delta);
|
*cpu_user = (((jiffies_user - jiffies_user_old) * 100.0f) / (float)jiffies_total_delta);
|
||||||
*cpu_system = (jiffies_system - jiffies_system_old) * 100 / (gdouble)(jiffies_total_delta);
|
*cpu_system = (((jiffies_system - jiffies_system_old) * 100.0f) / (float)jiffies_total_delta);
|
||||||
}
|
}
|
||||||
*cpu_count = _cpu_count;
|
*cpu_count = _cpu_count;
|
||||||
|
|
||||||
@@ -178,12 +178,12 @@ get_cpu_percent (guint pid, gulong jiffies_user, gfloat *cpu_user, gulong jiffie
|
|||||||
|
|
||||||
if (_cpu_count > 0 && jiffies_total_delta > 0)
|
if (_cpu_count > 0 && jiffies_total_delta > 0)
|
||||||
{
|
{
|
||||||
*cpu_user = (jiffies_user - jiffies_user_old) * 100 / (gdouble)jiffies_total_delta;
|
*cpu_user = (((jiffies_user - jiffies_user_old) * 100.0f) / (float)jiffies_total_delta);
|
||||||
*cpu_system = (jiffies_system - jiffies_system_old) * 100 / (gdouble)jiffies_total_delta;
|
*cpu_system = (((jiffies_system - jiffies_system_old) * 100.0f) / (float)jiffies_total_delta);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*cpu_user = *cpu_system = 0;
|
*cpu_user = *cpu_system = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ get_memory_usage (guint64 *memory_total, guint64 *memory_free, guint64 *memory_c
|
|||||||
gboolean
|
gboolean
|
||||||
get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
|
get_cpu_usage (gushort *cpu_count, gfloat *cpu_user, gfloat *cpu_system)
|
||||||
{
|
{
|
||||||
*cpu_user = *cpu_system = 0.0;
|
*cpu_user = *cpu_system = 0.0f;
|
||||||
*cpu_count = 0; /*_cpu_count;*/
|
*cpu_count = 0; /*_cpu_count;*/
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@@ -112,12 +112,12 @@ get_cpu_percent (guint pid, gulong ticks_user, gfloat *cpu_user, gulong ticks_sy
|
|||||||
|
|
||||||
if (_cpu_count > 0 && ticks_total_delta > 0)
|
if (_cpu_count > 0 && ticks_total_delta > 0)
|
||||||
{
|
{
|
||||||
*cpu_user = (ticks_user - ticks_user_old) * 100 / (gdouble)ticks_total_delta;
|
*cpu_user = (((ticks_user - ticks_user_old) * 100.0f) / (float)ticks_total_delta);
|
||||||
*cpu_system = (ticks_system - ticks_system_old) * 100 / (gdouble)ticks_total_delta;
|
*cpu_system = (((ticks_system - ticks_system_old) * 100.0f) / (float)ticks_total_delta);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*cpu_user = *cpu_system = 0;
|
*cpu_user = *cpu_system = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ get_task_details (guint pid, Task *task)
|
|||||||
pw = getpwuid (process.pr_uid);
|
pw = getpwuid (process.pr_uid);
|
||||||
task->uid = (guint)process.pr_uid;
|
task->uid = (guint)process.pr_uid;
|
||||||
g_strlcpy (task->uid_name, (pw != NULL) ? pw->pw_name : "nobody", sizeof (task->uid_name));
|
g_strlcpy (task->uid_name, (pw != NULL) ? pw->pw_name : "nobody", sizeof (task->uid_name));
|
||||||
get_cpu_percent (task->pid, process.pr_time.tv_sec * 1000 + process.pr_time.tv_nsec / 100000, &task->cpu_user, 0, &task->cpu_system);
|
get_cpu_percent (task->pid, (process.pr_time.tv_sec * 1000 + process.pr_time.tv_nsec / 100000), &task->cpu_user, 0, &task->cpu_system);
|
||||||
|
|
||||||
fclose (file);
|
fclose (file);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user