Fix clippy::thread_local_initializer_can_be_made_const

BUG=b:344974550
TEST=tools/clippy

Change-Id: I9875f910fbe3ac249e8f855a7b806e77347fb6d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5609077
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Daniel Verkamp 2024-06-07 12:39:04 -07:00 committed by crosvm LUCI
parent 97848ecceb
commit b27e34916c
4 changed files with 4 additions and 4 deletions

View file

@ -354,7 +354,7 @@ fn set_creds(
ScopedGid::new(gid, oldgid).and_then(|gid| Ok((ScopedUid::new(uid, olduid)?, gid)))
}
thread_local!(static THREAD_FSCREATE: RefCell<Option<File>> = RefCell::new(None));
thread_local!(static THREAD_FSCREATE: RefCell<Option<File>> = const { RefCell::new(None) });
// Opens and returns a write-only handle to /proc/thread-self/attr/fscreate. Panics if it fails to
// open the file.

View file

@ -40,7 +40,7 @@ use crate::virtio::Interrupt;
use crate::virtio::Queue;
thread_local! {
pub(crate) static NET_EXECUTOR: OnceCell<Executor> = OnceCell::new();
pub(crate) static NET_EXECUTOR: OnceCell<Executor> = const { OnceCell::new() };
}
// TODO(b/188947559): Come up with better way to include these constants. Compiler errors happen

View file

@ -1033,7 +1033,7 @@ pub struct VcpuThread {
signal_num: Option<c_int>,
}
thread_local!(static VCPU_THREAD: RefCell<Option<VcpuThread>> = RefCell::new(None));
thread_local!(static VCPU_THREAD: RefCell<Option<VcpuThread>> = const { RefCell::new(None) });
impl Vcpu {
/// Constructs a new VCPU for `vm`.

View file

@ -168,7 +168,7 @@ where
Ok(vcpu)
}
thread_local!(static VCPU_THREAD: RefCell<Option<VcpuSignalHandle>> = RefCell::new(None));
thread_local!(static VCPU_THREAD: RefCell<Option<VcpuSignalHandle>> = const { RefCell::new(None) });
fn set_vcpu_thread_local(vcpu: Option<&dyn VcpuArch>, signal_num: c_int) {
// Block signal while we add -- if a signal fires (very unlikely,