diff --git a/include/event.h b/include/event.h index cac3d15e1..bb9737f8e 100644 --- a/include/event.h +++ b/include/event.h @@ -14,13 +14,13 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons #define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0) #define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len)) -size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); -size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); int event_ctx_init (hashcat_ctx_t *hashcat_ctx); void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/logfile.h b/include/logfile.h index 8ffc6e192..09f591121 100644 --- a/include/logfile.h +++ b/include/logfile.h @@ -36,7 +36,7 @@ void logfile_generate_topid (hashcat_ctx_t *hashcat_ctx); void logfile_generate_subid (hashcat_ctx_t *hashcat_ctx); -void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); int logfile_init (hashcat_ctx_t *hashcat_ctx); void logfile_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/src/Makefile b/src/Makefile index 6a59b14b0..183d14ece 100644 --- a/src/Makefile +++ b/src/Makefile @@ -116,6 +116,7 @@ CFLAGS += -Winit-self CFLAGS += -Werror-implicit-function-declaration CFLAGS += -Wformat CFLAGS += -ftrapv +CFLAGS += -Wno-format-zero-length # the following compiler options produce warnings that should be fixed at some time diff --git a/src/combinator.c b/src/combinator.c index e498e7869..ae2a4d6a8 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -68,7 +68,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISDIR (tmp_stat.st_mode)) { - event_log_error (hashcat_ctx, "%s must be a regular file", dictfile1, strerror (errno)); + event_log_error (hashcat_ctx, "%s must be a regular file", dictfile1); fclose (fp1); @@ -96,7 +96,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISDIR (tmp_stat.st_mode)) { - event_log_error (hashcat_ctx, "%s must be a regular file", dictfile2, strerror (errno)); + event_log_error (hashcat_ctx, "%s must be a regular file", dictfile2); fclose (fp1); fclose (fp2); diff --git a/src/convert.c b/src/convert.c index 030eef233..d842963f7 100644 --- a/src/convert.c +++ b/src/convert.c @@ -374,7 +374,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.5 + (double) in_len) * 8) / 5); // ceil (in_len * 8 / 5) + int out_len = (int) (((0.5f + (double) in_len) * 8) / 5); // ceil (in_len * 8 / 5) while (out_len % 8) { @@ -441,7 +441,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.5 + (double) in_len) * 8) / 6); // ceil (in_len * 8 / 6) + int out_len = (int) (((0.5f + (double) in_len) * 8) / 6); // ceil (in_len * 8 / 6) while (out_len % 4) { diff --git a/src/hashcat.c b/src/hashcat.c index 0671d517b..bde41d8f7 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -263,8 +263,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->runtime_stop = runtime_stop; - logfile_sub_uint (runtime_start); - logfile_sub_uint (runtime_stop); + logfile_sub_uint ((u32) runtime_start); + logfile_sub_uint ((u32) runtime_stop); time (&status_ctx->prepare_start); @@ -1088,8 +1088,8 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) const time_t proc_stop = time (NULL); - logfile_top_uint (proc_start); - logfile_top_uint (proc_stop); + logfile_top_uint ((u32) proc_start); + logfile_top_uint ((u32) proc_stop); logfile_top_msg ("STOP"); diff --git a/src/hwmon.c b/src/hwmon.c index 19c612230..12d687386 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -3032,11 +3032,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - int engine_clock_max = (int) (0.6666 * caps.sEngineClockRange.iMax); - int memory_clock_max = (int) (0.6250 * caps.sMemoryClockRange.iMax); + int engine_clock_max = (int) (0.6666f * caps.sEngineClockRange.iMax); + int memory_clock_max = (int) (0.6250f * caps.sMemoryClockRange.iMax); - int warning_trigger_engine = (int) (0.25 * engine_clock_max); - int warning_trigger_memory = (int) (0.25 * memory_clock_max); + int warning_trigger_engine = (int) (0.25f * engine_clock_max); + int warning_trigger_memory = (int) (0.25f * memory_clock_max); int engine_clock_profile_max = hwmon_ctx->od_clock_mem_status[device_id].state.aLevels[1].iEngineClock; int memory_clock_profile_max = hwmon_ctx->od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock; diff --git a/src/main.c b/src/main.c index d4ecc6515..9068aa192 100644 --- a/src/main.c +++ b/src/main.c @@ -719,11 +719,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); + event_log_info_nn (hashcat_ctx, "Parsing Hashes: %u/%u (%0.2f%%)...", hashes_cnt, hashes_avail, (hashes_cnt / hashes_avail) * 100.0f); } else { - event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, 100); + event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, 100.0f); } } diff --git a/src/terminal.c b/src/terminal.c index 3694f6e71..a7eb555b1 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -509,8 +509,8 @@ void opencl_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, " Processor(s) : %u", device_processors); event_log_info (hashcat_ctx, " Clock : %u", device_maxclock_frequency); event_log_info (hashcat_ctx, " Memory : %" PRIu64 "/%" PRIu64 " MB allocatable", device_maxmem_alloc / 1024 / 1024, device_global_mem / 1024 / 1024); - event_log_info (hashcat_ctx, " OpenCL Version : %u", device_opencl_version); - event_log_info (hashcat_ctx, " Driver Version : %u", driver_version); + event_log_info (hashcat_ctx, " OpenCL Version : %s", device_opencl_version); + event_log_info (hashcat_ctx, " Driver Version : %s", driver_version); event_log_info (hashcat_ctx, ""); } } @@ -546,7 +546,7 @@ void opencl_info_compact (hashcat_ctx_t *hashcat_ctx) line[len] = 0; - event_log_info (hashcat_ctx, line); + event_log_info (hashcat_ctx, "%s", line); } else { @@ -566,12 +566,12 @@ void opencl_info_compact (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped == false) { - event_log_info (hashcat_ctx, "* Device #%u: %s, %lu/%lu MB allocatable, %uMCU", + event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB allocatable, %uMCU", devices_idx + 1, device_name, - (unsigned int) (device_maxmem_alloc / 1024 / 1024), - (unsigned int) (device_global_mem / 1024 / 1024), - (unsigned int) device_processors); + device_maxmem_alloc / 1024 / 1024, + device_global_mem / 1024 / 1024, + device_processors); } else {