diff options
| author | bors <bors@rust-lang.org> | 2022-10-26 23:58:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-26 23:58:24 +0000 |
| commit | df57f7b438660071fd8e2c8b587b8e38e36b47bd (patch) | |
| tree | b7dbc4dd16c1501d13a5e3878261babda9e1ff58 /library/std/src | |
| parent | 1898c34e923bad763e723c68dd9f23a09f9eb0fc (diff) | |
| parent | 132883e455dc212f9009656992c1733643de2b18 (diff) | |
| download | rust-df57f7b438660071fd8e2c8b587b8e38e36b47bd.tar.gz rust-df57f7b438660071fd8e2c8b587b8e38e36b47bd.zip | |
Auto merge of #103604 - JohnTitor:rollup-q4ns2gh, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #103432 (rustdoc: don't mark Box<T> as Iterator, Read, etc) - #103526 (More dupe typos again) - #103537 (rustdoc: combine shared CSS between `.*-line-numbers`) - #103549 (llvm-16: Don't initialize removed legacy passes) - #103558 (Update cargo) - #103567 (ptr::eq: clarify that comparing dyn Trait is fragile) - #103579 (:arrow_up: rust-analyzer) - #103580 (Fix typo in docs for `guaranteed_ne`) - #103596 (thread::set_name: debug-assert that things went well) - #103598 (rustc_lexer::TokenKind improve docs) Failed merges: - #103585 (Migrate source line numbers CSS to CSS variables) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sync/mpsc/stream.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unix/thread.rs | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/library/std/src/sync/mpsc/stream.rs b/library/std/src/sync/mpsc/stream.rs index 4c3812c79f6..4592e914160 100644 --- a/library/std/src/sync/mpsc/stream.rs +++ b/library/std/src/sync/mpsc/stream.rs @@ -114,7 +114,7 @@ impl<T> Packet<T> { match self.queue.producer_addition().cnt.fetch_add(1, Ordering::SeqCst) { // As described in the mod's doc comment, -1 == wakeup -1 => UpWoke(self.take_to_wake()), - // As as described before, SPSC queues must be >= -2 + // As described before, SPSC queues must be >= -2 -2 => UpSuccess, // Be sure to preserve the disconnected state, and the return value diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 69cd2b500a1..c1d30dd9d52 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -137,7 +137,9 @@ impl Thread { unsafe { // Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20. let name = truncate_cstr(name, TASK_COMM_LEN); - libc::pthread_setname_np(libc::pthread_self(), name.as_ptr()); + let res = libc::pthread_setname_np(libc::pthread_self(), name.as_ptr()); + // We have no good way of propagating errors here, but in debug-builds let's check that this actually worked. + debug_assert_eq!(res, 0); } } @@ -152,7 +154,9 @@ impl Thread { pub fn set_name(name: &CStr) { unsafe { let name = truncate_cstr(name, libc::MAXTHREADNAMESIZE); - libc::pthread_setname_np(name.as_ptr()); + let res = libc::pthread_setname_np(name.as_ptr()); + // We have no good way of propagating errors here, but in debug-builds let's check that this actually worked. + debug_assert_eq!(res, 0); } } @@ -160,11 +164,12 @@ impl Thread { pub fn set_name(name: &CStr) { unsafe { let cname = CStr::from_bytes_with_nul_unchecked(b"%s\0".as_slice()); - libc::pthread_setname_np( + let res = libc::pthread_setname_np( libc::pthread_self(), cname.as_ptr(), name.as_ptr() as *mut libc::c_void, ); + debug_assert_eq!(res, 0); } } @@ -177,9 +182,8 @@ impl Thread { } if let Some(f) = pthread_setname_np.get() { - unsafe { - f(libc::pthread_self(), name.as_ptr()); - } + let res = unsafe { f(libc::pthread_self(), name.as_ptr()) }; + debug_assert_eq!(res, 0); } } |
