From f4285da638c92893a551eca023777da200658e18 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Tue, 2 Apr 2024 16:57:48 +0200 Subject: [PATCH] lib/posix-process: Use negative errors internally Update static functions to encode negative errors in returned pointers. Signed-off-by: Michalis Pappas Reviewed-by: Ioan-Teodor Teugea Reviewed-by: Sergiu Moga Reviewed-by: Andrei Tatar Approved-by: Andrei Tatar GitHub-Closes: #1248 --- lib/posix-process/process.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/posix-process/process.c b/lib/posix-process/process.c index 84c3dae7f..c87b3e5d4 100644 --- a/lib/posix-process/process.c +++ b/lib/posix-process/process.c @@ -129,14 +129,14 @@ static struct posix_thread *pprocess_create_pthread( a = pprocess->_a; tid = find_and_reserve_tid(); - if (tid < 0) { - err = EAGAIN; + if (unlikely(tid < 0)) { + err = -EAGAIN; goto err_out; } pthread = uk_zalloc(a, sizeof(*pthread)); - if (!pthread) { - err = ENOMEM; + if (unlikely(!pthread)) { + err = -ENOMEM; goto err_free_tid; } @@ -156,7 +156,7 @@ static struct posix_thread *pprocess_create_pthread( err_free_tid: release_tid(tid); err_out: - return ERR2PTR(-err); + return ERR2PTR(err); } /* Free thread that is part of a process -- 2.39.5