From 204333885950fa798a491dcdf141f2e928dd497d Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 8 Jul 2016 22:57:27 +0200 Subject: [PATCH] Rewrite some code to workaround strict aliasing rule violation for older compilers Rewrite some variable initializers on older compilers --- docs/changes.txt | 3 ++- src/hashcat.c | 20 ++++++++++++++------ src/shared.c | 9 ++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 78669c4..e84cf3a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -8,7 +8,8 @@ - Add support to compile on FreeBSD - Make use of cl_context_properties[] to clCreateContext(), even if OpenCL specification allow the use of NULL, some runtimes fail without - The Time.Estimated attribute in status display should also show --runtime limit if user set it - +- Fix some strict aliasing rule violation on older compilers +- Fix some variable initializers on older compilers ## ## Bugs diff --git a/src/hashcat.c b/src/hashcat.c index f7b33f4..59e682a 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -4216,8 +4216,11 @@ static void *thread_monitor (void *p) { if (data.hm_nvapi) { - NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info = { 0 }; - NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status = { 0 }; + NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info; + NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status; + + memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1)); + memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1)); perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1); perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1); @@ -14519,10 +14522,15 @@ int main (int argc, char **argv) */ #ifdef HAVE_HWMON - hm_attrs_t hm_adapters_adl[DEVICES_MAX] = { { 0 } }; - hm_attrs_t hm_adapters_nvapi[DEVICES_MAX] = { { 0 } }; - hm_attrs_t hm_adapters_nvml[DEVICES_MAX] = { { 0 } }; - hm_attrs_t hm_adapters_xnvctrl[DEVICES_MAX] = { { 0 } }; + hm_attrs_t hm_adapters_adl[DEVICES_MAX]; + hm_attrs_t hm_adapters_nvapi[DEVICES_MAX]; + hm_attrs_t hm_adapters_nvml[DEVICES_MAX]; + hm_attrs_t hm_adapters_xnvctrl[DEVICES_MAX]; + + memset (hm_adapters_adl, 0, sizeof (hm_adapters_adl)); + memset (hm_adapters_nvapi, 0, sizeof (hm_adapters_nvapi)); + memset (hm_adapters_nvml, 0, sizeof (hm_adapters_nvml)); + memset (hm_adapters_xnvctrl, 0, sizeof (hm_adapters_xnvctrl)); if (gpu_temp_disable == 0) { diff --git a/src/shared.c b/src/shared.c index e7d5dc3..86ddc01 100644 --- a/src/shared.c +++ b/src/shared.c @@ -3489,7 +3489,9 @@ int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspe { if (fanpolicy == 1) { - NV_GPU_COOLER_LEVELS CoolerLevels = { 0 }; + NV_GPU_COOLER_LEVELS CoolerLevels; + + memset (&CoolerLevels, 0, sizeof (NV_GPU_COOLER_LEVELS)); CoolerLevels.Version = GPU_COOLER_LEVELS_VER | sizeof (NV_GPU_COOLER_LEVELS); @@ -6176,9 +6178,10 @@ void ascii_digest (char *out_buf, uint salt_pos, uint digest_pos) uint len = 4096; - uint digest_buf[64] = { 0 }; + u8 datax[256] = { 0 }; - u64 *digest_buf64 = (u64 *) digest_buf; + u64 *digest_buf64 = (u64 *) datax; + u32 *digest_buf = (u32 *) datax; char *digests_buf_ptr = (char *) data.digests_buf; -- 2.25.1