]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3451] Razvan's simplification Kea-3.1.3
authorAndrei Pavel <andrei@isc.org>
Tue, 28 Oct 2025 07:58:15 +0000 (09:58 +0200)
committerAndrei Pavel <andrei@isc.org>
Tue, 28 Oct 2025 07:58:15 +0000 (09:58 +0200)
src/bin/dhcp4/dhcp4_srv.cc
src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc
src/lib/dns/tests/master_lexer_state_unittest.cc

index 137316a6d9d0fc28eabb3a47987cb25356c6a401..93fb8d3b2595a3435a6f88254c785f88e912240a 100644 (file)
@@ -3356,10 +3356,10 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
             try {
                 createNameChangeRequests(lease, ctx->old_lease_,
                                          *ex.getContext()->getDdnsParams());
-            } catch (const Exception& exception) {
+            } catch (const Exception& e) {
                 LOG_ERROR(ddns4_logger, DHCP4_NCR_CREATION_FAILED)
                     .arg(query->getLabel())
-                    .arg(exception.what());
+                    .arg(e.what());
             }
         }
 
@@ -3412,7 +3412,7 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
 
 void
 Dhcpv4Srv::postAllocateNameUpdate(const AllocEngine::ClientContext4Ptr& ctx, const Lease4Ptr& lease,
-                                 const Pkt4Ptr& query, const Pkt4Ptr& resp, bool client_name_changed) {
+                                  const Pkt4Ptr& query, const Pkt4Ptr& resp, bool client_name_changed) {
     // We may need to update FQDN or hostname if the server is to generate
     // new name from the allocated IP address or if the allocation engine
     // has switched to a different subnet within a shared network.  Get
@@ -5015,11 +5015,11 @@ void Dhcpv4Srv::evaluateAdditionalClasses(Dhcpv4Exchange& ex) {
                 // Matching: add the class
                 query->addClass(cclass);
             }
-        } catch (const Exception& exception) {
+        } catch (const Exception& e) {
             LOG_ERROR(dhcp4_logger, DHCP4_ADDITIONAL_CLASS_EVAL_ERROR)
                 .arg(query->getLabel())
                 .arg(cclass)
-                .arg(exception.what());
+                .arg(e.what());
         }
     }
 }
index cc3bcbd24727df841aaed441091e435082b29b4c..182088436d2e78afeab7ea34593ea69922aeaf71 100644 (file)
@@ -1064,9 +1064,9 @@ GenericConfigBackendDHCPv6Test::getSubnet6Test() {
                  isc::InvalidOperation);
 
     // Test that this subnet will be fetched for various server selectors.
-    auto test_get_subnet = [this, &subnet](const std::string& test_case_name,
-                                           const ServerSelector& server_selector,
-                                           const std::string& expected_tag = ServerTag::ALL) {
+    auto test_get_subnet = [this, &subnet] (const std::string& test_case_name,
+                                            const ServerSelector& server_selector,
+                                            const std::string& expected_tag = ServerTag::ALL) {
         SCOPED_TRACE(test_case_name);
 
         // Test fetching subnet by id.
index 1c8c5bbfd788de66a3783432d11d983edff89d46..db635942aa87ce178a06bcf19c9cc86f12faafb3 100644 (file)
@@ -28,8 +28,7 @@ protected:
                              s_string(State::getInstance(State::String)),
                              s_qstring(State::getInstance(State::QString)),
                              s_number(State::getInstance(State::Number)),
-                             options(MasterLexer::NONE),
-                             orig_options(options)
+                             orig_options(MasterLexer::NONE)
     {}
 
     // Specify INITIAL_WS as common initial options.
@@ -41,7 +40,7 @@ protected:
     const State& s_qstring;
     const State& s_number;
     std::stringstream ss;
-    MasterLexer::Options options, orig_options;
+    MasterLexer::Options orig_options;
 };
 
 // Common check for the end-of-file condition.
@@ -390,42 +389,42 @@ TEST_F(MasterLexerStateTest, quotedString) {
 
     // If QSTRING is specified in option, '"' is regarded as a beginning of
     // a quoted string.
-    const MasterLexer::Options my_options = common_options | MasterLexer::QSTRING;
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    const MasterLexer::Options options = common_options | MasterLexer::QSTRING;
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     EXPECT_FALSE(s_string.wasLastEOL(lexer)); // EOL is canceled due to '"'
     s_qstring.handle(lexer);
     stringTokenCheck("quoted string", s_string.getToken(lexer), true);
 
     // Empty string is okay as qstring
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     stringTokenCheck("", s_string.getToken(lexer), true);
 
     // Also checks other separator characters within a qstring
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     stringTokenCheck("quoted()\t\rstring", s_string.getToken(lexer), true);
 
     // escape character mostly doesn't have any effect in the qstring
     // processing
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     stringTokenCheck("escape\\ in quote", s_string.getToken(lexer), true);
 
     // The only exception is the quotation mark itself.  Note that the escape
     // only works on the quotation mark immediately after it.
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     stringTokenCheck("escaped\"", s_string.getToken(lexer), true);
 
     // quoted '\' then '"'.  Unlike the previous case '"' shouldn't be
     // escaped.
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     stringTokenCheck("escaped backslash\\\\", s_string.getToken(lexer), true);
 
     // ';' has no meaning in a quoted string (not indicating a comment)
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     stringTokenCheck("no;comment", s_string.getToken(lexer), true);
 }
@@ -437,28 +436,28 @@ TEST_F(MasterLexerStateTest, brokenQuotedString) {
     lexer.pushSource(ss);
 
     // EOL is encountered without closing the quote
-    const MasterLexer::Options my_options = common_options | MasterLexer::QSTRING;
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    const MasterLexer::Options options = common_options | MasterLexer::QSTRING;
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     ASSERT_EQ(Token::ERROR, s_qstring.getToken(lexer).getType());
     EXPECT_EQ(Token::UNBALANCED_QUOTES,
               s_qstring.getToken(lexer).getErrorCode());
     // We can resume after the error from the '\n'
-    EXPECT_EQ(s_null, State::start(lexer, my_options));
+    EXPECT_EQ(s_null, State::start(lexer, options));
     EXPECT_EQ(Token::END_OF_LINE, s_crlf.getToken(lexer).getType());
 
     // \n is okay in a quoted string if escaped
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     stringTokenCheck("quoted\\\n", s_string.getToken(lexer), true);
 
     // EOF is encountered without closing the quote
-    EXPECT_EQ(&s_qstring, State::start(lexer, my_options));
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
     s_qstring.handle(lexer);
     ASSERT_EQ(Token::ERROR, s_qstring.getToken(lexer).getType());
     EXPECT_EQ(Token::UNEXPECTED_END, s_qstring.getToken(lexer).getErrorCode());
     // If we continue we'll simply see the EOF
-    EXPECT_EQ(s_null, State::start(lexer, my_options));
+    EXPECT_EQ(s_null, State::start(lexer, options));
     EXPECT_EQ(Token::END_OF_FILE, s_crlf.getToken(lexer).getType());
 }
 
@@ -478,52 +477,52 @@ TEST_F(MasterLexerStateTest, basicNumbers) {
     lexer.pushSource(ss);
 
     // Ask the lexer to recognize numbers as well
-    const MasterLexer::Options my_options = common_options | MasterLexer::NUMBER;
+    const MasterLexer::Options options = common_options | MasterLexer::NUMBER;
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(0, s_number.getToken(lexer).getNumber());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(1, s_number.getToken(lexer).getNumber());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(12345, s_number.getToken(lexer).getNumber());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(4294967295u, s_number.getToken(lexer).getNumber());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(Token::NUMBER_OUT_OF_RANGE,
               s_number.getToken(lexer).getErrorCode());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(Token::NUMBER_OUT_OF_RANGE,
               s_number.getToken(lexer).getErrorCode());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(5, s_number.getToken(lexer).getNumber());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(42, s_number.getToken(lexer).getNumber());
 
-    EXPECT_EQ(s_null, State::start(lexer, my_options));
+    EXPECT_EQ(s_null, State::start(lexer, options));
     EXPECT_TRUE(s_crlf.wasLastEOL(lexer));
     EXPECT_EQ(Token::END_OF_LINE, s_crlf.getToken(lexer).getType());
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     EXPECT_EQ(37, s_number.getToken(lexer).getNumber());
 
     // If we continue we'll simply see the EOF
-    EXPECT_EQ(s_null, State::start(lexer, my_options));
+    EXPECT_EQ(s_null, State::start(lexer, options));
     EXPECT_EQ(Token::END_OF_FILE, s_crlf.getToken(lexer).getType());
 }
 
@@ -554,52 +553,52 @@ TEST_F(MasterLexerStateTest, stringNumbers) {
     stringTokenCheck("123", s_string.getToken(lexer), false);
 
     // Ask the lexer to recognize numbers as well
-    const MasterLexer::Options my_options = common_options | MasterLexer::NUMBER;
+    const MasterLexer::Options options = common_options | MasterLexer::NUMBER;
 
-    EXPECT_EQ(&s_string, State::start(lexer, my_options));
+    EXPECT_EQ(&s_string, State::start(lexer, options));
     s_string.handle(lexer);
     stringTokenCheck("-1", s_string.getToken(lexer), false);
 
     // Starts out as a number, but ends up being a string
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     stringTokenCheck("123abc456", s_number.getToken(lexer), false);
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer);
     stringTokenCheck("123\\456", s_number.getToken(lexer), false);
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer); // recognize str, see ' ' at end
     stringTokenCheck("3scaped\\ space", s_number.getToken(lexer));
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer); // recognize str, see ' ' at end
     stringTokenCheck("3scaped\\\ttab", s_number.getToken(lexer));
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer); // recognize str, see ' ' at end
     stringTokenCheck("3scaped\\(paren", s_number.getToken(lexer));
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer); // recognize str, see ' ' at end
     stringTokenCheck("3scaped\\)close", s_number.getToken(lexer));
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer); // recognize str, see ' ' at end
     stringTokenCheck("3scaped\\;comment", s_number.getToken(lexer));
 
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer); // recognize str, see ' ' in mid
     stringTokenCheck("3scaped\\\\", s_number.getToken(lexer));
 
     // Confirm the word that follows the escaped '\' is correctly recognized.
-    EXPECT_EQ(&s_number, State::start(lexer, my_options));
+    EXPECT_EQ(&s_number, State::start(lexer, options));
     s_number.handle(lexer); // recognize str, see ' ' at end
     stringTokenCheck("8ackslash", s_number.getToken(lexer));
 
     // If we continue we'll simply see the EOF
-    EXPECT_EQ(s_null, State::start(lexer, my_options));
+    EXPECT_EQ(s_null, State::start(lexer, options));
     EXPECT_EQ(Token::END_OF_FILE, s_crlf.getToken(lexer).getType());
 }