]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-fdtab: Fix fdtab cleanup w/o asserts
authorAndrei Tatar <andrei@unikraft.io>
Tue, 2 Jan 2024 08:14:14 +0000 (10:14 +0200)
committerRazvan Deaconescu <razvan.deaconescu@upb.ro>
Tue, 2 Jan 2024 16:08:36 +0000 (18:08 +0200)
commit 12f7eda56cb1 ("lib/posix-fdtab: Silence unused variable warning")
moved `uk_fdtab_take` into an assert statement, preventing its
side-effects when asserts are disabled.
This change corrects this, ensuring that `uk_fdtab_take` is run
regardless of whether asserts are enabled or not.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1239

lib/posix-fdtab/fdtab.c

index 5dd9fc3ff19869c2b26f59ccc3ded80f57e5323f..464c9ec11e9c6405f218504c0a2f4c1efdd78aae 100644 (file)
@@ -360,7 +360,10 @@ static void fdtab_cleanup(int all)
                        struct fdval v = fdtab_decode(p);
 
                        if (all || (v.flags & UK_FDTAB_CLOEXEC)) {
-                               UK_ASSERT(p == uk_fmap_take(fmap, i));
+                               void **pp __maybe_unused;
+
+                               pp = uk_fmap_take(fmap, i);
+                               UK_ASSERT(p == pp);
                                file_rel(tab, v.p, v.flags);
                        }
                }