Jelajahi Sumber

Fix sign comparison warnings in server.cpp

- Fixed comparison between std::string::size_type (unsigned) and int (signed) at lines 2400 and 2409
- Added static_cast<int> to prompt.length() and negative_prompt.length() to ensure type consistency
- Build now completes without compiler warnings
Fszontagh 3 bulan lalu
induk
melakukan
26688e646c
1 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 3 3
      src/server.cpp

+ 3 - 3
src/server.cpp

@@ -913,7 +913,7 @@ void Server::setupCORS() {
     });
 }
 
-void Server::handleHealthCheck(const httplib::Request& req, httplib::Response& res) {
+void Server::handleHealthCheck(const httplib::Request& /*req*/, httplib::Response& res) {
     LOG_DEBUG("handleHealthCheck called");
     try {
         nlohmann::json response = {
@@ -2397,7 +2397,7 @@ std::pair<bool, std::string> Server::validateGenerationParameters(const nlohmann
     if (prompt.empty()) {
         return {false, "Prompt cannot be empty"};
     }
-    if (prompt.length() > m_config.maxPromptLength) {
+    if (static_cast<int>(prompt.length()) > m_config.maxPromptLength) {
         return {false, "Prompt too long (max " + std::to_string(m_config.maxPromptLength) + " characters)"};
     }
 
@@ -2406,7 +2406,7 @@ std::pair<bool, std::string> Server::validateGenerationParameters(const nlohmann
         if (!params["negative_prompt"].is_string()) {
             return {false, "Invalid 'negative_prompt' field, must be string"};
         }
-        if (params["negative_prompt"].get<std::string>().length() > m_config.maxNegativePromptLength) {
+        if (static_cast<int>(params["negative_prompt"].get<std::string>().length()) > m_config.maxNegativePromptLength) {
             return {false, "Negative prompt too long (max " + std::to_string(m_config.maxNegativePromptLength) + " characters)"};
         }
     }