Skip to content
Snippets Groups Projects
Commit 1f461b2d authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[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: default avatarFlorian Fischer <florian.fl.fischer@fau.de>
parent b8e2983f
No related branches found
No related tags found
1 merge request!200[CountingPrivateSemaphore] Fix assert
// 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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment