]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#889] addressed review
authorRazvan Becheriu <razvan@isc.org>
Wed, 15 Jan 2020 12:46:43 +0000 (14:46 +0200)
committerRazvan Becheriu <razvan@isc.org>
Wed, 15 Jan 2020 12:46:43 +0000 (14:46 +0200)
src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/libdhcp++.h

index f7b0ee5ebc2a807a5fba8539fffd201eedc0f295..6be24dbc54e4096fcaa22bec83e88ce82983a0e0 100644 (file)
@@ -88,21 +88,15 @@ void initOptionSpace(OptionDefContainerPtr& defs,
                      const OptionDefParams* params,
                      size_t params_size);
 
-bool initialized = LibDHCP::initOptionDefs();
+bool LibDHCP::initialized_ = LibDHCP::initOptionDefs();
 
 const OptionDefContainerPtr
 LibDHCP::getOptionDefs(const std::string& space) {
-    // If any of the containers is not initialized, it means that we haven't
-    // initialized option definitions at all.
-    if (option_defs_.end() == option_defs_.find(space)) {
-        isc_throw(isc::Unexpected, "option definitions should have been "
-                  "automatically initialized at process startup");
-    }
-
     OptionDefContainers::const_iterator container = option_defs_.find(space);
     if (container != option_defs_.end()) {
         return (container->second);
     }
+
     return (null_option_def_container_);
 }
 
@@ -119,6 +113,7 @@ LibDHCP::getVendorOptionDefs(const Option::Universe u, const uint32_t vendor_id)
             return getOptionDefs(ISC_V6_OPTION_SPACE);
         }
     }
+
     return (null_option_def_container_);
 }
 
@@ -130,6 +125,7 @@ LibDHCP::getOptionDef(const std::string& space, const uint16_t code) {
     if (range.first != range.second) {
         return (*range.first);
     }
+
     return (OptionDefinitionPtr());
 }
 
@@ -141,6 +137,7 @@ LibDHCP::getOptionDef(const std::string& space, const std::string& name) {
     if (range.first != range.second) {
         return (*range.first);
     }
+
     return (OptionDefinitionPtr());
 }
 
@@ -158,6 +155,7 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
     if (range.first != range.second) {
         return (*range.first);
     }
+
     return (OptionDefinitionPtr());
 }
 
@@ -178,6 +176,7 @@ LibDHCP::getVendorOptionDef(const Option::Universe u, const uint32_t vendor_id,
     if (range.first != range.second) {
         return (*range.first);
     }
+
     return (OptionDefinitionPtr());
 }
 
@@ -270,6 +269,7 @@ LibDHCP::getLastResortOptionDefs(const std::string& space) {
     if (space == DHCP4_OPTION_SPACE) {
         return getOptionDefs(LAST_RESORT_V4_OPTION_SPACE);
     }
+
     return (null_option_def_container_);
 }
 
@@ -907,7 +907,8 @@ LibDHCP::initOptionDefs() {
                         OPTION_DEF_PARAMS[i].optionDefParams,
                         OPTION_DEF_PARAMS[i].size);
     }
-    return true;
+
+    return (true);
 }
 
 uint32_t
index b613fe9d866a4ba722bc4a632b01b727ec2bc64b..1b22fb547ee0ae761ac26e53f685e5d9c67a6577 100644 (file)
@@ -363,6 +363,8 @@ public:
     /// @return vendor id.
     static uint32_t optionSpaceToVendorId(const std::string& option_space);
 
+private:
+
     /// Initialize DHCP option definitions.
     ///
     /// The method creates option definitions for all DHCP options.
@@ -372,7 +374,8 @@ public:
     /// are incorrect. This is programming error.
     static bool initOptionDefs();
 
-private:
+    /// flag which indicates initialization state
+    static bool initialized_;
 
     /// pointers to factories that produce DHCPv6 options
     static FactoryMap v4factories_;