Skip to content

Commit 9e8c030

Browse files
authored
Rollup merge of #131307 - YohDeadfall:prctl-set-name-dbg-assert, r=workingjubilee
Android: Debug assertion after setting thread name While `prctl` cannot fail if it points to a valid buffer, it's still better to assert the result as it's done for other places.
2 parents 1e2b77d + 2223328 commit 9e8c030

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/std/src/sys/pal/unix/thread.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@ impl Thread {
117117
pub fn set_name(name: &CStr) {
118118
const PR_SET_NAME: libc::c_int = 15;
119119
unsafe {
120-
libc::prctl(
120+
let res = libc::prctl(
121121
PR_SET_NAME,
122122
name.as_ptr(),
123123
0 as libc::c_ulong,
124124
0 as libc::c_ulong,
125125
0 as libc::c_ulong,
126126
);
127+
// We have no good way of propagating errors here, but in debug-builds let's check that this actually worked.
128+
debug_assert_eq!(res, 0);
127129
}
128130
}
129131

0 commit comments

Comments
 (0)