Fix some non_upper_case_globals warnings

This commit is contained in:
Johannes Altmanninger
2025-12-30 14:13:44 +01:00
parent 2524ece2cc
commit 0be3f9e57e
4 changed files with 19 additions and 19 deletions

View File

@@ -263,7 +263,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
let mut override_buffer = None;
const short_options: &wstr = L!("abijpctfxorhI:CBELSsP");
let short_options = L!("abijpctfxorhI:CBELSsP");
let long_options: &[WOption] = &[
wopt(L!("append"), ArgType::NoArgument, 'a'),
wopt(L!("insert"), ArgType::NoArgument, 'i'),

View File

@@ -401,7 +401,7 @@ pub fn expected_dash_count(&self) -> usize {
}
/// Last value used in the order field of [`CompletionEntry`].
static complete_order: AtomicUsize = AtomicUsize::new(0);
static COMPLETE_ORDER: AtomicUsize = AtomicUsize::new(0);
struct CompletionEntry {
/// List of all options.
@@ -415,7 +415,7 @@ impl CompletionEntry {
pub fn new() -> Self {
Self {
options: vec![],
order: complete_order.fetch_add(1, atomic::Ordering::Relaxed),
order: COMPLETE_ORDER.fetch_add(1, atomic::Ordering::Relaxed),
}
}
@@ -606,7 +606,7 @@ struct Completer<'ctx> {
condition_cache: HashMap<WString, bool>,
}
static completion_autoloader: Lazy<Mutex<Autoload>> =
static COMPLETION_AUTOLOADER: Lazy<Mutex<Autoload>> =
Lazy::new(|| Mutex::new(Autoload::new(L!("fish_complete_path"))));
impl<'ctx> Completer<'ctx> {
@@ -1257,7 +1257,7 @@ fn complete_param_for_command(
flog!(complete, "Skipping completions for non-existent command");
} else if let Some(parser) = self.ctx.maybe_parser() {
complete_load(&cmd, parser);
} else if !completion_autoloader
} else if !COMPLETION_AUTOLOADER
.lock()
.unwrap()
.has_attempted_autoload(&cmd)
@@ -1793,7 +1793,7 @@ fn try_complete_user(&mut self, s: &wstr) -> bool {
}
#[cfg(not(target_os = "android"))]
{
static s_setpwent_lock: Mutex<()> = Mutex::new(());
static SETPWENT_LOCK: Mutex<()> = Mutex::new(());
if s.char_at(0) != '~' || s.contains('/') {
return false;
@@ -1817,7 +1817,7 @@ fn getpwent_name() -> Option<WString> {
Some(charptr2wcstring(pw.pw_name))
}
let _guard = s_setpwent_lock.lock().unwrap();
let _guard = SETPWENT_LOCK.lock().unwrap();
unsafe { libc::setpwent() };
while let Some(pw_name) = getpwent_name() {
@@ -2477,14 +2477,14 @@ pub fn complete_load(cmd: &wstr, parser: &Parser) -> bool {
// We need to take the lock to decide what to load, drop it to perform the load, then reacquire
// it.
// Note we only look at the global fish_function_path and fish_complete_path.
let path_to_load = completion_autoloader
let path_to_load = COMPLETION_AUTOLOADER
.lock()
.expect("mutex poisoned")
.resolve_command(cmd, EnvStack::globals());
match path_to_load {
AutoloadResult::Path(path_to_load) => {
Autoload::perform_autoload(&path_to_load, parser);
completion_autoloader
COMPLETION_AUTOLOADER
.lock()
.expect("mutex poisoned")
.mark_autoload_finished(cmd);
@@ -2545,7 +2545,7 @@ pub fn complete_invalidate_path() {
// unload any completions that the user may specified on the command line. We should in
// principle track those completions loaded by the autoloader alone.
let cmds = completion_autoloader
let cmds = COMPLETION_AUTOLOADER
.lock()
.expect("mutex poisoned")
.get_autoloaded_commands();

View File

@@ -343,18 +343,18 @@ unsafe impl Sync for TopicMonitor {}
/// The principal topic monitor.
/// Do not attempt to move this into a lazy_static, it must be accessed from a signal handler.
static mut s_principal: *const TopicMonitor = std::ptr::null();
static mut PRINCIPAL: *const TopicMonitor = std::ptr::null();
impl TopicMonitor {
/// Initialize the principal monitor, and return it.
/// This should be called only on the main thread.
pub fn initialize() -> &'static Self {
unsafe {
if s_principal.is_null() {
if PRINCIPAL.is_null() {
// We simply leak.
s_principal = Box::into_raw(Box::default());
PRINCIPAL = Box::into_raw(Box::default());
}
&*s_principal
&*PRINCIPAL
}
}
@@ -595,10 +595,10 @@ pub fn topic_monitor_init() {
pub fn topic_monitor_principal() -> &'static TopicMonitor {
unsafe {
assert!(
!s_principal.is_null(),
!PRINCIPAL.is_null(),
"Principal topic monitor not initialized"
);
&*s_principal
&*PRINCIPAL
}
}

View File

@@ -566,7 +566,7 @@ fn wgetopt_inner(&mut self, longopt_index: &mut usize) -> Option<char> {
#[cfg(test)]
mod tests {
use super::{ArgType, WGetopter, WOption, wopt};
use super::{ArgType, WGetopter, wopt};
use crate::prelude::*;
use crate::wcstringutil::join_strings;
@@ -611,8 +611,8 @@ fn test_exchange() {
#[test]
fn test_wgetopt() {
// Regression test for a crash.
const short_options: &wstr = L!("-a");
const long_options: &[WOption] = &[wopt(L!("add"), ArgType::NoArgument, 'a')];
let short_options = L!("-a");
let long_options = &[wopt(L!("add"), ArgType::NoArgument, 'a')];
let mut argv = [
L!("abbr"),
L!("--add"),