Standardise and add safety comments.
These will soon be required by a lint.
Bug: 290018030
Test: m rust
Change-Id: If62281a5eb2160061a11f28588b7a14e32ce265b
diff --git a/libs/capabilities/src/caps.rs b/libs/capabilities/src/caps.rs
index 1f44a34..bc17fa8 100644
--- a/libs/capabilities/src/caps.rs
+++ b/libs/capabilities/src/caps.rs
@@ -26,8 +26,8 @@
/// Removes inheritable capabilities set for this process.
/// See: https://man7.org/linux/man-pages/man7/capabilities.7.html
pub fn drop_inheritable_caps() -> Result<()> {
+ // SAFETY: we do not manipulate memory handled by libcap.
unsafe {
- // SAFETY: we do not manipulate memory handled by libcap.
let caps = cap_get_proc();
scopeguard::defer! {
cap_free(caps as *mut std::os::raw::c_void);
@@ -49,8 +49,8 @@
pub fn drop_bounding_set() -> Result<()> {
let mut cap_id: cap_value_t = 0;
while cap_id <= CAP_LAST_CAP.try_into().unwrap() {
+ // SAFETY: we do not manipulate memory handled by libcap.
unsafe {
- // SAFETY: we do not manipulate memory handled by libcap.
if cap_drop_bound(cap_id) == -1 {
let e = Errno::last();
bail!("cap_drop_bound failed for {}: {:?}", cap_id, e);