crack5opencl: Fix various printf compilation errors when enabling debug macros

This commit is contained in:
Philippe Teuwen 2024-01-23 15:10:47 +01:00
commit ead228672a
4 changed files with 18 additions and 13 deletions

View file

@ -1,3 +1,4 @@
#include <stdio.h>
#include "ht2crack5opencl.h" #include "ht2crack5opencl.h"
#include "hitag2.h" #include "hitag2.h"

View file

@ -1011,7 +1011,7 @@ int main(int argc, char **argv) {
// at this point z is the max value, still usefulfor free's // at this point z is the max value, still usefulfor free's
#if DEBUGME > 0 #if DEBUGME > 0
printf("[debug] Lower profile between %u device(s) is: %d\n", selected_devices_cnt, profile); printf("[debug] Lower profile between %zu device(s) is: %d\n", selected_devices_cnt, profile);
#endif #endif
uint32_t max_step = profiles[profile][0]; uint32_t max_step = profiles[profile][0];
@ -1102,9 +1102,9 @@ int main(int argc, char **argv) {
if (ctx.thread_sched_type == THREAD_TYPE_ASYNC) { if (ctx.thread_sched_type == THREAD_TYPE_ASYNC) {
size_t th_status_err = 0; size_t th_status_err = 0;
for (z = 0; z < thread_count; z++) { for (z = 0; z < thread_count; z++) {
pthread_mutex_lock(&thread_mutexs[z]); pthread_mutex_lock(&th_ctx.thread_mutexs[z]);
thread_status_t tmp = t_arg[z].status; thread_status_t tmp = t_arg[z].status;
pthread_mutex_unlock(&thread_mutexs[z]); pthread_mutex_unlock(&th_ctx.thread_mutexs[z]);
if (tmp != TH_START) { if (tmp != TH_START) {
printf("! Warning: Thread %zu is not in TH_START, found in %s\n", z, thread_status_strdesc(tmp)); printf("! Warning: Thread %zu is not in TH_START, found in %s\n", z, thread_status_strdesc(tmp));

View file

@ -54,7 +54,7 @@ unsigned int get_smallest_profile(compute_platform_ctx_t *cd_ctx, size_t ocl_pla
if (!cd_ctx[x].device[y].selected) continue; if (!cd_ctx[x].device[y].selected) continue;
#if DEBUGME > 1 #if DEBUGME > 1
printf("[debug] Initial profile for device %zu: %d\n", z, cd_ctx[x].device[y].profile); printf("[debug] Initial profile for device %zu: %d\n", y, cd_ctx[x].device[y].profile);
#endif #endif
// with same devices will be selected the best // with same devices will be selected the best

View file

@ -510,17 +510,17 @@ void *computing_process(void *arg) {
a->slice = wu.id + 1; a->slice = wu.id + 1;
if (ctx->queue_ctx.queue_type == QUEUE_TYPE_RANDOM) { if (ctx->queue_ctx.queue_type == QUEUE_TYPE_RANDOM) {
float progress = 100.0 - (((wu.rem + 1) * 100.0) / wu.max);
#if DEBUGME > 0 #if DEBUGME > 0
printf("[%zu] Slice %zu (off %zu), max %zu, remain %zu slice(s)\n", z, wu.id + 1, wu.off, wu.max, wu.rem); printf("[%zu] Slice %5zu (off %6zu), max %5zu, remain %5zu slice(s)\n", z, wu.id + 1, wu.off, wu.max, wu.rem);
#else #else
printf("\r[%zu] Slice %zu/%zu (%zu remain) ( %2.1f%% )", z, wu.id + 1, wu.max, wu.rem, progress); float progress = 100.0 - (((wu.rem + 1) * 100.0) / wu.max);
printf("\r[%zu] Slice %5zu/%5zu (%5zu remain) ( %2.1f%% )", z, wu.id + 1, wu.max, wu.rem, progress);
#endif // DEBUGME #endif // DEBUGME
} else { } else {
float progress = (((wu.id + 1) * 100.0) / wu.max);
#if DEBUGME > 0 #if DEBUGME > 0
printf("[%zu] Slice %zu/%zu, off %zu\n", z, wu.id + 1, wu.max, wu.off); printf("[%zu] Slice %zu/%zu, off %zu\n", z, wu.id + 1, wu.max, wu.off);
#else #else
float progress = (((wu.id + 1) * 100.0) / wu.max);
printf("\r[%zu] Slice %zu/%zu ( %2.1f%% )", z, wu.id + 1, wu.max, progress); printf("\r[%zu] Slice %zu/%zu ( %2.1f%% )", z, wu.id + 1, wu.max, progress);
#endif // DEBUGME #endif // DEBUGME
} }
@ -588,7 +588,7 @@ void *computing_process_async(void *arg) {
if (status == TH_START) { if (status == TH_START) {
#if TDEBUG >= 1 #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)); printf("[%s][%zu] uid %u, aR2 %u, nR1 %u, nR2 %u, Initial status: %s\n", __func__, z, uid, aR2, nR1, nR2, thread_status_strdesc(status));
#endif #endif
status = TH_WAIT; status = TH_WAIT;
// proceed to next // proceed to next
@ -665,17 +665,17 @@ void *computing_process_async(void *arg) {
a->slice = wu.id + 1; a->slice = wu.id + 1;
if (ctx->queue_ctx.queue_type == QUEUE_TYPE_RANDOM) { if (ctx->queue_ctx.queue_type == QUEUE_TYPE_RANDOM) {
float progress = 100.0 - (((wu.rem + 1) * 100.0) / wu.max);
#if DEBUGME > 0 #if DEBUGME > 0
printf("[%zu] Slice %zu (off %zu), max %zu, remain %zu slice(s)\n", z, wu.id + 1, wu.off, wu.max, wu.rem); printf("[%zu] Slice %5zu (off %6zu), max %5zu, remain %5zu slice(s)\n", z, wu.id + 1, wu.off, wu.max, wu.rem);
#else #else
printf("\r[%zu] Slice %zu/%zu (%zu remain) ( %2.1f%% )", z, wu.id + 1, wu.max, wu.rem, progress); float progress = 100.0 - (((wu.rem + 1) * 100.0) / wu.max);
printf("\r[%zu] Slice %5zu/%5zu (%5zu remain) ( %2.1f%% )", z, wu.id + 1, wu.max, wu.rem, progress);
#endif // DEBUGME #endif // DEBUGME
} else { } else {
float progress = (((wu.id + 1) * 100.0) / wu.max);
#if DEBUGME > 0 #if DEBUGME > 0
printf("[%zu] Slice %zu/%zu, off %zu\n", z, wu.id + 1, wu.max, wu.off); printf("[%zu] Slice %zu/%zu, off %zu\n", z, wu.id + 1, wu.max, wu.off);
#else #else
float progress = (((wu.id + 1) * 100.0) / wu.max);
printf("\r[%zu] Slice %zu/%zu ( %2.1f%% )", z, wu.id + 1, wu.max, progress); printf("\r[%zu] Slice %zu/%zu ( %2.1f%% )", z, wu.id + 1, wu.max, progress);
#endif // DEBUGME #endif // DEBUGME
} }
@ -772,7 +772,11 @@ void *computing_process_async(void *arg) {
a->quit = true; a->quit = true;
pthread_mutex_unlock(&a->thread_ctx->thread_mutexs[z]); pthread_mutex_unlock(&a->thread_ctx->thread_mutexs[z]);
#if TDEBUG >= 1 #if TDEBUG >= 1
#ifdef _ISOC99_SOURCE
printf("[%s][%zu] master, I found the key ! state %U64x, slice %zu\n", __func__, z, a->s, a->slice + 1);
#else
printf("[%s][%zu] master, I found the key ! state %" STR(OFF_FORMAT_U) ", slice %zu\n", __func__, z, a->s, a->slice + 1); printf("[%s][%zu] master, I found the key ! state %" STR(OFF_FORMAT_U) ", slice %zu\n", __func__, z, a->s, a->slice + 1);
#endif
fflush(stdout); fflush(stdout);
#endif #endif