]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Use negative errors internally
authorMichalis Pappas <michalis@unikraft.io>
Tue, 2 Apr 2024 14:57:48 +0000 (16:57 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Wed, 26 Mar 2025 08:05:34 +0000 (08:05 +0000)
Update static functions to encode negative errors in
returned pointers.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1248

lib/posix-process/process.c

index 84c3dae7f9ff7ec3be5bc5ded6e7296186ef6771..c87b3e5d405e2c38885be43bf33385e43a7f544c 100644 (file)
@@ -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