diff --git a/platforms/posix/src/px4_layer/px4_sem.cpp b/platforms/posix/src/px4_layer/px4_sem.cpp
index 355d409febbbdc874d1edab11afafbc1c55fa845..c5d9e241edc0c345757ecba2a8cd8d3ebb88f5d2 100644
--- a/platforms/posix/src/px4_layer/px4_sem.cpp
+++ b/platforms/posix/src/px4_layer/px4_sem.cpp
@@ -142,7 +142,7 @@ int px4_sem_timedwait(px4_sem_t *s, const struct timespec *abstime)
 
 	int err = ret;
 
-	if (err != 0 && errno != ETIMEDOUT) {
+	if (err != 0 && err != ETIMEDOUT) {
 		setbuf(stdout, nullptr);
 		setbuf(stderr, nullptr);
 		const unsigned NAMELEN = 32;