From 1bc4cf2318715579db9a006f13eb71e2a348d71c Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 1 Oct 2018 09:59:22 -0700 Subject: [PATCH] More const and atomic correctness --- src/builtin_string.cpp | 2 +- src/complete.cpp | 5 +++-- src/env_universal_common.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 2dc57eb3b..0915e4911 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -423,7 +423,7 @@ static const struct woption long_options[] = { {L"right", no_argument, NULL, 'r'}, {L"start", required_argument, NULL, 's'}, {L"style", required_argument, NULL, 1}, {NULL, 0, NULL, 0}}; -static std::unordered_map flag_to_function = { +static const std::unordered_map flag_to_function = { {'N', handle_flag_N}, {'a', handle_flag_a}, {'c', handle_flag_c}, {'e', handle_flag_e}, {'f', handle_flag_f}, {'i', handle_flag_i}, {'l', handle_flag_l}, {'m', handle_flag_m}, {'n', handle_flag_n}, {'q', handle_flag_q}, {'r', handle_flag_r}, {'s', handle_flag_s}, diff --git a/src/complete.cpp b/src/complete.cpp index 8b6ae652c..2f412be9a 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -133,7 +134,7 @@ typedef struct complete_entry_opt { using arg_list_t = std::vector>; /// Last value used in the order field of completion_entry_t. -static unsigned int kCompleteOrder = 0; +static std::atomic k_complete_order{0}; /// Struct describing a command completion. typedef std::list option_list_t; @@ -159,7 +160,7 @@ class completion_entry_t { bool remove_option(const wcstring &option, complete_option_type_t type); completion_entry_t(wcstring c, bool type) - : cmd(std::move(c)), cmd_is_path(type), order(++kCompleteOrder) {} + : cmd(std::move(c)), cmd_is_path(type), order(++k_complete_order) {} }; /// Set of all completion entries. diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 07d31bc6f..f7b01ba72 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -198,7 +198,7 @@ static bool append_file_entry(fish_message_type_t type, const wcstring &key_in, } /// Encoding of a null string. -static const wchar_t *ENV_NULL = L"\x1d"; +static const wchar_t * const ENV_NULL = L"\x1d"; /// Decode a serialized universal variable value into a list. static wcstring_list_t decode_serialized(const wcstring &val) {