Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/modules/battery Modified Files: batget.c e_mod_main.c Log Message: let's just put all things that multiply that could possibly be big numbers be long long to avoid overflows. :) =================================================================== RCS file: /cvs/e/e17/apps/e/src/modules/battery/batget.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- batget.c 4 Mar 2008 01:06:58 -0000 1.5 +++ batget.c 4 Mar 2008 03:35:03 -0000 1.6 @@ -725,7 +725,7 @@ else { 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; @@ -744,7 +744,7 @@ else if (current < 0) time_left = -1; 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; } } @@ -759,7 +759,7 @@ { if (current > 0) { - pwr = ((pwr_now - pwr_empty) * 3600) / current; + pwr = (((long long)pwr_now - (long long)pwr_empty) * 3600) / current; time_left += pwr; } } @@ -1063,18 +1063,18 @@ } ecore_list_destroy(bats); 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) - battery_full = 100 * capacity / acpi_max_design; + battery_full = 100 * (long long)capacity / acpi_max_design; else battery_full = -1; if (rate <= 0) time_left = -1; else { if (have_power) - time_left = (3600 * (acpi_max_full - capacity)) / rate; + time_left = (3600 * ((long long)acpi_max_full - (long long)capacity)) / rate; else - time_left = (3600 * capacity) / rate; + time_left = (3600 * (long long)capacity) / rate; } } } @@ -1290,7 +1290,7 @@ } } 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; time_left = seconds; } =================================================================== RCS file: /cvs/e/e17/apps/e/src/modules/battery/e_mod_main.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -3 -r1.107 -r1.108 --- e_mod_main.c 3 Mar 2008 14:35:26 -0000 1.107 +++ e_mod_main.c 4 Mar 2008 03:35:03 -0000 1.108 @@ -240,7 +240,7 @@ E_CONFIG_LIMIT(battery_config->poll_interval, 4, 4096); E_CONFIG_LIMIT(battery_config->alarm, 0, 60); E_CONFIG_LIMIT(battery_config->alarm_p, 0, 100); - + battery_config->module = m; battery_config->full = -2; ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs