From bd780a372953b640c6fc923cc862853cd3fa2465 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 12 Nov 2016 15:20:38 -0800 Subject: [PATCH 1/2] Fix a few float conversion errors --- src/convert.c | 4 ++-- src/hwmon.c | 2 +- src/main.c | 4 ++-- src/monitor.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/convert.c b/src/convert.c index 32369a28d..5914098df 100644 --- a/src/convert.c +++ b/src/convert.c @@ -457,7 +457,7 @@ int base32_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf out_ptr += 8; } - int out_len = (int) (((0.5f + (double) in_len) * 8) / 5); // ceil (in_len * 8 / 5) + int out_len = (int) (((0.5 + in_len) * 8) / 5); // ceil (in_len * 8 / 5) while (out_len % 8) { @@ -524,7 +524,7 @@ int base64_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf out_ptr += 4; } - int out_len = (int) (((0.5f + (double) in_len) * 8) / 6); // ceil (in_len * 8 / 6) + int out_len = (int) (((0.5 + in_len) * 8) / 6); // ceil (in_len * 8 / 6) while (out_len % 4) { diff --git a/src/hwmon.c b/src/hwmon.c index 838a18bd5..a4c0338f5 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -208,7 +208,7 @@ static int hm_SYSFS_set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int return -1; } - val = (float) val * 2.55f; // should be pwm1_max + val = (int) (val * 2.55f); // should be pwm1_max fprintf (fd, "%d", val); diff --git a/src/main.c b/src/main.c index d8b7c565a..baedfd9b6 100644 --- a/src/main.c +++ b/src/main.c @@ -720,11 +720,11 @@ static void main_hashlist_parse_hash (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M if (hashes_cnt < hashes_avail) { - event_log_info_nn (hashcat_ctx, "Parsing Hashes: %u/%u (%0.2f%%)...", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100.0f); + event_log_info_nn (hashcat_ctx, "Parsing Hashes: %u/%u (%0.2f%%)...", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100.0); } else { - event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, 100.0f); + event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, 100.0); } } diff --git a/src/monitor.c b/src/monitor.c index f5562cdfc..799ece4bd 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -193,9 +193,9 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) last_temp_check_time = temp_check_time; - float Kp = 1.8; - float Ki = 0.005; - float Kd = 6; + float Kp = 1.8f; + float Ki = 0.005f; + float Kd = 6.0f; // PID controller (3-term controller: proportional - Kp, integral - Ki, derivative - Kd) From ee2c058dc6c6eb92e7dfced4b1c36cda5d57a427 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 12 Nov 2016 15:21:22 -0800 Subject: [PATCH 2/2] Fix small format warning --- src/event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/event.c b/src/event.c index 312d9faf9..b33f0946f 100644 --- a/src/event.c +++ b/src/event.c @@ -8,6 +8,8 @@ #include "thread.h" #include "event.h" +static int event_log (const char *fmt, va_list ap, char *s, const size_t sz) __attribute__ ((format (printf, 1, 0))); + void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { event_ctx_t *event_ctx = hashcat_ctx->event_ctx;