Parcourir la source

[3161] Pass values by reference where it makes sense.

Reported by cpp-check.
Marcin Siodelski il y a 8 ans
Parent
commit
a024d79008

+ 1 - 1
src/bin/dhcp6/tests/host_unittest.cc

@@ -453,7 +453,7 @@ public:
     /// reservation.
     void testReservationByIdentifier(Dhcp6Client& client,
                                      const unsigned int config_index,
-                                     const std::string exp_ip_address) {
+                                     const std::string& exp_ip_address) {
         configure(CONFIGS[config_index], *client.getServer());
 
         const Subnet6Collection* subnets = CfgMgr::instance().getCurrentCfg()->

+ 1 - 1
src/lib/asiolink/tests/udp_socket_unittest.cc

@@ -79,7 +79,7 @@ public:
     /// data.
     ///
     /// \param which Which of the two callback objects this is
-    UDPCallback(std::string which) : ptr_(new PrivateData())
+    UDPCallback(const std::string& which) : ptr_(new PrivateData())
     {
         setName(which);
     }

+ 3 - 3
src/lib/dhcpsrv/tests/duid_config_parser_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -49,7 +49,7 @@ public:
     /// @param duid_type DUID type in numeric format.
     /// @param duid_type_text DUID type in textual format.
     void testTypeOnly(const DUID::DUIDType& duid_type,
-                      const std::string duid_type_text) const;
+                      const std::string& duid_type_text) const;
 
     /// @brief Test that invalid configuration is rejected.
     ///
@@ -109,7 +109,7 @@ DUIDConfigParserTest::build(const std::string& config) const {
 
 void
 DUIDConfigParserTest::testTypeOnly(const DUID::DUIDType& duid_type,
-                                   const std::string duid_type_text) const {
+                                   const std::string& duid_type_text) const {
     // Use DUID configuration with only a "type".
     ASSERT_NO_THROW(build(createConfigWithType(duid_type_text)));
 

+ 1 - 1
src/lib/dhcpsrv/tests/pgsql_exchange_unittest.cc

@@ -225,7 +225,7 @@ public:
     /// @lineno line number from where the call was invoked
     ///
     /// Asserts if the result set status does not equal the expected outcome.
-    void runSql(PgSqlResultPtr& r, const std::string sql, int exp_outcome,
+    void runSql(PgSqlResultPtr& r, const std::string& sql, int exp_outcome,
                 int lineno) {
         r.reset(new PgSqlResult(PQexec(*conn_, sql.c_str())));
         ASSERT_EQ(PQresultStatus(*r), exp_outcome)

+ 19 - 13
src/lib/eval/tests/context_unittest.cc

@@ -173,7 +173,7 @@ public:
     /// @param exp_code expected option code to be parsed
     /// @param exp_repr expected representation to be parsed
     /// @param exp_tokens expected number of tokens
-    void testRelay6Option(std::string expr,
+    void testRelay6Option(const std::string& expr,
                          uint8_t exp_level,
                          uint16_t exp_code,
                          TokenOption::RepresentationType exp_repr,
@@ -221,7 +221,7 @@ public:
     /// @param expr expression to be parsed
     /// @param exp_type expected metadata type to be parsed
     /// @param exp_tokens expected number of tokens
-    void testPktMetadata(std::string expr,
+    void testPktMetadata(const std::string& expr,
                          TokenPkt::MetadataType exp_type,
                          int exp_tokens) {
         EvalContext eval(Option::V6);
@@ -266,7 +266,7 @@ public:
     /// @param expr expression to be parsed
     /// @param exp_type expected field type to be parsed
     /// @param exp_tokens expected number of tokens
-    void testPkt4Field(std::string expr,
+    void testPkt4Field(const std::string& expr,
                        TokenPkt4::FieldType exp_type,
                        int exp_tokens) {
         EvalContext eval(Option::V4);
@@ -314,7 +314,8 @@ public:
     /// @param expr expression to be parsed
     /// @param exp_type expected field type to be parsed
     /// @param exp_tokens expected number of tokens
-    void testPkt6Field(std::string expr, TokenPkt6::FieldType exp_type,
+    void testPkt6Field(const std::string& expr,
+                       TokenPkt6::FieldType exp_type,
                        int exp_tokens) {
         EvalContext eval(Option::V6);
 
@@ -363,7 +364,7 @@ public:
     /// @param exp_level expected level to be parsed
     /// @param exp_type expected field type to be parsed
     /// @param exp_tokens expected number of tokens
-    void testRelay6Field(std::string expr,
+    void testRelay6Field(const std::string& expr,
                          uint8_t exp_level,
                          TokenRelay6Field::FieldType exp_type,
                          int exp_tokens) {
@@ -461,8 +462,9 @@ public:
     /// @param vendor_id expected vendor-id (aka enterprise number)
     /// @param option_code expected option code (ignored if 0)
     /// @param expected_repr expected representation (either 'exists' or 'hex')
-    void testVendor(std::string expr, Option::Universe u, uint32_t vendor_id,
-                    uint16_t option_code, TokenOption::RepresentationType expected_repr) {
+    void testVendor(const std::string& expr, Option::Universe u,
+                    uint32_t vendor_id, uint16_t option_code,
+                    TokenOption::RepresentationType expected_repr) {
         EvalContext eval(u);
 
         EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
@@ -487,7 +489,8 @@ public:
     /// @param u universe (V4 or V6)
     /// @param vendor_id expected vendor-id (aka enterprise number)
     /// @param expected_repr expected representation (either 'exists' or 'hex')
-    void testVendor(std::string expr, Option::Universe u, uint32_t vendor_id,
+    void testVendor(const std::string& expr, Option::Universe u,
+                    uint32_t vendor_id,
                     TokenOption::RepresentationType expected_repr) {
         testVendor(expr, u, vendor_id, 0, expected_repr);
     }
@@ -499,7 +502,8 @@ public:
     ///
     /// @param expr expression to be parsed
     /// @param u universe (V4 or V6)
-    void testVendorEnterprise(std::string expr, Option::Universe u) {
+    void testVendorEnterprise(const std::string& expr,
+                              Option::Universe u) {
         EvalContext eval(u);
 
         EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
@@ -524,7 +528,8 @@ public:
     /// @param expr expression to be parsed
     /// @param u universe (V4 or V6)
     /// @param vendor_id expected vendor-id (aka enterprise number)
-    void testVendorClass(std::string expr, Option::Universe u, uint32_t vendor_id) {
+    void testVendorClass(const std::string& expr,
+                         Option::Universe u, uint32_t vendor_id) {
         EvalContext eval(u);
 
         EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
@@ -548,8 +553,8 @@ public:
     /// @param u universe (V4 or V6)
     /// @param vendor_id expected vendor-id (aka enterprise number)
     /// @param index expected data index
-    void testVendorClass(std::string expr, Option::Universe u, uint32_t vendor_id,
-                         uint16_t index) {
+    void testVendorClass(const std::string& expr, Option::Universe u,
+                         uint32_t vendor_id, uint16_t index) {
         EvalContext eval(u);
 
         EXPECT_NO_THROW(parsed_ = eval.parseString(expr));
@@ -572,7 +577,8 @@ public:
     ///
     /// @param expr expression to be parsed
     /// @param u universe (V4 or V6)
-    void testVendorClassEnterprise(std::string expr, Option::Universe u) {
+    void testVendorClassEnterprise(const std::string& expr,
+                                   Option::Universe u) {
         EvalContext eval(u);
 
         EXPECT_NO_THROW(parsed_ = eval.parseString(expr));