1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-13 19:28:56 +00:00

Fix -Wfloat-conversion warnings

This commit is contained in:
Rosen Penev 2016-08-28 12:44:19 -07:00
parent d666191d67
commit 88519f9437
No known key found for this signature in database
GPG Key ID: 8B5A63249D3D4CE7

View File

@ -769,7 +769,7 @@ static double get_avg_exec_time (hc_device_param_t *device_param, const int last
{
double exec_ms = device_param->exec_ms[(exec_pos + i) % EXEC_CACHE];
if (exec_ms)
if (exec_ms > 0)
{
exec_ms_sum += exec_ms;
@ -1245,7 +1245,7 @@ void status_display ()
hashes_dev_ms[device_id] = 0;
if (speed_ms[device_id])
if (speed_ms[device_id] > 0)
{
hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id];
@ -1291,11 +1291,11 @@ void status_display ()
#ifdef WIN
__time64_t sec_run = ms_running / 1000;
__time64_t sec_run = (__time64_t) ms_running / 1000;
#else
time_t sec_run = ms_running / 1000;
time_t sec_run = (time_t) ms_running / 1000;
#endif
@ -1408,11 +1408,11 @@ void status_display ()
time_t sec_etc = 0;
#endif
if (hashes_all_ms)
if (hashes_all_ms > 0)
{
u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip;
u64 ms_left = (progress_left_relative_skip - progress_noneed) / hashes_all_ms;
u64 ms_left = (u64) ((progress_left_relative_skip - progress_noneed) / hashes_all_ms);
sec_etc = ms_left / 1000;
}
@ -1782,7 +1782,7 @@ static void status_benchmark_automate ()
hashes_dev_ms[device_id] = 0;
if (speed_ms[device_id])
if (speed_ms[device_id] > 0)
{
hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id];
}
@ -1837,7 +1837,7 @@ static void status_benchmark ()
hashes_dev_ms[device_id] = 0;
if (speed_ms[device_id])
if (speed_ms[device_id] > 0)
{
hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id];
@ -2895,7 +2895,7 @@ static int run_kernel (const uint kern_run, hc_device_param_t *device_param, con
{
if (data.opti_type & OPTI_TYPE_SLOW_HASH_SIMD)
{
num_elements = CEIL ((float) num_elements / device_param->vector_width);
num_elements = CEIL (num_elements / device_param->vector_width);
}
}
@ -2923,7 +2923,7 @@ static int run_kernel (const uint kern_run, hc_device_param_t *device_param, con
return -1;
}
if (device_param->nvidia_spin_damp)
if (device_param->nvidia_spin_damp > 0)
{
if (data.devices_status == STATUS_RUNNING)
{
@ -2931,9 +2931,9 @@ static int run_kernel (const uint kern_run, hc_device_param_t *device_param, con
{
switch (kern_run)
{
case KERN_RUN_1: if (device_param->exec_us_prev1[iteration]) usleep (device_param->exec_us_prev1[iteration] * device_param->nvidia_spin_damp); break;
case KERN_RUN_2: if (device_param->exec_us_prev2[iteration]) usleep (device_param->exec_us_prev2[iteration] * device_param->nvidia_spin_damp); break;
case KERN_RUN_3: if (device_param->exec_us_prev3[iteration]) usleep (device_param->exec_us_prev3[iteration] * device_param->nvidia_spin_damp); break;
case KERN_RUN_1: if (device_param->exec_us_prev1[iteration] > 0) usleep ((__useconds_t)(device_param->exec_us_prev1[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_2: if (device_param->exec_us_prev2[iteration] > 0) usleep ((__useconds_t)(device_param->exec_us_prev2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_3: if (device_param->exec_us_prev3[iteration] > 0) usleep ((__useconds_t)(device_param->exec_us_prev3[iteration] * device_param->nvidia_spin_damp)); break;
}
}
}
@ -3405,7 +3405,7 @@ static int choose_kernel (hc_device_param_t *device_param, const uint attack_exe
const float iter_part = (float) (loop_pos + loop_left) / iter;
const u64 perf_sum_all = pws_cnt * iter_part;
const u64 perf_sum_all = (u64) (pws_cnt * iter_part);
double speed_ms;
@ -3741,8 +3741,8 @@ static int autotune (hc_device_param_t *device_param)
for (u32 f = 1; f < 1024; f++)
{
const u32 kernel_accel_try = (float) kernel_accel_orig * f;
const u32 kernel_loops_try = (float) kernel_loops_orig / f;
const u32 kernel_accel_try = kernel_accel_orig * f;
const u32 kernel_loops_try = kernel_loops_orig / f;
if (kernel_accel_try > kernel_accel_max) break;
if (kernel_loops_try < kernel_loops_min) break;
@ -3782,7 +3782,7 @@ static int autotune (hc_device_param_t *device_param)
{
// this is safe to not overflow kernel_accel_max because of accel_left
kernel_accel = (double) kernel_accel * exec_accel_min;
kernel_accel *= (u32) exec_accel_min;
}
// reset them fake words
@ -5209,7 +5209,7 @@ static u32 get_power (hc_device_param_t *device_param)
{
const double device_factor = (double) device_param->hardware_power / data.hardware_power_all;
const u64 words_left_device = CEIL ((double) kernel_power_final * device_factor);
const u64 words_left_device = (u64) CEIL (kernel_power_final * device_factor);
// work should be at least the hardware power available without any accelerator
@ -15688,11 +15688,11 @@ int main (int argc, char **argv)
return -1;
}
int engine_clock_max = caps.sEngineClockRange.iMax * 0.6666;
int memory_clock_max = caps.sMemoryClockRange.iMax * 0.6250;
int engine_clock_max = (int) (0.6666 * caps.sEngineClockRange.iMax);
int memory_clock_max = (int) (0.6250 * caps.sMemoryClockRange.iMax);
int warning_trigger_engine = (int) (0.25 * (double) engine_clock_max);
int warning_trigger_memory = (int) (0.25 * (double) memory_clock_max);
int warning_trigger_engine = (int) (0.25 * engine_clock_max);
int warning_trigger_memory = (int) (0.25 * memory_clock_max);
int engine_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iEngineClock;
int memory_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock;