diff --git a/.clang-tidy b/.clang-tidy index 25c56ca8ff50086dfac3a670170c396ad6327874..0acc102f238dee75730258350c99633da2fb83e4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,6 +6,7 @@ Checks: > performance-*, portability-*, readability-*, + -bugprone-easily-swappable-parameters, -cert-err58-cpp, -clang-diagnostic-empty-translation-unit, -readability-braces-around-statements, diff --git a/emper/Runtime.cpp b/emper/Runtime.cpp index c246bbc6e0fffd1bd43b7208b8180c249117aacd..907bbebcda273596905e6c81bce4c8922821f211 100644 --- a/emper/Runtime.cpp +++ b/emper/Runtime.cpp @@ -258,6 +258,7 @@ auto Runtime::workerLoop(Worker* worker) -> void* { LOGD("Worker loop started by thread " << gettid()); int oldType; + // NOLINTNEXTLINE: cert-pos47-c errno = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldType); if (errno) { DIE_MSG_ERRNO("pthread_setcanceltype() failed"); diff --git a/emper/sleep_strategy/PipeSleepStrategy.cpp b/emper/sleep_strategy/PipeSleepStrategy.cpp index f2d878ef7ea46e7b9c6b926d09130063ae241a77..c541ff7c65fa081472f1df72086ef19106791a3a 100644 --- a/emper/sleep_strategy/PipeSleepStrategy.cpp +++ b/emper/sleep_strategy/PipeSleepStrategy.cpp @@ -43,10 +43,10 @@ PipeSleepStrategy::~PipeSleepStrategy() { template <CallerEnvironment callerEnvironment> [[nodiscard]] auto PipeSleepStrategy::createHint() -> TaggedPtr { if constexpr (callerEnvironment == CallerEnvironment::EMPER) { - return TaggedPtr((uintptr_t)Worker::getCurrentWorkerId(), - static_cast<uint16_t>(IoContext::PointerTags::NewWorkWsq)); + return {(uintptr_t)Worker::getCurrentWorkerId(), + static_cast<uint16_t>(IoContext::PointerTags::NewWorkWsq)}; } else { - return TaggedPtr((uintptr_t) nullptr, static_cast<uint16_t>(IoContext::PointerTags::NewWorkAq)); + return {(uintptr_t) nullptr, static_cast<uint16_t>(IoContext::PointerTags::NewWorkAq)}; } } diff --git a/eval/Locality.cpp b/eval/Locality.cpp index 26ddb8ae099a0d0f3bbe9717a9e7a51b54cbf785..67bb4149f92bfecfc6d61464e5e92e6dbc90d8f8 100644 --- a/eval/Locality.cpp +++ b/eval/Locality.cpp @@ -37,8 +37,8 @@ struct FiberMetadata { }; struct State { - const unsigned int fiberCount; - const unsigned int bytesPerFiber; + const size_t fiberCount; + const size_t bytesPerFiber; const unsigned int rounds; Runtime& runtime; @@ -59,7 +59,8 @@ struct State { for (unsigned int i = 0; i < fiberCount; ++i) { affinity[i] = Fiber::NOT_AFFINE; } - data = new uint8_t[fiberCount * bytesPerFiber]; + auto totalBytes = static_cast<unsigned long>(fiberCount) * bytesPerFiber; + data = new uint8_t[totalBytes]; #ifdef FIBER_METADATA fiberMetadata = new FiberMetadata[fiberCount * rounds]; #endif @@ -79,7 +80,8 @@ struct State { [[nodiscard]] auto getFiberMetadata(unsigned int fiberNum, unsigned int roundNum) const -> FiberMetadata* { - return fiberMetadata + (fiberNum * fiberCount) + roundNum; + auto fiberOffset = fiberNum * fiberCount; + return fiberMetadata + fiberOffset + roundNum; } }; @@ -106,7 +108,7 @@ static void performRound(State& state, DBG("Starting round " << round); - for (unsigned int i = 0; i < state.fiberCount; ++i) { + for (size_t i = 0; i < state.fiberCount; ++i) { fiberArgs[i].fiberData = state.data + (i * state.bytesPerFiber); fiberArgs[i].roundData = roundData; fiberArgs[i].ps = &cps; diff --git a/tests/io/TooLongFutureChain.cpp b/tests/io/TooLongFutureChain.cpp index 9de61b62549423d3b4d9399c7aa278ac11340a7a..4f3710af0462decafc1977f12895f7b87c33663d 100644 --- a/tests/io/TooLongFutureChain.cpp +++ b/tests/io/TooLongFutureChain.cpp @@ -9,7 +9,7 @@ using emper::io::AlarmFuture; void emperTest() { - const size_t links = EMPER_IO_WORKER_URING_ENTRIES * 2; + const size_t links = static_cast<size_t>(EMPER_IO_WORKER_URING_ENTRIES) * 2; std::array<AlarmFuture*, links> futures; AlarmFuture::Timespec ts = {.tv_sec = 0, .tv_nsec = 100};