Re:Tell HN: C Experts Panel – Ask us anything about C
by eqvinox on Tuesday April 14, 2020 @10:47AM
(#22866645)
Here's our usage: https://github.com/FRRouting/frr/blob/master/lib/privs.h#L14...
This gives us a block construct that guarantees elevated privileges are dropped when the block is done:
[ Parent
| on HN ]
Re:Tell HN: C Experts Panel – Ask us anything about C
by rwmj on Tuesday April 14, 2020 @11:04AM
(#22866852)
We have a nice macro for acquiring locks that only applies to the scope:
https://github.com/libguestfs/nbdkit/blob/e58d28d65bfea3af36...
You end up with code like this:
https://github.com/libguestfs/nbdkit/blob/e58d28d65bfea3af36...
It's so useful to be able to be sure the lock is released on all return paths. Also because it's scope-level you can scope your locks tightly to where they are needed.