Rewrite some code to workaround strict aliasing rule violation for older compilers
authorjsteube <jens.steube@gmail.com>
Fri, 8 Jul 2016 20:57:27 +0000 (22:57 +0200)
committerjsteube <jens.steube@gmail.com>
Fri, 8 Jul 2016 20:57:27 +0000 (22:57 +0200)
Rewrite some variable initializers on older compilers

docs/changes.txt
src/hashcat.c
src/shared.c

index 78669c4..e84cf3a 100644 (file)
@@ -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
index f7b33f4..59e682a 100644 (file)
@@ -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)
     {
index e7d5dc3..86ddc01 100644 (file)
@@ -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;