forked from enlightenment/enlightenment
let's just put all things that multiply that could possibly be big numbers be
long long to avoid overflows. :) SVN revision: 33911
This commit is contained in:
parent
617ab30c56
commit
6c8d35abf0
|
@ -725,7 +725,7 @@ linux_sys_class_power_supply_check(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pwr_now < 0)
|
if (pwr_now < 0)
|
||||||
pwr_now = ((capacity * (pwr_full - pwr_empty)) / 100) + pwr_empty;
|
pwr_now = (((long long)capacity * ((long long)pwr_full - (long long)pwr_empty)) / 100) + pwr_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sysev->present) have_battery = 1;
|
if (sysev->present) have_battery = 1;
|
||||||
|
@ -744,7 +744,7 @@ linux_sys_class_power_supply_check(void)
|
||||||
else if (current < 0) time_left = -1;
|
else if (current < 0) time_left = -1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pwr = ((pwr_full - pwr_now) * 3600) / -current;
|
pwr = (((long long)pwr_full - (long long)pwr_now) * 3600) / -current;
|
||||||
if (pwr > time_left) time_left = pwr;
|
if (pwr > time_left) time_left = pwr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ linux_sys_class_power_supply_check(void)
|
||||||
{
|
{
|
||||||
if (current > 0)
|
if (current > 0)
|
||||||
{
|
{
|
||||||
pwr = ((pwr_now - pwr_empty) * 3600) / current;
|
pwr = (((long long)pwr_now - (long long)pwr_empty) * 3600) / current;
|
||||||
time_left += pwr;
|
time_left += pwr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1063,18 +1063,18 @@ linux_acpi_check(void)
|
||||||
}
|
}
|
||||||
ecore_list_destroy(bats);
|
ecore_list_destroy(bats);
|
||||||
if (acpi_max_full > 0)
|
if (acpi_max_full > 0)
|
||||||
battery_full = 100 * capacity / acpi_max_full;
|
battery_full = 100 * (long long)capacity / acpi_max_full;
|
||||||
else if (acpi_max_design > 0)
|
else if (acpi_max_design > 0)
|
||||||
battery_full = 100 * capacity / acpi_max_design;
|
battery_full = 100 * (long long)capacity / acpi_max_design;
|
||||||
else
|
else
|
||||||
battery_full = -1;
|
battery_full = -1;
|
||||||
if (rate <= 0) time_left = -1;
|
if (rate <= 0) time_left = -1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (have_power)
|
if (have_power)
|
||||||
time_left = (3600 * (acpi_max_full - capacity)) / rate;
|
time_left = (3600 * ((long long)acpi_max_full - (long long)capacity)) / rate;
|
||||||
else
|
else
|
||||||
time_left = (3600 * capacity) / rate;
|
time_left = (3600 * (long long)capacity) / rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1290,7 +1290,7 @@ linux_pmu_check(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ecore_list_destroy(bats);
|
ecore_list_destroy(bats);
|
||||||
if (max_charge > 0) battery_full = (charge * 100) / max_charge;
|
if (max_charge > 0) battery_full = ((long long)charge * 100) / max_charge;
|
||||||
else battery_full = 0;
|
else battery_full = 0;
|
||||||
time_left = seconds;
|
time_left = seconds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ e_modapi_init(E_Module *m)
|
||||||
E_CONFIG_LIMIT(battery_config->poll_interval, 4, 4096);
|
E_CONFIG_LIMIT(battery_config->poll_interval, 4, 4096);
|
||||||
E_CONFIG_LIMIT(battery_config->alarm, 0, 60);
|
E_CONFIG_LIMIT(battery_config->alarm, 0, 60);
|
||||||
E_CONFIG_LIMIT(battery_config->alarm_p, 0, 100);
|
E_CONFIG_LIMIT(battery_config->alarm_p, 0, 100);
|
||||||
|
|
||||||
battery_config->module = m;
|
battery_config->module = m;
|
||||||
|
|
||||||
battery_config->full = -2;
|
battery_config->full = -2;
|
||||||
|
|
Loading…
Reference in New Issue