Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
54fffea
docs(spec): add static analysis design for clang-tidy + cppcheck (202…
renecannao Apr 9, 2026
62dd15f
chore(plans): add static analysis implementation plan (clang-tidy + c…
renecannao Apr 9, 2026
1f2f79f
chore(lint): add lint scripts and Makefile targets
renecannao Apr 9, 2026
4e23c4d
chore(lint): add lint scripts and Makefile targets
renecannao Apr 9, 2026
062c38c
chore(lint): finalize Makefile lint target
renecannao Apr 9, 2026
1c29238
chore(lint): make lint scripts executable
renecannao Apr 9, 2026
af87e1c
chore(lint): make lint scripts executable (fix)
renecannao Apr 9, 2026
2701844
chore(lint): add lint directory, suppressions, and .clang-tidy
renecannao Apr 9, 2026
d8c0f1c
lint: add header-filter to clang-tidy runner and improve normalizatio…
renecannao Apr 9, 2026
f5d77bb
lint: anchor clang-tidy header-filter to repo paths and ignore non-re…
renecannao Apr 9, 2026
656d310
lint: canonicalize clang-tidy diagnostic paths and filter to repo inc…
renecannao Apr 9, 2026
17225cf
lint: fix bugprone-macro-parentheses in 6 header files
renecannao Apr 9, 2026
413584f
lint: fix unsigned-to-signed cast in MySrvConnList::find_idx
renecannao Apr 9, 2026
4810f1f
lint: fix reserved identifier in include guards
renecannao Apr 9, 2026
54e9de7
lint: fix reserved identifier in enum size sentinels
renecannao Apr 9, 2026
f1826cf
lint: fix reserved identifier in member variables
renecannao Apr 9, 2026
b531326
lint: optimize enum underlying types and fix reserved identifiers
renecannao Apr 9, 2026
0d6c027
lint: optimize enum types and fix reserved identifiers in Base/PgSQL …
renecannao Apr 9, 2026
9bdfb8b
lint: optimize enum types and fix reserved identifiers in Query_Cache…
renecannao Apr 9, 2026
f2bc1d4
lint: fix reserved identifier in function parameter names and comments
renecannao Apr 9, 2026
5513f73
lint: replace NULL with nullptr in header files
renecannao Apr 9, 2026
1fd63f9
chore(lint): stop tracking generated lint output files
renecannao Apr 9, 2026
7e1a78f
lint: fix reserved identifiers and include guards
renecannao Apr 9, 2026
a27d07f
lint: fix reserved identifiers and include guards (NO OUTPUT FILES)
renecannao Apr 9, 2026
f67a8a8
gitignore: add lint/ to prevent committing output files
renecannao Apr 9, 2026
2b69c30
plan: cppcheck static analysis fixes
renecannao Apr 10, 2026
39b664a
fix: resolve memleakOnRealloc in PtrArray::allocate
renecannao Apr 10, 2026
9a3f728
perf: use initialization list in Servers_SslParams constructor
renecannao Apr 10, 2026
500488b
fix: delete copy operations in iface_info class
renecannao Apr 10, 2026
a02e878
fix: initialize all members in Query_Processor_Output constructor
renecannao Apr 10, 2026
315f12d
fix: initialize all members in MySQL_Protocol constructor
renecannao Apr 10, 2026
b5617c0
fix: initialize all members in Query_Info constructor
renecannao Apr 10, 2026
04a1487
fix: ensure MySQL_Query_Processor_Output initializes inherited members
renecannao Apr 10, 2026
521fcf5
fix: initialize all members in stmt_execute_metadata_t constructor
renecannao Apr 10, 2026
18f83e9
plan: add more cppcheck fix tasks (noCopyConstructor, printf, null po…
renecannao Apr 10, 2026
a51fe19
fix: delete copy operations in 4 classes (Group_Replication_Info, Gal…
renecannao Apr 10, 2026
5ccb715
fix: cppcheck fixes - printf formats, null checks, copy operators
renecannao Apr 10, 2026
bf9030e
fix: remaining cppcheck printf and null pointer issues
renecannao Apr 10, 2026
d5ffcba
fix: cppcheck deeper analysis - invalidLifetime and arrayIndexOutOfBo…
renecannao Apr 10, 2026
a82224f
fix: PR review feedback - double-free, end comments, dead code
renecannao Apr 10, 2026
24e56d4
fix: SonarCloud issues - explicit ctors, sprintf->snprintf
renecannao Apr 10, 2026
76251a7
fix: resolve invalidFunctionArg in get_current_query - use size_t cast
renecannao Apr 10, 2026
f1a78f8
chore: remove superpowers specs/plans from PR
renecannao Apr 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Checks: >
clang-analyzer-*,
bugprone-*,
performance-*,
modernize-use-nullptr,
modernize-use-override,
modernize-loop-convert,
modernize-pass-by-value,
readability-braces-around-statements
WarningsAsErrors: ''
HeaderFilterRegex: 'include/|lib/'
FormatStyle: none
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Internal Repos
priv-infra/

# Lint output (do not commit)
lint/

# direnv
.envrc.local

Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ ifndef GIT_VERSION_BASE
$(error GIT_VERSION_BASE is not set)
endif

.PHONY: lint lint-generate-cdb lint-run

lint-generate-cdb:
@echo "Generating compile_commands.json (requires bear)"
./scripts/lint/generate-compile-commands.sh

lint-run:
@echo "Running local linters"
./scripts/lint/run-local.sh

lint: lint-generate-cdb lint-run
@echo "Done lint"


### RELEASE TIERS & FEATURE FLAGS:
### ProxySQL supports three distinct release tiers built from the same codebase.
### The tier is controlled by environment variables which enable feature guards
Expand Down
Binary file added compile_commands.events.json
Binary file not shown.
4 changes: 2 additions & 2 deletions include/AI_Features_Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* @endcode
*/

#ifndef __CLASS_AI_FEATURES_MANAGER_H
#define __CLASS_AI_FEATURES_MANAGER_H
#ifndef PROXYSQL_AI_FEATURES_MANAGER_H
#define PROXYSQL_AI_FEATURES_MANAGER_H

#ifdef PROXYSQLGENAI

Expand Down
4 changes: 2 additions & 2 deletions include/AI_Vector_Storage.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __CLASS_AI_VECTOR_STORAGE_H
#define __CLASS_AI_VECTOR_STORAGE_H
#ifndef PROXYSQL_AI_VECTOR_STORAGE_H
#define PROXYSQL_AI_VECTOR_STORAGE_H

#ifdef PROXYSQLGENAI

Expand Down
4 changes: 2 additions & 2 deletions include/Anomaly_Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* @endcode
*/

#ifndef __CLASS_ANOMALY_DETECTOR_H
#define __CLASS_ANOMALY_DETECTOR_H
#ifndef PROXYSQL_ANOMALY_DETECTOR_H
#define PROXYSQL_ANOMALY_DETECTOR_H

#ifdef PROXYSQLGENAI

Expand Down
42 changes: 21 additions & 21 deletions include/Base_HostGroups_Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class BaseHGC { // MySQL Host Group Container
bool connection_warming;
bool configured; // this variable controls if attributes are configured or not. If not configured, they do not apply
bool initialized; // this variable controls if attributes were ever configured or not. Used by reset_attributes()
nlohmann::json * ignore_session_variables_json = NULL; // the JSON format of ignore_session_variables
nlohmann::json * ignore_session_variables_json = nullptr; // the JSON format of ignore_session_variables
} attributes;
struct {
int64_t weight;
Expand Down Expand Up @@ -393,7 +393,7 @@ class Group_Replication_Info {
char *comment;
bool active;
int writer_is_also_reader;
bool __active;
bool active_;
bool need_converge; // this is set to true on LOAD MYSQL SERVERS TO RUNTIME . This ensure that checks wil take an action
int current_num_writers;
int current_num_backup_writers;
Expand All @@ -415,7 +415,7 @@ class Galera_Info {
char *comment;
bool active;
int writer_is_also_reader;
bool __active;
bool active_;
bool need_converge; // this is set to true on LOAD MYSQL SERVERS TO RUNTIME . This ensure that checks wil take an action
int current_num_writers;
int current_num_backup_writers;
Expand Down Expand Up @@ -444,7 +444,7 @@ class AWS_Aurora_Info {
char * domain_name;
char * comment;
bool active;
bool __active;
bool active_;
AWS_Aurora_Info(int w, int r, int _port, char *_end_addr, int maxl, int al, int minl, int lnc, int ci, int ct, bool _a, int wiar, int nrw, char *c);
bool update(int r, int _port, char *_end_addr, int maxl, int al, int minl, int lnc, int ci, int ct, bool _a, int wiar, int nrw, char *c);
~AWS_Aurora_Info();
Expand Down Expand Up @@ -482,20 +482,20 @@ struct p_hg_counter {
myhgm_myconnpool_reset,
myhgm_myconnpool_destroy,
auto_increment_delay_multiplex,
__size
SIZE_
};
};

struct p_hg_gauge {
enum metric {
server_connections_connected = 0,
client_connections_connected,
__size
SIZE_
};
};

struct p_hg_dyn_counter {
enum metric {
enum metric : uint8_t {
conn_pool_bytes_data_recv = 0,
conn_pool_bytes_data_sent,
connection_pool_conn_err,
Expand All @@ -504,22 +504,22 @@ struct p_hg_dyn_counter {
gtid_executed,
proxysql_mysql_error,
mysql_error,
__size
SIZE_
};
};

enum class p_mysql_error_type {
enum class p_mysql_error_type : uint8_t {
mysql,
proxysql
};

struct p_hg_dyn_gauge {
enum metric {
enum metric : uint8_t {
connection_pool_conn_free = 0,
connection_pool_conn_used,
connection_pool_latency_us,
connection_pool_status,
__size
SIZE_
};
};

Expand Down Expand Up @@ -550,7 +550,7 @@ enum READ_ONLY_SERVER_T {
ROS_HOSTNAME = 0,
ROS_PORT,
ROS_READONLY,
ROS__SIZE
ROS_SIZE_
};

enum REPLICATION_LAG_SERVER_T {
Expand All @@ -559,7 +559,7 @@ enum REPLICATION_LAG_SERVER_T {
RLS_PORT,
RLS_CURRENT_REPLICATION_LAG,
RLS_OVERRIDE_REPLICATION_LAG,
RLS__SIZE
RLS_SIZE_
};

/**
Expand Down Expand Up @@ -637,18 +637,18 @@ class MySQL_HostGroups_Manager {
MYSQL_SERVERS_SSL_PARAMS,
MYSQL_SERVERS,

__HGM_TABLES_SIZE
HGM_TABLES_SIZE_
};

std::array<uint64_t, __HGM_TABLES_SIZE> table_resultset_checksum { {0} };
std::array<uint64_t, HGM_TABLES_SIZE_> table_resultset_checksum { {0} };

class HostGroup_Server_Mapping {
public:
enum Type {
WRITER = 0,
READER = 1,

__TYPE_SIZE
TYPE_SIZE_
};

struct Node {
Expand Down Expand Up @@ -713,7 +713,7 @@ class MySQL_HostGroups_Manager {
MySrvC* insert_HGM(unsigned int hostgroup_id, const MySrvC* srv);
void remove_HGM(MySrvC* srv);

std::array<std::vector<Node>, __TYPE_SIZE> mapping; // index 0 contains reader and 1 contains writer hostgroups
std::array<std::vector<Node>, TYPE_SIZE_> mapping; // index 0 contains reader and 1 contains writer hostgroups
int readonly_flag;
MySQL_HostGroups_Manager* myHGM;
};
Expand Down Expand Up @@ -915,12 +915,12 @@ class MySQL_HostGroups_Manager {
//////////////////////////////////////////////////////

/// Prometheus metrics arrays
std::array<prometheus::Counter*, p_hg_counter::__size> p_counter_array {};
std::array<prometheus::Gauge*, p_hg_gauge::__size> p_gauge_array {};
std::array<prometheus::Counter*, p_hg_counter::SIZE_> p_counter_array {};
std::array<prometheus::Gauge*, p_hg_gauge::SIZE_> p_gauge_array {};

// Prometheus dyn_metrics families arrays
std::array<prometheus::Family<prometheus::Counter>*, p_hg_dyn_counter::__size> p_dyn_counter_array {};
std::array<prometheus::Family<prometheus::Gauge>*, p_hg_dyn_gauge::__size> p_dyn_gauge_array {};
std::array<prometheus::Family<prometheus::Counter>*, p_hg_dyn_counter::SIZE_> p_dyn_counter_array {};
std::array<prometheus::Family<prometheus::Gauge>*, p_hg_dyn_gauge::SIZE_> p_dyn_gauge_array {};

/// Prometheus connection_pool metrics
std::map<std::string, prometheus::Counter*> p_conn_pool_bytes_data_recv_map {};
Expand Down
8 changes: 4 additions & 4 deletions include/ClickHouse_Authentication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ typedef struct _ch_account_details_t {
bool fast_forward;
int max_connections;
int num_connections_used;
bool __frontend; // this is used only during the dump
bool __backend; // this is used only during the dump
bool __active;
bool frontend_; // this is used only during the dump
bool backend_; // this is used only during the dump
bool active_;
} ch_account_details_t;

struct ch_dup_account_details_t {
Expand Down Expand Up @@ -79,7 +79,7 @@ class ClickHouse_Authentication {
bool *fast_forward, int *max_connections, void **sha1_pass);
ch_account_details_t lookup(char* username, enum cred_username_type usertype, const ch_dup_account_details_t& dup_details);
int dump_all_users(ch_account_details_t ***, bool _complete = true);
int increase_frontend_user_connections(char *username, int *mc = NULL);
int increase_frontend_user_connections(char *username, int *mc = nullptr);
void decrease_frontend_user_connections(char *username);
void set_all_inactive(enum cred_username_type usertype);
void remove_inactives(enum cred_username_type usertype);
Expand Down
6 changes: 3 additions & 3 deletions include/Command_Counter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __CLASS_COMMAND_COUNTER_H
#define __CLASS_COMMAND_COUNTER_H
#ifndef PROXYSQL_COMMAND_COUNTER_H
#define PROXYSQL_COMMAND_COUNTER_H

class Command_Counter {
public:
Expand Down Expand Up @@ -60,4 +60,4 @@ class Command_Counter {
}
};

#endif /* __CLASS_COMMAND_COUNTER_H */
#endif /* PROXYSQL_COMMAND_COUNTER_H */
4 changes: 2 additions & 2 deletions include/GenAI_Thread.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __CLASS_GENAI_THREAD_H
#define __CLASS_GENAI_THREAD_H
#ifndef PROXYSQL_GENAI_THREAD_H
#define PROXYSQL_GENAI_THREAD_H

#ifdef PROXYSQLGENAI

Expand Down
6 changes: 3 additions & 3 deletions include/LLM_Bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
* @endcode
*/

#ifndef __CLASS_LLM_BRIDGE_H
#define __CLASS_LLM_BRIDGE_H
#ifndef PROXYSQL_LLM_BRIDGE_H
#define PROXYSQL_LLM_BRIDGE_H

#ifdef PROXYSQLGENAI

Expand Down Expand Up @@ -334,4 +334,4 @@ class LLM_Bridge {

#endif /* PROXYSQLGENAI */

#endif // __CLASS_LLM_BRIDGE_H
#endif /* PROXYSQL_LLM_BRIDGE_H */
4 changes: 2 additions & 2 deletions include/MCP_Thread.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __CLASS_MCP_THREAD_H
#define __CLASS_MCP_THREAD_H
#ifndef PROXYSQL_MCP_THREAD_H
#define PROXYSQL_MCP_THREAD_H

#ifdef PROXYSQLGENAI

Expand Down
10 changes: 5 additions & 5 deletions include/MySQL_Authentication.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __CLASS_MYSQL_AUTHENTICATION_H
#define __CLASS_MYSQL_AUTHENTICATION_H
#ifndef PROXYSQL_MYSQL_AUTHENTICATION_H
#define PROXYSQL_MYSQL_AUTHENTICATION_H

#include "proxysql.h"
#include "cpp.h"
Expand All @@ -22,9 +22,9 @@ typedef struct _account_details_t {
int max_connections;
int num_connections_used;
int num_connections_used_addl_pass;
bool __frontend; // this is used only during the dump
bool __backend; // this is used only during the dump
bool __active;
bool frontend_; // this is used only during the dump
bool backend_; // this is used only during the dump
bool active_;
char *attributes = nullptr;
char *comment = nullptr;
} account_details_t;
Expand Down
6 changes: 3 additions & 3 deletions include/MySQL_Data_Stream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __CLASS_MYSQL_DATA_STREAM_H
#define __CLASS_MYSQL_DATA_STREAM_H
#ifndef PROXYSQL_MYSQL_DATA_STREAM_H
#define PROXYSQL_MYSQL_DATA_STREAM_H

#include "proxysql.h"
#include "cpp.h"
Expand Down Expand Up @@ -287,4 +287,4 @@ class MySQL_Data_Stream

void get_client_myds_info_json(nlohmann::json&);
};
#endif /* __CLASS_MYSQL_DATA_STREAM_H */
#endif /* PROXYSQL_MYSQL_DATA_STREAM_H */
Loading
Loading