Skip to content

Commit 65c492f

Browse files
committed
Bug#37471922: Auto-fix clang-tidy warnings [73/n] [noclose]
Generate fixes for a number of warnings that clang-tidy can fix automatically. This commit fixes the warning 'performance-unnecessary-value-param'. Change example: - void create_file(std::string path) { + void create_file(const std::string &path) { Change-Id: Ic2468b38de8fad4297b2ac2294bb0a25dcc78ad5
1 parent 0507297 commit 65c492f

File tree

109 files changed

+272
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+272
-214
lines changed

client/check/mysqlcheck_core.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <mysqld_error.h>
2828
#include <sys/types.h>
2929
#include <string>
30+
#include <utility>
3031
#include <vector>
3132

3233
#include "client/check/mysqlcheck.h"
@@ -387,7 +388,7 @@ void mysql_check(MYSQL *connection, int what_to_do, bool opt_alldbs,
387388
::opt_upgrade = opt_upgrade;
388389
::opt_write_binlog = opt_write_binlog;
389390
::verbose = verbose;
390-
::opt_skip_database = opt_skip_database;
391+
::opt_skip_database = std::move(opt_skip_database);
391392
::DBError = dberror;
392393

393394
if (!::opt_write_binlog) {

client/mysqldump.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -812,19 +812,19 @@ static std::unordered_map<string, string> compatibility_rpl_replica_commands = {
812812
static std::unordered_map<string, string> compatibility_rpl_source_commands = {
813813
{"SHOW BINARY LOG STATUS", "SHOW MASTER STATUS"}};
814814

815-
static string get_compatible_rpl_source_query(string command) {
815+
static string get_compatible_rpl_source_query(const string &command) {
816816
return ((opt_server_version < FIRST_REPLICA_COMMAND_VERSION)
817817
? compatibility_rpl_source_commands.at(command)
818818
: command);
819819
}
820820

821-
static string get_compatible_rpl_replica_query(string command) {
821+
static string get_compatible_rpl_replica_query(const string &command) {
822822
return ((opt_server_version < FIRST_REPLICA_COMMAND_VERSION)
823823
? compatibility_rpl_replica_commands.at(command)
824824
: command);
825825
}
826826

827-
static string get_compatible_rpl_replica_command(string command) {
827+
static string get_compatible_rpl_replica_command(const string &command) {
828828
return ((opt_output_as_version_mode == Output_as_version_mode::BEFORE_8_0_23)
829829
? compatibility_rpl_replica_commands.at(command)
830830
: command);

client/mysqltest.cc

+9-5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include <cstdarg>
6767
#include <cstdio>
6868
#include <cstdlib>
69+
#include <utility>
6970
#ifndef _WIN32
7071
#include <poll.h>
7172
#include <sys/time.h>
@@ -678,7 +679,9 @@ static void free_all_replace() {
678679
class AsyncTimer {
679680
public:
680681
explicit AsyncTimer(std::string label)
681-
: label_(label), time_(std::chrono::system_clock::now()), start_(time_) {}
682+
: label_(std::move(label)),
683+
time_(std::chrono::system_clock::now()),
684+
start_(time_) {}
682685

683686
~AsyncTimer() {
684687
auto now = std::chrono::system_clock::now();
@@ -5948,7 +5951,8 @@ static bool check_and_filter_once_property(DYNAMIC_STRING ds_property,
59485951
/// @param once_prop Flag specifying whether a property should be set
59495952
/// for next statement only.
59505953
static void handle_disable_warnings(std::uint32_t warning_code,
5951-
std::string warning, bool once_prop) {
5954+
const std::string &warning,
5955+
bool once_prop) {
59525956
if (enabled_warnings->count()) {
59535957
// Remove the warning from list of enabled warnings.
59545958
enabled_warnings->remove_warning(warning_code, once_prop);
@@ -5973,7 +5977,7 @@ static void handle_disable_warnings(std::uint32_t warning_code,
59735977
/// @param once_prop Flag specifying whether a property should be set
59745978
/// for next statement only.
59755979
static void handle_enable_warnings(std::uint32_t warning_code,
5976-
std::string warning, bool once_prop) {
5980+
const std::string &warning, bool once_prop) {
59775981
if (disabled_warnings->count()) {
59785982
// Remove the warning from list of disabled warnings.
59795983
disabled_warnings->remove_warning(warning_code, once_prop);
@@ -8641,7 +8645,7 @@ static bool match_warnings(Expected_warnings *warnings, std::uint32_t error,
86418645
///
86428646
/// @retval True if a warning is found in the list of disabled or enabled
86438647
/// warnings, false otherwise.
8644-
static bool handle_one_warning(DYNAMIC_STRING *ds, std::string warning) {
8648+
static bool handle_one_warning(DYNAMIC_STRING *ds, const std::string &warning) {
86458649
// Each line of show warnings output contains information about
86468650
// error level, error code and the error/warning message separated
86478651
// by '\t'. Parse each line from the show warnings output to
@@ -11584,7 +11588,7 @@ class Comp_lines {
1158411588
}
1158511589
};
1158611590

11587-
static size_t length_of_n_first_columns(std::string str,
11591+
static size_t length_of_n_first_columns(const std::string &str,
1158811592
int start_sort_column) {
1158911593
std::stringstream columns(str);
1159011594
std::string temp;

client/mysqltest/error_names.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static st_error global_error_names[] = {
3131
#endif /* IN_DOXYGEN */
3232
{nullptr, 0, nullptr, nullptr, nullptr, 0}};
3333

34-
int get_errcode_from_name(std::string error_name) {
34+
int get_errcode_from_name(const std::string &error_name) {
3535
for (st_error *error = global_error_names; error->name; error++) {
3636
if (error_name == error->name) return error->error_code;
3737
}

client/mysqltest/error_names.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct st_error {
4040
/// @param error_name Error name string
4141
///
4242
/// @retval -1 if error name is unknown, error code otherwise.
43-
int get_errcode_from_name(std::string error_name);
43+
int get_errcode_from_name(const std::string &error_name);
4444

4545
/// Get an error name from an error code.
4646
///

components/keyrings/common/data/data.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2323

2424
#include <functional>
25+
#include <utility>
2526

2627
#include "data.h"
2728

@@ -35,7 +36,7 @@ Data::Data(const Sensitive_data &data, Type type)
3536

3637
/* Following constructors imply no data */
3738
Data::Data() : Data("", "") {}
38-
Data::Data(Type type) : Data("", type) {}
39+
Data::Data(Type type) : Data("", std::move(type)) {}
3940

4041
/** Copy constructor */
4142
Data::Data(const Data &src) : Data(src.data_, src.type_) {}

components/keyrings/common/json_data/json_reader.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Json_reader::Json_reader() : Json_reader(schema_version_1_0, "") {}
114114
@returns property value string in case property is present,
115115
empty string otherwise.
116116
*/
117-
std::string Json_reader::property(const std::string property_key) const {
117+
std::string Json_reader::property(const std::string &property_key) const {
118118
if (!valid_) return {};
119119
return document_[property_key.c_str()].Get<std::string>();
120120
}

components/keyrings/common/json_data/json_reader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class Json_reader {
127127
128128
@returns value of the property
129129
*/
130-
std::string property(const std::string property_key) const;
130+
std::string property(const std::string &property_key) const;
131131

132132
private:
133133
/** Data in JSON DOM format */

components/libminchassis/mysql_component.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
2424
#include "mysql_component_imp.h"
2525

2626
#include <cstddef>
27+
#include <utility>
2728
#include <vector>
2829

2930
mysql_component::mysql_component(mysql_component_t *component_data,
3031
my_string urn)
31-
: m_component_data(component_data), m_urn(urn) {
32+
: m_component_data(component_data), m_urn(std::move(urn)) {
3233
for (const mysql_metadata_ref_t *metadata_iterator = component_data->metadata;
3334
metadata_iterator->key != nullptr; ++metadata_iterator) {
3435
this->set_value(metadata_iterator->key, metadata_iterator->value);

components/test/perfschema/test_pfs_notification.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static bool negative_tests = false;
9999
/* Callback for special use case */
100100
void session_connect_internal(const PSI_thread_attrs *thread_attrs);
101101

102-
void print_log(std::string msg);
102+
void print_log(const std::string &msg);
103103

104104
/**
105105
Log file operations
@@ -119,7 +119,7 @@ void close_log() {
119119
if (log_outfile.is_open()) log_outfile.close();
120120
}
121121

122-
void print_log(std::string msg) {
122+
void print_log(const std::string &msg) {
123123
if (!log_enabled) return;
124124

125125
/* Write to both log file and stderr. */

components/test/perfschema/test_pfs_resource_group.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int handle = 0;
8282
static std::ofstream log_outfile;
8383
static std::string separator("===========================");
8484

85-
void print_log(std::string msg) {
85+
void print_log(const std::string &msg) {
8686
log_outfile << msg << std::endl;
8787
fprintf(stderr, "%s\n", msg.c_str());
8888
fflush(stderr);

components/test/statement_services/utils.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ auto parse_rows(my_h_statement statement, size_t fields_count,
177177

178178
// Make a string where values are separated by separator
179179
auto string_from_vector(const std::vector<std::string> &values,
180-
const std::string separator) -> std::string {
180+
const std::string &separator) -> std::string {
181181
auto temp = std::string{};
182182
auto first = true;
183183
for (const auto &header : values) {

include/compression.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ constexpr int default_zstd_compression_level = 3;
4848

4949
/* Helper functions to validate compression algorithm and level */
5050
enum_compression_algorithm get_compression_algorithm(
51-
std::string name = std::string());
51+
const std::string &name = std::string());
5252
std::string get_compression_algorithm_name(enum_compression_algorithm);
53-
void parse_compression_algorithms_list(std::string name,
53+
void parse_compression_algorithms_list(const std::string &name,
5454
std::vector<std::string> &list);
5555
bool is_zstd_compression_level_valid(uint level);
56-
bool validate_compression_attributes(std::string algorithm_names,
57-
std::string channel_name,
56+
bool validate_compression_attributes(const std::string &algorithm_names,
57+
const std::string &channel_name,
5858
bool ignore_errors);
5959

6060
#endif /* COMPRESSION_INCLUDED */

include/my_sys.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ extern void set_psi_tls_channel_service(void *psi);
957957
[[nodiscard]] extern unsigned long long my_physical_memory();
958958

959959
/* Compares versions and determine if clone is allowed */
960-
[[nodiscard]] extern bool are_versions_clone_compatible(std::string ver1,
961-
std::string ver2);
960+
[[nodiscard]] extern bool are_versions_clone_compatible(
961+
const std::string &ver1, const std::string &ver2);
962962

963963
/**
964964
@} (end of group MYSYS)

libmysql/authentication_kerberos/auth_kerberos_client_plugin.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <cstdio>
3535
#include <cstdlib>
3636
#include <cstring>
37+
#include <utility>
3738

3839
#include <mysql.h>
3940
#include <mysql/client_plugin.h>
@@ -81,7 +82,7 @@ bool Kerberos_plugin_client::obtain_store_credentials() {
8182
}
8283

8384
void Kerberos_plugin_client::set_mysql_account_name(
84-
std::string mysql_account_name) {
85+
const std::string &mysql_account_name) {
8586
std::string cc_user_name;
8687
std::stringstream log_client_stream;
8788

@@ -141,17 +142,18 @@ void Kerberos_plugin_client::set_mysql_account_name(
141142
}
142143
}
143144

144-
void Kerberos_plugin_client::set_upn_info(std::string name, std::string pwd) {
145+
void Kerberos_plugin_client::set_upn_info(const std::string &name,
146+
std::string pwd) {
145147
/*
146148
Setting UPN using MySQL account name + user realm.
147149
*/
148-
m_password = pwd;
150+
m_password = std::move(pwd);
149151
if (!name.empty()) {
150152
create_upn(name);
151153
}
152154
}
153155

154-
void Kerberos_plugin_client::create_upn(std::string account_name) {
156+
void Kerberos_plugin_client::create_upn(const std::string &account_name) {
155157
if (!m_as_user_relam.empty()) {
156158
m_user_principal_name = account_name + "@" + m_as_user_relam;
157159
}

libmysql/authentication_kerberos/auth_kerberos_client_plugin.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ class Kerberos_plugin_client {
5050
authentication_mode mode);
5151
~Kerberos_plugin_client() = default;
5252
bool authenticate();
53-
void set_upn_info(std::string name, std::string pwd);
54-
void set_mysql_account_name(std::string name);
53+
void set_upn_info(const std::string &name, std::string pwd);
54+
void set_mysql_account_name(const std::string &name);
5555
bool obtain_store_credentials();
5656
bool read_spn_realm_from_server();
5757

5858
protected:
59-
void create_upn(std::string account_name);
59+
void create_upn(const std::string &account_name);
6060
std::string m_user_principal_name;
6161
std::string m_password;
6262
std::string m_service_principal;

libmysql/authentication_kerberos/log_client.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void Logger_client::set_log_level(log_client_level level) {
2727
m_log_level = level;
2828
}
2929

30-
void Logger_client::write(std::string data) {
30+
void Logger_client::write(const std::string &data) {
3131
std::cerr << data << "\n";
3232
std::cerr.flush();
3333
}

libmysql/authentication_kerberos/log_client.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Logger_client {
5050
template <log_client_type::log_type type>
5151
void log(std::string msg);
5252
void set_log_level(log_client_level level);
53-
void write(std::string data);
53+
void write(const std::string &data);
5454
void log_client_plugin_data_exchange(const unsigned char *buffer,
5555
unsigned int length);
5656

libmysql/fido_client/common/registration.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool registration::make_credentials(const char *challenge) {
6666
6767
@param [in] user buffer holding user name
6868
*/
69-
void registration::set_user(std::string user) {
69+
void registration::set_user(const std::string &user) {
7070
/*
7171
1, 2 parameters refer to user ID/len, which should be unique for
7272
a given user, else same credentials is re used in authenticator.
@@ -81,7 +81,7 @@ void registration::set_user(std::string user) {
8181
8282
@param [in] rp_id buffer holding relying party name
8383
*/
84-
void registration::set_rp_id(std::string rp_id) {
84+
void registration::set_rp_id(const std::string &rp_id) {
8585
fido_cred_set_rp(m_cred, rp_id.c_str(), nullptr);
8686
}
8787

libmysql/fido_client/common/registration.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class registration {
5353
virtual ~registration();
5454
bool make_credentials(const char *challenge);
5555
/* set rp id */
56-
void set_rp_id(std::string rp_id);
56+
void set_rp_id(const std::string &rp_id);
5757
/* set user name */
58-
void set_user(std::string user);
58+
void set_user(const std::string &user);
5959

6060
/* get authenticator data details */
6161
size_t get_authdata_len();

mysys/my_version.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ static ParseArray parse_version_string(std::string version, bool &is_valid) {
109109
@param ver2 version2 string
110110
@return true if cloning is allowed between ver1 and ver2, false otherwise
111111
*/
112-
bool are_versions_clone_compatible(std::string ver1, std::string ver2) {
112+
bool are_versions_clone_compatible(const std::string &ver1,
113+
const std::string &ver2) {
113114
if (ver1 == ver2) {
114115
return true;
115116
}

plugin/clone/src/clone_plugin.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ using Donor_Callback = std::function<bool(std::string &, uint32_t)>;
182182
@param[in] callback callback function
183183
@return true, if scan is successful or match is found. */
184184
static bool scan_donor_list(const std::string &donor_list,
185-
Donor_Callback callback) {
185+
const Donor_Callback &callback) {
186186
size_t comma_pos = 0;
187187
size_t begin_pos = 0;
188188

@@ -318,7 +318,9 @@ static int check_donor_addr_format(MYSQL_THD thd, SYS_VAR *var [[maybe_unused]],
318318

319319
const std::string addrs(addrs_cstring);
320320

321-
Donor_Callback const callback = [](std::string, uint32_t) { return (false); };
321+
const Donor_Callback callback = [](const std::string &, uint32_t) {
322+
return (false);
323+
};
322324

323325
bool const success = scan_donor_list(addrs_cstring, callback);
324326

plugin/group_replication/include/sql_service/sql_service_interface.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Sql_service_interface {
143143
@retval >0 SQL Error Number returned from MySQL Service API
144144
@retval <0 local errors
145145
*/
146-
long execute_query(std::string query_string);
146+
long execute_query(const std::string &query_string);
147147

148148
/**
149149
Executes a server command in a session.
@@ -163,7 +163,7 @@ class Sql_service_interface {
163163
@retval <0 local errors
164164
*/
165165
long execute_query(
166-
std::string sql_string, Sql_resultset *rset,
166+
const std::string &sql_string, Sql_resultset *rset,
167167
enum cs_text_or_binary cs_txt_bin = CS_TEXT_REPRESENTATION,
168168
const CHARSET_INFO *cs_charset = &my_charset_utf8mb3_general_ci);
169169

0 commit comments

Comments
 (0)