1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 01:50:10 +00:00

More clang tidy fixes

This commit is contained in:
Rosen Penev 2017-11-05 01:52:29 -07:00
parent 0555613305
commit 3ba84f17f1
12 changed files with 189 additions and 191 deletions

View File

@ -134,7 +134,7 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par
char *iconv_tmp = NULL;
if (strcmp (user_options->encoding_from, user_options->encoding_to))
if (strcmp (user_options->encoding_from, user_options->encoding_to) != 0)
{
iconv_enabled = true;
@ -278,8 +278,6 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par
{
iconv_close (iconv_ctx);
iconv_enabled = false;
hcfree (iconv_tmp);
}

View File

@ -589,7 +589,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
*/
hash_t *hashes_buf = (hash_t *) hccalloc (hashes_avail, sizeof (hash_t));
void *digests_buf = (void *) hccalloc (hashes_avail, hashconfig->dgst_size);
void *digests_buf = hccalloc (hashes_avail, hashconfig->dgst_size);
salt_t *salts_buf = NULL;
void *esalts_buf = NULL;
void *hook_salts_buf = NULL;
@ -630,7 +630,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->esalt_size > 0)
{
esalts_buf = (void *) hccalloc (hashes_avail, hashconfig->esalt_size);
esalts_buf = hccalloc (hashes_avail, hashconfig->esalt_size);
}
if (hashconfig->hook_salt_size > 0)
@ -1225,7 +1225,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
* Now generate all the buffers required for later
*/
void *digests_buf_new = (void *) hccalloc (hashes_cnt, hashconfig->dgst_size);
void *digests_buf_new = hccalloc (hashes_cnt, hashconfig->dgst_size);
salt_t *salts_buf_new = NULL;
void *esalts_buf_new = NULL;
void *hook_salts_buf_new = NULL;
@ -1241,12 +1241,12 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->esalt_size > 0)
{
esalts_buf_new = (void *) hccalloc (hashes_cnt, hashconfig->esalt_size);
esalts_buf_new = hccalloc (hashes_cnt, hashconfig->esalt_size);
}
if (hashconfig->hook_salt_size > 0)
{
hook_salts_buf_new = (void *) hccalloc (hashes_cnt, hashconfig->hook_salt_size);
hook_salts_buf_new = hccalloc (hashes_cnt, hashconfig->hook_salt_size);
}
EVENT (EVENT_HASHLIST_SORT_SALT_PRE);
@ -1547,18 +1547,18 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
void *st_esalts_buf = NULL;
void *st_hook_salts_buf = NULL;
st_digests_buf = (void *) hccalloc (1, hashconfig->dgst_size);
st_digests_buf = hccalloc (1, hashconfig->dgst_size);
st_salts_buf = (salt_t *) hccalloc (1, sizeof (salt_t));
if (hashconfig->esalt_size > 0)
{
st_esalts_buf = (void *) hccalloc (1, hashconfig->esalt_size);
st_esalts_buf = hccalloc (1, hashconfig->esalt_size);
}
if (hashconfig->hook_salt_size > 0)
{
st_hook_salts_buf = (void *) hccalloc (1, hashconfig->hook_salt_size);
st_hook_salts_buf = hccalloc (1, hashconfig->hook_salt_size);
}
hash_t hash;

View File

@ -2563,7 +2563,8 @@ int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev
return Temperature.iTemperature / 1000;
}
else if (hwmon_ctx->hm_device[device_id].od_version == 6)
if (hwmon_ctx->hm_device[device_id].od_version == 6)
{
int Temperature = 0;
@ -2649,7 +2650,8 @@ int hm_get_fanpolicy_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic
return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1;
}
else // od_version == 6
if (hwmon_ctx->hm_device[device_id].od_version == 6)
{
return 1;
}
@ -2706,7 +2708,8 @@ int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device
return lpFanSpeedValue.iFanSpeed;
}
else // od_version == 6
if (hwmon_ctx->hm_device[device_id].od_version == 6)
{
ADLOD6FanSpeedInfo faninfo;
@ -3108,7 +3111,8 @@ int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 de
return 0;
}
else // od_version == 6
if (hwmon_ctx->hm_device[device_id].od_version == 6)
{
ADLOD6FanSpeedValue fan_speed_value;
@ -3140,7 +3144,8 @@ int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 de
return 0;
}
else // od_version == 6
if (hwmon_ctx->hm_device[device_id].od_version == 6)
{
if (hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl) == -1)
{
@ -3189,7 +3194,8 @@ int hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx_t *hashcat_ctx, const u32
return 0;
}
else
if (fanpolicy != 1)
{
NV_GPU_COOLER_LEVELS CoolerLevels;

File diff suppressed because it is too large Load Diff

View File

@ -101,7 +101,7 @@ static int mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf)
{
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
u32 salt_len = (u32) salt_buf->salt_len;
u32 salt_len = salt_buf->salt_len;
u8 *salt_buf_ptr = (u8 *) salt_buf->salt_buf;
u32 css_cnt_salt = mask_ctx->css_cnt + salt_len;
@ -201,7 +201,7 @@ static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *cs
return 0;
}
static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt)
static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, const u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -569,7 +569,7 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
}
else
{
char mp_file[1024] = { 0 };
char mp_file[1024];
const size_t nread = hc_fread (mp_file, 1, sizeof (mp_file) - 1, fp);
@ -581,10 +581,8 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
return -1;
}
else
{
fclose (fp);
}
fclose (fp);
if (nread == 0)
{
@ -749,7 +747,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
u64 z = *ptr++;
memcpy (root_stats_buf, ptr, sizeof (u64) * SP_ROOT_CNT); ptr += SP_ROOT_CNT;
memcpy (markov_stats_buf, ptr, sizeof (u64) * SP_MARKOV_CNT); ptr += SP_MARKOV_CNT;
memcpy (markov_stats_buf, ptr, sizeof (u64) * SP_MARKOV_CNT); // ptr += SP_MARKOV_CNT;
hcfree (inbuf);
hcfree (outbuf);

View File

@ -67,10 +67,8 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
return 0;
}
else
{
fclose (fd_drm);
}
fclose (fd_drm);
if (vendor != 4098) return 0;
@ -2011,7 +2009,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
if (hashes->salts_shown[salt_pos] == 1)
{
status_ctx->words_progress_done[salt_pos] += (u64) pws_cnt * (u64) innerloop_left;
status_ctx->words_progress_done[salt_pos] += (u64) pws_cnt * innerloop_left;
continue;
}
@ -2293,7 +2291,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
* speed
*/
const u64 perf_sum_all = (u64) pws_cnt * (u64) innerloop_left;
const u64 perf_sum_all = (u64) pws_cnt * innerloop_left;
const double speed_msec = hc_timer_get (device_param->timer_speed);
@ -5459,7 +5457,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
device_param->kernel_params_mp_buf32[7] = 0;
}
for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; }
for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_mem), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; }
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
@ -5476,8 +5474,8 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1;
if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1;
for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
}
hardware_power_all += device_param->hardware_power;
@ -5751,8 +5749,8 @@ int opencl_session_update_mp (hashcat_ctx_t *hashcat_ctx)
int CL_rc = CL_SUCCESS;
for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; }
for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; }
for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_ulong), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; }
for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_uint), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; }
CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1;
CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1;
@ -5783,13 +5781,13 @@ int opencl_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l
int CL_rc = CL_SUCCESS;
for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 9; i < 9; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_uint), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 9; i < 9; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; }
for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
for (u32 i = 4; i < 7; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
for (u32 i = 8; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
for (u32 i = 4; i < 7; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_uint), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
for (u32 i = 8; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; }
CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1;
CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1;

View File

@ -52,7 +52,7 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
plain_buf[i] = pw.i[i];
}
plain_len = (int) apply_rules_optimized (straight_ctx->kernel_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], (u32) pw.pw_len);
plain_len = apply_rules_optimized (straight_ctx->kernel_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], pw.pw_len);
}
else
{
@ -61,7 +61,7 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
plain_buf[i] = pw.i[i];
}
plain_len = (int) apply_rules (straight_ctx->kernel_rules_buf[off].cmds, plain_buf, pw.pw_len);
plain_len = apply_rules (straight_ctx->kernel_rules_buf[off].cmds, plain_buf, pw.pw_len);
}
if (plain_len > (int) hashconfig->pw_max) plain_len = (int) hashconfig->pw_max;

View File

@ -42,8 +42,8 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
hash_buf.digest = hcmalloc (dgst_size);
if (is_salted == true) hash_buf.salt = (salt_t *) hcmalloc (sizeof (salt_t));
if (esalt_size > 0) hash_buf.esalt = (void *) hcmalloc (esalt_size);
if (hook_salt_size > 0) hash_buf.hook_salt = (void *) hcmalloc (hook_salt_size);
if (esalt_size > 0) hash_buf.esalt = hcmalloc (esalt_size);
if (hook_salt_size > 0) hash_buf.hook_salt = hcmalloc (hook_salt_size);
u32 digest_buf[64] = { 0 };

View File

@ -283,7 +283,7 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
tmp_buf[tmp_len++] = 'X';
tmp_buf[tmp_len++] = '[';
exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
exec_hexify ((const u8 *) plain_ptr, plain_len, tmp_buf + tmp_len);
tmp_len += plain_len * 2;
@ -602,7 +602,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (is_hexify ((const u8 *) essid_pos, (const int) essid_len) == true)
{
essid_len = exec_unhexify ((const u8 *) essid_pos, (int) essid_len, (u8 *) essid_pos, (int) essid_len);
essid_len = exec_unhexify ((const u8 *) essid_pos, essid_len, (u8 *) essid_pos, essid_len);
}
if (essid_len > 32) continue;

View File

@ -17,10 +17,8 @@ static int conv_pos (const u8 c, const int pos_mem)
{
return pos_mem;
}
else
{
return conv_ctoi (c);
}
return conv_ctoi (c);
}
static void MANGLE_TOGGLE_AT (char *arr, const int pos)

View File

@ -133,7 +133,7 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
plain_buf[i] = pw.i[i];
}
plain_len = (int) apply_rules (straight_ctx->kernel_rules_buf[off].cmds, plain_buf, pw.pw_len);
plain_len = apply_rules (straight_ctx->kernel_rules_buf[off].cmds, plain_buf, pw.pw_len);
}
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;

View File

@ -242,7 +242,7 @@ void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len
{
if (device_param->pws_cnt < device_param->kernel_power)
{
pw_t *pw = (pw_t *) device_param->pws_buf + device_param->pws_cnt;
pw_t *pw = device_param->pws_buf + device_param->pws_cnt;
u8 *ptr = (u8 *) pw->i;
@ -538,7 +538,7 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx)
* iconv
*/
if (strcmp (user_options->encoding_from, user_options->encoding_to))
if (strcmp (user_options->encoding_from, user_options->encoding_to) != 0)
{
wl_data->iconv_enabled = true;