From 87dd427d79f39477fb405d9e60adb6109aeb1660 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Fri, 11 Aug 2017 21:38:53 +0200 Subject: [PATCH] Make benchmark progress parameter the same as the internal unsigned type. --- lib/crypto_backend/crypto_backend.h | 2 +- lib/crypto_backend/pbkdf_check.c | 12 ++++++------ lib/libcryptsetup.h | 2 +- lib/utils_benchmark.c | 6 +++--- src/cryptsetup.c | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/crypto_backend/crypto_backend.h b/lib/crypto_backend/crypto_backend.h index 80a08b57..93cdd7e9 100644 --- a/lib/crypto_backend/crypto_backend.h +++ b/lib/crypto_backend/crypto_backend.h @@ -68,7 +68,7 @@ int crypt_pbkdf_perf(const char *kdf, const char *hash, size_t volume_key_size, uint32_t time_ms, uint32_t max_memory_kb, uint32_t parallel_threads, uint32_t *iterations_out, uint32_t *memory_out, - int (*progress)(long time_ms, void *usrptr), void *usrptr); + int (*progress)(uint32_t time_ms, void *usrptr), void *usrptr); #if USE_INTERNAL_PBKDF2 /* internal PBKDF2 implementation */ diff --git a/lib/crypto_backend/pbkdf_check.c b/lib/crypto_backend/pbkdf_check.c index 878cc18c..972fae46 100644 --- a/lib/crypto_backend/pbkdf_check.c +++ b/lib/crypto_backend/pbkdf_check.c @@ -169,7 +169,7 @@ static int crypt_argon2_check(const char *kdf, const char *password, uint32_t min_t_cost, uint32_t max_m_cost, uint32_t parallel, uint32_t target_ms, uint32_t *out_t_cost, uint32_t *out_m_cost, - int (*progress)(long time_ms, void *usrptr), + int (*progress)(uint32_t time_ms, void *usrptr), void *usrptr) { int r = 0; @@ -201,7 +201,7 @@ static int crypt_argon2_check(const char *kdf, const char *password, /* Update parameters to actual measurement */ *out_t_cost = t_cost; *out_m_cost = m_cost; - if (progress && progress(ms, usrptr)) + if (progress && progress((uint32_t)ms, usrptr)) r = -EINTR; } @@ -255,7 +255,7 @@ static int crypt_argon2_check(const char *kdf, const char *password, /* Update parameters to actual measurement */ *out_t_cost = t_cost; *out_m_cost = m_cost; - if (progress && progress(ms, usrptr)) + if (progress && progress((uint32_t)ms, usrptr)) r = -EINTR; } @@ -276,7 +276,7 @@ static int crypt_pbkdf_check(const char *kdf, const char *hash, const char *password, size_t password_length, const char *salt, size_t salt_length, size_t key_length, uint32_t *iter_secs, uint32_t target_ms, - int (*progress)(long time_ms, void *usrptr), void *usrptr) + int (*progress)(uint32_t time_ms, void *usrptr), void *usrptr) { struct rusage rstart, rend; @@ -320,7 +320,7 @@ static int crypt_pbkdf_check(const char *kdf, const char *hash, *iter_secs = (uint32_t)PBKDF2_temp; } - if (progress && progress(ms, usrptr)) { + if (progress && progress((uint32_t)ms, usrptr)) { r = -EINTR; goto out; } @@ -358,7 +358,7 @@ int crypt_pbkdf_perf(const char *kdf, const char *hash, size_t volume_key_size, uint32_t time_ms, uint32_t max_memory_kb, uint32_t parallel_threads, uint32_t *iterations_out, uint32_t *memory_out, - int (*progress)(long time_ms, void *usrptr), void *usrptr) + int (*progress)(uint32_t time_ms, void *usrptr), void *usrptr) { int r = -EINVAL; diff --git a/lib/libcryptsetup.h b/lib/libcryptsetup.h index fa8677f6..eb0b33c6 100644 --- a/lib/libcryptsetup.h +++ b/lib/libcryptsetup.h @@ -1117,7 +1117,7 @@ int crypt_benchmark_pbkdf(struct crypt_device *cd, const char *salt, size_t salt_size, size_t volume_key_size, - int (*progress)(long time_ms, void *usrptr), + int (*progress)(uint32_t time_ms, void *usrptr), void *usrptr); /** @} */ diff --git a/lib/utils_benchmark.c b/lib/utils_benchmark.c index 444f0552..a7326a9f 100644 --- a/lib/utils_benchmark.c +++ b/lib/utils_benchmark.c @@ -238,7 +238,7 @@ int crypt_benchmark_pbkdf(struct crypt_device *cd, const char *salt, size_t salt_size, size_t volume_key_size, - int (*progress)(long time_ms, void *usrptr), + int (*progress)(uint32_t time_ms, void *usrptr), void *usrptr) { int r; @@ -264,12 +264,12 @@ int crypt_benchmark_pbkdf(struct crypt_device *cd, return r; } -static int benchmark_callback(long time_ms, void *usrptr) +static int benchmark_callback(uint32_t time_ms, void *usrptr) { struct crypt_pbkdf_type *pbkdf = usrptr; log_dbg("PBKDF benchmark: memory cost = %u, iterations = %u, " - "threads = %u (took %ld ms)", pbkdf->max_memory_kb, + "threads = %u (took %u ms)", pbkdf->max_memory_kb, pbkdf->iterations, pbkdf->parallel_threads, time_ms); return 0; diff --git a/src/cryptsetup.c b/src/cryptsetup.c index c6dc8b28..62f35249 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -532,7 +532,7 @@ out: return r; } -static int benchmark_callback(long time_ms, void *usrptr) +static int benchmark_callback(uint32_t time_ms, void *usrptr) { struct crypt_pbkdf_type *pbkdf = usrptr; int r = 0; @@ -542,7 +542,7 @@ static int benchmark_callback(long time_ms, void *usrptr) log_err("Benchmark interrupted.\n"); else log_dbg("PBKDF benchmark: memory cost = %u, iterations = %u, " - "threads = %u (took %ld ms)", pbkdf->max_memory_kb, + "threads = %u (took %u ms)", pbkdf->max_memory_kb, pbkdf->iterations, pbkdf->parallel_threads, time_ms); return r; }