fix: medium priority warnings - write-strings and unused variables

1. Fix write-strings warnings (12 occurrences):
   - MySQL_HostGroups_Manager.cpp: Change char* to const char*
     for src_status and dst_status variables
   - MySQL_Monitor.cpp: Change ConsumerThread constructor
     parameter from char thread_name[16] to const char *thread_name

2. Fix unused-but-set-variable warnings (6 occurrences) by
   wrapping PROXYSQLGENAI-specific variables in #ifdef blocks:
   - stats_mcp_query_tools_counters
   - stats_mcp_query_tools_counters_reset
   - stats_mcp_query_digest
   - stats_mcp_query_digest_reset
   - stats_mcp_query_rules
   - runtime_mcp_query_rules

   These variables were assigned values but appeared unused when
   PROXYSQLGENAI was not defined. Now they are only defined and
   assigned when PROXYSQLGENAI is enabled.

This eliminates 18 compiler warnings: 12 write-strings and 6
unused-but-set-variable warnings.

Found during compiler warning analysis with 'make debug'.
pull/5357/head
Rene Cannao 2 months ago
parent 4c788dcbb3
commit df1c4e7928

@ -3783,8 +3783,8 @@ void MySQL_HostGroups_Manager::set_Readyset_status(char *hostname, int port, enu
if (mysrvc->port==port && strcmp(mysrvc->address,hostname)==0) {
enum MySerStatus prev_status = mysrvc->get_status();
if (prev_status != status) {
char *src_status = "?"; // this shouldn't display
char *dst_status = "?"; // this shouldn't display
const char *src_status = "?"; // this shouldn't display
const char *dst_status = "?"; // this shouldn't display
if (prev_status == MYSQL_SERVER_STATUS_ONLINE) { src_status = "ONLINE"; }
else if (prev_status == MYSQL_SERVER_STATUS_OFFLINE_SOFT) { src_status = "OFFLINE_SOFT"; }
else if (prev_status == MYSQL_SERVER_STATUS_SHUNNED) { src_status = "SHUNNED"; };

@ -105,7 +105,7 @@ class ConsumerThread : public Thread {
int thrn;
char thr_name[16];
public:
ConsumerThread(wqueue<WorkItem<T>*>& queue, int _n, char thread_name[16]=NULL) : m_queue(queue) {
ConsumerThread(wqueue<WorkItem<T>*>& queue, int _n, const char *thread_name=NULL) : m_queue(queue) {
thrn=_n;
if (thread_name && thread_name[0]) {
snprintf(thr_name, sizeof(thr_name), "%.16s", thread_name);

@ -1202,11 +1202,13 @@ bool ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsign
bool stats_memory_metrics=false;
bool stats_mysql_commands_counters=false;
bool stats_pgsql_commands_counters = false;
#ifdef PROXYSQLGENAI
bool stats_mcp_query_tools_counters = false;
bool stats_mcp_query_tools_counters_reset = false;
bool stats_mcp_query_digest = false;
bool stats_mcp_query_digest_reset = false;
bool stats_mcp_query_rules = false;
#endif
bool stats_mysql_query_rules=false;
bool stats_pgsql_query_rules = false;
bool stats_mysql_users=false;
@ -1234,7 +1236,9 @@ bool ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsign
bool runtime_pgsql_query_rules = false;
bool runtime_pgsql_query_rules_fast_routing = false;
#ifdef PROXYSQLGENAI
bool runtime_mcp_query_rules = false;
#endif
bool stats_pgsql_global = false;
bool stats_pgsql_connection_pool = false;
@ -1398,6 +1402,7 @@ bool ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsign
{ stats_proxysql_message_metrics=true; refresh=true; }
if (strstr(query_no_space,"stats_proxysql_message_metrics_reset"))
{ stats_proxysql_message_metrics_reset=true; refresh=true; }
#ifdef PROXYSQLGENAI
if (strstr(query_no_space,"stats_mcp_query_tools_counters"))
{ stats_mcp_query_tools_counters=true; refresh=true; }
if (strstr(query_no_space,"stats_mcp_query_tools_counters_reset"))
@ -1408,6 +1413,7 @@ bool ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsign
{ stats_mcp_query_digest=true; refresh=true; }
if (strstr(query_no_space,"stats_mcp_query_rules"))
{ stats_mcp_query_rules=true; refresh=true; }
#endif
// temporary disabled because not implemented
/*
@ -1494,9 +1500,11 @@ bool ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsign
if (strstr(query_no_space, "runtime_pgsql_query_rules_fast_routing")) {
runtime_pgsql_query_rules_fast_routing = true; refresh = true;
}
#ifdef PROXYSQLGENAI
if (strstr(query_no_space, "runtime_mcp_query_rules")) {
runtime_mcp_query_rules = true; refresh = true;
}
#endif
if (strstr(query_no_space,"runtime_scheduler")) {
runtime_scheduler=true; refresh=true;
}

Loading…
Cancel
Save