From 1f461b2d46beaea4a5a83816a91479e819c0bf9c Mon Sep 17 00:00:00 2001 From: Florian Schmaus <flow@cs.fau.de> Date: Fri, 14 May 2021 10:37:22 +0200 Subject: [PATCH] [CountingPrivateSemaphore] Fix assert As the code comment above the assert indicates, the atomic exchange operation may either return nullptr or a valid Context pointer. And this is what the assert() should assert. :) Reported-by: Florian Fischer <florian.fl.fischer@fau.de> --- emper/CountingPrivateSemaphore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emper/CountingPrivateSemaphore.cpp b/emper/CountingPrivateSemaphore.cpp index a74246a3..d66634c7 100644 --- a/emper/CountingPrivateSemaphore.cpp +++ b/emper/CountingPrivateSemaphore.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright © 2020 Florian Schmaus +// Copyright © 2020-2021 Florian Schmaus #include "CountingPrivateSemaphore.hpp" #include <cassert> // for assert @@ -46,7 +46,7 @@ auto CountingPrivateSemaphore::signalInternal() -> Context* { // returns nullptr. In this case the block() function will // have won the race. Context* context = blockedContext.exchange(nullptr); - assert(context > (Context*)4096); + assert(!context || context > (Context*)4096); return context; } -- GitLab