mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-05 07:02:50 -08:00
cppchecker fixes
This commit is contained in:
parent
49b19376fa
commit
9da0073e0d
tools/hitag2crack
@ -286,7 +286,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
int gpu = 1;
|
||||
err = clGetDeviceIDs(ctx.platform_id, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &(ctx.device_id), NULL);
|
||||
err = clGetDeviceIDs(ctx.platform_id, CL_DEVICE_TYPE_GPU, 1, &(ctx.device_id), NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
printf("Error: Failed to create a device group!: %d\n", err);
|
||||
exit(1);
|
||||
@ -394,7 +394,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
static void try_state(uint64_t s) {
|
||||
Hitag_State hstate;
|
||||
uint64_t keyrev, key, nR1xk;
|
||||
uint64_t keyrev, nR1xk;
|
||||
uint32_t b = 0;
|
||||
|
||||
hstate.shiftreg = s;
|
||||
@ -413,7 +413,7 @@ static void try_state(uint64_t s) {
|
||||
hitag2_init(&hstate, keyrev, uid, nR2);
|
||||
if ((aR2 ^ hitag2_nstep(&hstate, 32)) == 0xffffffff) {
|
||||
|
||||
key = rev64(keyrev);
|
||||
uint64_t key = rev64(keyrev);
|
||||
|
||||
printf("Key: ");
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
@ -208,7 +208,7 @@ int discoverDevices(unsigned int profile_selected, uint32_t device_types_selecte
|
||||
|
||||
err = clGetDeviceIDs((*cd_ctx)[platform_idx].platform_id, CL_DEVICE_TYPE_ALL, ocl_device_max, ocl_devices, &ocl_device_cnt);
|
||||
if (ocl_device_cnt == 0) {
|
||||
if (device_types_selected == CL_DEVICE_TYPE_ALL) printf("No device(s) available with platform id %d\n", platform_idx);
|
||||
if (device_types_selected == CL_DEVICE_TYPE_ALL) printf("No device(s) available with platform id %u\n", platform_idx);
|
||||
(*cd_ctx)[platform_idx].device_cnt = 0;
|
||||
continue;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ int wu_queue_init(wu_queue_ctx_t *ctx, wu_queue_type_t queue_type) {
|
||||
ctx->queue_head = 0; //NULL;
|
||||
ctx->queue_tail = 0; //NULL;
|
||||
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
if ((ret = pthread_mutexattr_init(&ctx->queue_mutex_attr)) != 0) {
|
||||
#if TEST_UNIT == 1
|
||||
@ -353,7 +353,6 @@ int wu_queue_pop(wu_queue_ctx_t *ctx, wu_queue_data_t *wu, short remove) {
|
||||
|
||||
memset(ptr, 0, sizeof(wu_queue_item_t));
|
||||
free(ptr);
|
||||
ptr = 0; //NULL;
|
||||
|
||||
ctx->queue_size--;
|
||||
|
||||
@ -407,7 +406,7 @@ int wu_queue_destroy(wu_queue_ctx_t *ctx) {
|
||||
memset(ctx, 0, sizeof(wu_queue_ctx_t));
|
||||
//ctx = 0; //NULL;
|
||||
|
||||
return (ret == 1) ? NO_ERROR : ERROR_GENERIC;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#if TEST_UNIT == 1
|
||||
|
@ -177,10 +177,10 @@ int thread_init(thread_ctx_t *ctx, short type, size_t thread_count) {
|
||||
}
|
||||
|
||||
int thread_start_scheduler(thread_ctx_t *ctx, thread_args_t *t_arg, wu_queue_ctx_t *queue_ctx) {
|
||||
size_t z = 0;
|
||||
size_t z;
|
||||
bool found = false;
|
||||
bool done = false;
|
||||
unsigned int th_cnt = 0;
|
||||
unsigned int th_cnt;
|
||||
|
||||
if (ctx->type == THREAD_TYPE_SEQ) {
|
||||
bool error = false;
|
||||
@ -265,17 +265,6 @@ int thread_start_scheduler(thread_ctx_t *ctx, thread_args_t *t_arg, wu_queue_ctx
|
||||
if (cur_status == TH_WAIT) {
|
||||
pthread_mutex_lock(&ctx->thread_mutexs[z]);
|
||||
|
||||
if (found) {
|
||||
#if TDEBUG >= 1
|
||||
printf("[%zu] key is found in another thread 1\n", z);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
t_arg[z].status = TH_END;
|
||||
t_arg[z].quit = true;
|
||||
pthread_mutex_unlock(&ctx->thread_mutexs[z]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wu_queue_done(queue_ctx) != QUEUE_EMPTY) {
|
||||
t_arg[z].status = TH_PROCESSING;
|
||||
|
||||
@ -592,9 +581,6 @@ void *computing_process_async(void *arg) {
|
||||
|
||||
pthread_mutex_unlock(&a->thread_ctx->thread_mutexs[z]);
|
||||
|
||||
uint64_t off = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (status == TH_START) {
|
||||
#if TDEBUG >= 1
|
||||
printf("[%s][%zu] plat id %d, uid %u, aR2 %u, nR1 %u, nR2 %u, Initial status: %s\n", __func__, z, ctx->id_platform, uid, aR2, nR1, nR2, thread_status_strdesc(status));
|
||||
@ -670,7 +656,7 @@ void *computing_process_async(void *arg) {
|
||||
|
||||
wu_queue_data_t wu;
|
||||
wu_queue_pop(&ctx->queue_ctx, &wu, false);
|
||||
off = wu.off;
|
||||
uint32_t off = wu.off;
|
||||
a->slice = wu.id + 1;
|
||||
|
||||
float progress = (((wu.id + 1) * 100.0) / wu.max);
|
||||
@ -690,7 +676,7 @@ void *computing_process_async(void *arg) {
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
ret = runKernel(ctx, (uint32_t) off, matches, matches_found, z);
|
||||
int ret = runKernel(ctx, off, matches, matches_found, z);
|
||||
|
||||
if (ret < 1) { // error or nada
|
||||
if (ret == -1) {
|
||||
@ -776,7 +762,7 @@ void *computing_process_async(void *arg) {
|
||||
if (a->r) {
|
||||
pthread_mutex_lock(&a->thread_ctx->thread_mutexs[z]);
|
||||
a->s = matches[match];
|
||||
status = a->status = TH_FOUND_KEY;
|
||||
a->status = TH_FOUND_KEY;
|
||||
a->quit = true;
|
||||
pthread_mutex_unlock(&a->thread_ctx->thread_mutexs[z]);
|
||||
#if TDEBUG >= 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user