From 5d2eb580fdd61ccacf00aa93d7ee42e8e53afc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 19 May 2022 13:11:25 +0300 Subject: [PATCH] mdbx: more minor fixes 32-to-64 warnings from Apple's CLANG 13. --- test/cases.cc | 8 ++++---- test/chrono.cc | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/cases.cc b/test/cases.cc index cf31344b..eac23752 100644 --- a/test/cases.cc +++ b/test/cases.cc @@ -65,7 +65,7 @@ void configure_actor(unsigned &last_space_id, const actor_testcase testcase, failure("No previous waitable actor for %u-ops\n", params.waitfor_nops); } - unsigned space_id = 0; + unsigned long space_id = 0; if (!space_id_cstr || strcmp(space_id_cstr, "auto") == 0) space_id = last_space_id + 1; else { @@ -79,13 +79,13 @@ void configure_actor(unsigned &last_space_id, const actor_testcase testcase, } if (!registry::review_actor_params(testcase, params)) - failure("Actor config-review failed for space-id %u\n", space_id); + failure("Actor config-review failed for space-id %lu\n", space_id); if (space_id > ACTOR_ID_MAX) - failure("Invalid space-id %u\n", space_id); + failure("Invalid space-id %lu\n", space_id); last_space_id = space_id; - log_trace("configure_actor: space %u for %s", space_id, + log_trace("configure_actor: space %lu for %s", space_id, testcase2str(testcase)); global::actors.emplace_back( actor_config(testcase, params, space_id, wait4id)); diff --git a/test/chrono.cc b/test/chrono.cc index c84d603c..ec22b39b 100644 --- a/test/chrono.cc +++ b/test/chrono.cc @@ -26,11 +26,11 @@ uint32_t ns2fractional(uint32_t ns) { * для ясности кода оставлено как есть (без ручной оптимизации). Так как * GCC, Clang и даже MSVC сами давно умеют конвертировать деление на * константу в быструю reciprocal-форму. */ - return ((uint64_t)ns << 32) / NSEC_PER_SEC; + return uint32_t((uint64_t(ns) << 32) / NSEC_PER_SEC); } uint32_t fractional2ns(uint32_t fractional) { - return (fractional * (uint64_t)NSEC_PER_SEC) >> 32; + return uint32_t((fractional * uint64_t(NSEC_PER_SEC)) >> 32); } #ifndef USEC_PER_SEC @@ -38,11 +38,11 @@ uint32_t fractional2ns(uint32_t fractional) { #endif /* USEC_PER_SEC */ uint32_t us2fractional(uint32_t us) { assert(us < USEC_PER_SEC); - return ((uint64_t)us << 32) / USEC_PER_SEC; + return uint32_t((uint64_t(us) << 32) / USEC_PER_SEC); } uint32_t fractional2us(uint32_t fractional) { - return (fractional * (uint64_t)USEC_PER_SEC) >> 32; + return uint32_t((fractional * uint64_t(USEC_PER_SEC)) >> 32); } #ifndef MSEC_PER_SEC @@ -50,31 +50,31 @@ uint32_t fractional2us(uint32_t fractional) { #endif /* MSEC_PER_SEC */ uint32_t ms2fractional(uint32_t ms) { assert(ms < MSEC_PER_SEC); - return ((uint64_t)ms << 32) / MSEC_PER_SEC; + return uint32_t((uint64_t(ms) << 32) / MSEC_PER_SEC); } uint32_t fractional2ms(uint32_t fractional) { - return (fractional * (uint64_t)MSEC_PER_SEC) >> 32; + return uint32_t((fractional * uint64_t(MSEC_PER_SEC)) >> 32); } time from_ns(uint64_t ns) { time result; - result.fixedpoint = ((ns / NSEC_PER_SEC) << 32) | - ns2fractional((uint32_t)(ns % NSEC_PER_SEC)); + result.fixedpoint = + ((ns / NSEC_PER_SEC) << 32) | ns2fractional(uint32_t(ns % NSEC_PER_SEC)); return result; } time from_us(uint64_t us) { time result; - result.fixedpoint = ((us / USEC_PER_SEC) << 32) | - us2fractional((uint32_t)(us % USEC_PER_SEC)); + result.fixedpoint = + ((us / USEC_PER_SEC) << 32) | us2fractional(uint32_t(us % USEC_PER_SEC)); return result; } time from_ms(uint64_t ms) { time result; - result.fixedpoint = ((ms / MSEC_PER_SEC) << 32) | - ms2fractional((uint32_t)(ms % MSEC_PER_SEC)); + result.fixedpoint = + ((ms / MSEC_PER_SEC) << 32) | ms2fractional(uint32_t(ms % MSEC_PER_SEC)); return result; }