From 1729662ea30501af5dda40d53fa254ddb9a079dd Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Tue, 7 Jul 2026 22:25:21 +0200 Subject: [PATCH] nits fixes --- tools/cli/cli-context.cpp | 5 +++-- tools/cli/cli-server.h | 14 ++++++++++---- tools/cli/cli-ui.h | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/cli/cli-context.cpp b/tools/cli/cli-context.cpp index 6f26ace0bc..78ebe30a0b 100644 --- a/tools/cli/cli-context.cpp +++ b/tools/cli/cli-context.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -81,7 +82,7 @@ static std::string format_error_message(const std::string & err) { static std::string media_type_from_ext(const std::string & fname) { std::string ext = std::filesystem::path(fname).extension().string(); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); + std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); }); if (ext == ".wav" || ext == ".mp3") { return "audio"; } @@ -281,7 +282,7 @@ bool cli_context::stage_media_file(const std::string & fname, const std::string if (type == "audio") { std::string ext = std::filesystem::path(fname).extension().string(); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); + std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c) { return std::tolower(c); }); impl->pending_media.push_back({ {"type", "input_audio"}, {"input_audio", { diff --git a/tools/cli/cli-server.h b/tools/cli/cli-server.h index d058c84183..7596efb01b 100644 --- a/tools/cli/cli-server.h +++ b/tools/cli/cli-server.h @@ -19,8 +19,13 @@ struct cli_server { } void stop() { - if (alive() && !is_stopping.exchange(true)) { + if (is_stopping.exchange(true)) { + return; + } + if (alive()) { llama_server_terminate(); + } + if (th.joinable()) { th.join(); } } @@ -35,9 +40,10 @@ struct cli_server { is_alive.store(true, std::memory_order_release); - th = std::thread([&]() { - common_params server_params = params; // copy - server_params.port = port; + common_params server_params = params; // copy + server_params.port = port; + + th = std::thread([this, server_params]() mutable { // argc / argv are only used in router mode, we can skip them for now int res = llama_server(server_params, 0, nullptr); if (res != 0) { diff --git a/tools/cli/cli-ui.h b/tools/cli/cli-ui.h index 7ebfd681d6..43aaba6f84 100644 --- a/tools/cli/cli-ui.h +++ b/tools/cli/cli-ui.h @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -61,7 +62,7 @@ static std::vector> auto_completion_callback(std: } if (string_starts_with(expanded_prefix, '/')) { #else - if (std::isalpha(expanded_prefix[0]) && expanded_prefix.find(':') == 1) { + if (std::isalpha(static_cast(expanded_prefix[0])) && expanded_prefix.find(':') == 1) { #endif cur_dir = std::filesystem::path(expanded_prefix).parent_path(); cur_dir_str.clear();