Skip to content

Commit

Permalink
Merge pull request #4317 from sysown/v2.6-CodeQL-fixes
Browse files Browse the repository at this point in the history
various warnings fixes
  • Loading branch information
renecannao authored Oct 31, 2023
2 parents a86d758 + 4ffb96b commit 983062e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/MySQL_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class MySQL_Session

Query_Info CurrentQuery;
PtrSize_t mirrorPkt;
PtrSize_t pkt;

// uint64_t
unsigned long long start_time;
Expand Down Expand Up @@ -247,7 +248,6 @@ class MySQL_Session

//this pointer is always initialized inside handler().
// it is an attempt to start simplifying the complexing of handler()
PtrSize_t *pktH;

uint32_t thread_session_id;
unsigned long long last_insert_id;
Expand Down
20 changes: 10 additions & 10 deletions lib/MySQL_HostGroups_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,12 @@ bool GTID_Server_Data::read_next_gtid() {
} else {
strncpy(rec_msg,data+pos,l);
pos += l+1;
rec_msg[l]=0;
rec_msg[l] = 0;
//int rc = write(1,data+pos,l+1);
//fprintf(stdout,"%s\n", rec_msg);
if (rec_msg[0]=='I') {
//char rec_uuid[80];
uint64_t rec_trxid;
uint64_t rec_trxid = 0;
char *a = NULL;
int ul = 0;
switch (rec_msg[1]) {
Expand Down Expand Up @@ -1768,7 +1768,7 @@ bool MySQL_HostGroups_Manager::commit(
}
if (atoi(r->fields[7])!=atoi(r->fields[17])) {
if (GloMTH->variables.hostgroup_manager_verbose)
proxy_info("Changing max_connections for server %d:%s:%d (%s:%d) from %d (%d) to %d\n" , mysrvc->myhgc->hid , mysrvc->address, mysrvc->port, r->fields[1], atoi(r->fields[2]), atoi(r->fields[7]) , mysrvc->max_connections , atoi(r->fields[17]));
proxy_info("Changing max_connections for server %d:%s:%d (%s:%d) from %d (%ld) to %d\n" , mysrvc->myhgc->hid , mysrvc->address, mysrvc->port, r->fields[1], atoi(r->fields[2]), atoi(r->fields[7]) , mysrvc->max_connections , atoi(r->fields[17]));
mysrvc->max_connections=atoi(r->fields[17]);
}
if (atoi(r->fields[8])!=atoi(r->fields[18])) {
Expand Down Expand Up @@ -2234,7 +2234,7 @@ void MySQL_HostGroups_Manager::generate_mysql_servers_table(int *_onlyhg) {
st=(char *)"SHUNNED";
break;
}
fprintf(stderr,"HID: %d , address: %s , port: %d , gtid_port: %d , weight: %d , status: %s , max_connections: %u , max_replication_lag: %u , use_ssl: %u , max_latency_ms: %u , comment: %s\n", mysrvc->myhgc->hid, mysrvc->address, mysrvc->port, mysrvc->gtid_port, mysrvc->weight, st, mysrvc->max_connections, mysrvc->max_replication_lag, mysrvc->use_ssl, mysrvc->max_latency_us*1000, mysrvc->comment);
fprintf(stderr,"HID: %d , address: %s , port: %d , gtid_port: %d , weight: %ld , status: %s , max_connections: %ld , max_replication_lag: %u , use_ssl: %u , max_latency_ms: %u , comment: %s\n", mysrvc->myhgc->hid, mysrvc->address, mysrvc->port, mysrvc->gtid_port, mysrvc->weight, st, mysrvc->max_connections, mysrvc->max_replication_lag, mysrvc->use_ssl, mysrvc->max_latency_us*1000, mysrvc->comment);
}
lst->add(mysrvc);
if (lst->len==32) {
Expand Down Expand Up @@ -6920,7 +6920,7 @@ T j_get_srv_default_int_val(
proxy_error(
"Invalid type '%s'(%hhu) supplied for 'mysql_hostgroup_attributes.servers_defaults.%s' for hostgroup %d."
" Value NOT UPDATED.\n",
type_name, val_type, key.c_str(), hid
type_name, (int) val_type, key.c_str(), hid
);
}
}
Expand Down Expand Up @@ -7561,7 +7561,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_writer(int _whid, int _rhid
if (mysrvc->max_connections > max_max_connections) {
max_max_connections = mysrvc->max_connections;
}
if (mysrvc->use_ssl > max_use_ssl) {
if (mysrvc->use_ssl > (int32_t) max_use_ssl) {
max_use_ssl = mysrvc->use_ssl;
}
}
Expand Down Expand Up @@ -7708,7 +7708,7 @@ void MySQL_HostGroups_Manager::update_aws_aurora_set_reader(int _whid, int _rhid
if (mysrvc->max_connections > max_max_connections) {
max_max_connections = mysrvc->max_connections;
}
if (mysrvc->use_ssl > max_use_ssl) {
if (mysrvc->use_ssl > (int32_t) max_use_ssl) {
max_use_ssl = mysrvc->use_ssl;
}
if (strcmp(mysrvc->address,full_hostname)==0 && mysrvc->port==aurora_port) {
Expand Down Expand Up @@ -7908,7 +7908,7 @@ MySrvC* MySQL_HostGroups_Manager::HostGroup_Server_Mapping::insert_HGM(unsigned
proxy_info(
"Found server node in Host Group Container %s:%d as 'OFFLINE_HARD', setting back as 'ONLINE' with:"
" hostgroup_id=%d, gtid_port=%d, weight=%ld, compression=%d, max_connections=%ld, use_ssl=%d,"
" max_replication_lag=%ld, max_latency_ms=%ld, comment=%s\n",
" max_replication_lag=%d, max_latency_ms=%d, comment=%s\n",
mysrvc->address, mysrvc->port, hostgroup_id, mysrvc->gtid_port, mysrvc->weight, mysrvc->compression,
mysrvc->max_connections, mysrvc->use_ssl, mysrvc->max_replication_lag, (mysrvc->max_latency_us / 1000),
mysrvc->comment
Expand All @@ -7922,10 +7922,10 @@ MySrvC* MySQL_HostGroups_Manager::HostGroup_Server_Mapping::insert_HGM(unsigned

if (!ret_srv) {
if (GloMTH->variables.hostgroup_manager_verbose) {
proxy_info("Creating new server in HG %d : %s:%d , gtid_port=%d, weight=%d, status=%d\n", hostgroup_id, srv->address, srv->port, srv->gtid_port, srv->weight, srv->status);
proxy_info("Creating new server in HG %d : %s:%d , gtid_port=%d, weight=%ld, status=%d\n", hostgroup_id, srv->address, srv->port, srv->gtid_port, srv->weight, srv->status);
}

proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Adding new server %s:%d , weight=%d, status=%d, mem_ptr=%p into hostgroup=%d\n", srv->address, srv->port, srv->weight, srv->status, srv, hostgroup_id);
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Adding new server %s:%d , weight=%ld, status=%d, mem_ptr=%p into hostgroup=%d\n", srv->address, srv->port, srv->weight, srv->status, srv, hostgroup_id);

ret_srv = new MySrvC(srv->address, srv->port, srv->gtid_port, srv->weight, srv->status, srv->compression,
srv->max_connections, srv->max_replication_lag, srv->use_ssl, (srv->max_latency_us / 1000), srv->comment);
Expand Down
2 changes: 1 addition & 1 deletion lib/MySQL_Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ void MySQL_Logger::log_request(MySQL_Session *sess, MySQL_Data_Stream *myds) {
break;
case WAITING_CLIENT_DATA:
{
unsigned char c=*((unsigned char *)sess->pktH->ptr+sizeof(mysql_hdr));
unsigned char c=*((unsigned char *)sess->pkt.ptr+sizeof(mysql_hdr));
switch ((enum_mysql_command)c) {
case _MYSQL_COM_STMT_PREPARE:
// proxysql is responding to COM_STMT_PREPARE without
Expand Down
1 change: 0 additions & 1 deletion lib/MySQL_Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3572,7 +3572,6 @@ gr_node_info_t gr_update_hosts_map(
// NOTE: This isn't specified in the initializer list due to current standard limitations
gr_node_info_t node_info {};
node_info.srv_st = gr_srv_st;
MySQL_Monitor_State_Data_Task_Result task_result = mmsd->get_task_result();

// Consider 'time_now' to be 'now - fetch_duration'
unsigned long long time_now=realtime_time();
Expand Down
10 changes: 4 additions & 6 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ bool MySQL_Session::handler_CommitRollback(PtrSize_t *pkt) {
// specific connection, for that, we update 'current_hostgroup' with the first active transaction we are
// able to find. If more transactions are simultaneously open for the session, more 'COMMIT|ROLLBACK'
// commands are required to be issued by the client to continue ending transactions.
unsigned int hg = FindOneActiveTransaction(true);
int hg = FindOneActiveTransaction(true);
if (hg != -1) {
// there is an active transaction, we must forward the request
current_hostgroup = hg;
Expand Down Expand Up @@ -1584,7 +1584,7 @@ bool MySQL_Session::handler_special_queries(PtrSize_t *pkt) {
}

void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY___create_mirror_session() {
if (pktH->size < 15*1024*1024 && (qpo->mirror_hostgroup >= 0 || qpo->mirror_flagOUT >= 0)) {
if (pkt.size < 15*1024*1024 && (qpo->mirror_hostgroup >= 0 || qpo->mirror_flagOUT >= 0)) {
// check if there are too many mirror sessions in queue
if (thread->mirror_queue_mysql_sessions->len >= (unsigned int)mysql_thread___mirror_max_queue_length) {
return;
Expand Down Expand Up @@ -1633,9 +1633,9 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C
newsess->default_schema=strdup(default_schema);
}
}
newsess->mirrorPkt.size=pktH->size;
newsess->mirrorPkt.size=pkt.size;
newsess->mirrorPkt.ptr=l_alloc(newsess->mirrorPkt.size);
memcpy(newsess->mirrorPkt.ptr,pktH->ptr,pktH->size);
memcpy(newsess->mirrorPkt.ptr,pkt.ptr,pkt.size);

if (thread->mirror_queue_mysql_sessions->len==0) {
// there are no sessions in the queue, we try to execute immediately
Expand Down Expand Up @@ -4739,8 +4739,6 @@ int MySQL_Session::handler() {
bool wrong_pass=false;
if (to_process==0) return 0; // this should be redundant if the called does the same check
proxy_debug(PROXY_DEBUG_NET,1,"Thread=%p, Session=%p -- Processing session %p\n" , this->thread, this, this);
PtrSize_t pkt;
pktH=&pkt;
//unsigned int j;
//unsigned char c;

Expand Down
1 change: 0 additions & 1 deletion lib/Query_Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,6 @@ unsigned long long Query_Processor::purge_query_digests_async(char **msg) {
digest_umap.swap(digest_umap_aux);
digest_text_umap.swap(digest_text_umap_aux);
pthread_rwlock_unlock(&digest_rwlock);
int num_rows = 0;
unsigned long long curtime1=monotonic_time();
size_t map1_size = digest_umap_aux.size();
size_t map2_size = digest_text_umap_aux.size();
Expand Down
2 changes: 1 addition & 1 deletion src/SQLite3_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ static void * sqlite3server_main_loop(void *arg)
if ( pthread_create(&child, &attr, child_func[callback_func[i]], client) != 0 )
perror("Thread creation");
} else {
proxy_error("accept() error:\n", strerror(errno));
proxy_error("accept() error: %s\n", strerror(errno));
}
}
fds[i].revents=0;
Expand Down

0 comments on commit 983062e

Please sign in to comment.