@@ -137,7 +137,9 @@ impl Thread {
137
137
unsafe {
138
138
// Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20.
139
139
let name = truncate_cstr ( name, TASK_COMM_LEN ) ;
140
- libc:: pthread_setname_np ( libc:: pthread_self ( ) , name. as_ptr ( ) ) ;
140
+ let res = libc:: pthread_setname_np ( libc:: pthread_self ( ) , name. as_ptr ( ) ) ;
141
+ // We have no good way of propagating errors here, but in debug-builds let's check that this actually worked.
142
+ debug_assert_eq ! ( res, 0 ) ;
141
143
}
142
144
}
143
145
@@ -152,19 +154,22 @@ impl Thread {
152
154
pub fn set_name ( name : & CStr ) {
153
155
unsafe {
154
156
let name = truncate_cstr ( name, libc:: MAXTHREADNAMESIZE ) ;
155
- libc:: pthread_setname_np ( name. as_ptr ( ) ) ;
157
+ let res = libc:: pthread_setname_np ( name. as_ptr ( ) ) ;
158
+ // We have no good way of propagating errors here, but in debug-builds let's check that this actually worked.
159
+ debug_assert_eq ! ( res, 0 ) ;
156
160
}
157
161
}
158
162
159
163
#[ cfg( target_os = "netbsd" ) ]
160
164
pub fn set_name ( name : & CStr ) {
161
165
unsafe {
162
166
let cname = CStr :: from_bytes_with_nul_unchecked ( b"%s\0 " . as_slice ( ) ) ;
163
- libc:: pthread_setname_np (
167
+ let res = libc:: pthread_setname_np (
164
168
libc:: pthread_self ( ) ,
165
169
cname. as_ptr ( ) ,
166
170
name. as_ptr ( ) as * mut libc:: c_void ,
167
171
) ;
172
+ debug_assert_eq ! ( res, 0 ) ;
168
173
}
169
174
}
170
175
@@ -177,9 +182,8 @@ impl Thread {
177
182
}
178
183
179
184
if let Some ( f) = pthread_setname_np. get ( ) {
180
- unsafe {
181
- f ( libc:: pthread_self ( ) , name. as_ptr ( ) ) ;
182
- }
185
+ let res = unsafe { f ( libc:: pthread_self ( ) , name. as_ptr ( ) ) } ;
186
+ debug_assert_eq ! ( res, 0 ) ;
183
187
}
184
188
}
185
189
0 commit comments