bhm: Fix a warning in the Linux sampler (#30924)

Use curly braces instead of an explicit drop to control the end of a
borrow.
This commit is contained in:
Martin Robinson 2023-12-28 12:20:47 +01:00 committed by GitHub
parent 7305c59304
commit bd052f536e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -207,6 +207,8 @@ impl Sampler for LinuxSampler {
// Safety: non-exclusive reference only
// since sampled threads are accessing this concurrently
let result;
{
let shared_state = unsafe { &*SHARED_STATE.0.get() };
shared_state
.msg2
@ -218,7 +220,7 @@ impl Sampler for LinuxSampler {
let context = CONTEXT.load(Ordering::SeqCst);
let mut cursor = mem::MaybeUninit::uninit();
let ret = unsafe { unw_init_local(cursor.as_mut_ptr(), context) };
let result = if ret == UNW_ESUCCESS {
result = if ret == UNW_ESUCCESS {
let mut native_stack = NativeStack::new();
loop {
let ip = match get_register(cursor.as_mut_ptr(), RegNum::Ip) {
@ -257,9 +259,7 @@ impl Sampler for LinuxSampler {
.unwrap()
.wait_through_intr()
.expect("msg4 failed");
// No-op, but marks the end of the shared borrow
drop(shared_state);
}
clear_shared_state();