From 5f51784b337ac57f273f091a3207ce683e685340 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 11 Mar 2026 14:35:06 +0100 Subject: [PATCH 1/2] Use HKEY_CURRENT_USER for testing Use HKEY_CURRENT_USER for testing as HKEY_LOCAL_MACHINE can't be changed when this test runs under a normal user. Also use const/addressof in various places --- ACE/ace/Configuration.cpp | 38 +++++++++++++++++++------------------- ACE/tests/Config_Test.cpp | 37 ++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/ACE/ace/Configuration.cpp b/ACE/ace/Configuration.cpp index 5467c825b7d8b..3c6c0640a71b1 100644 --- a/ACE/ace/Configuration.cpp +++ b/ACE/ace/Configuration.cpp @@ -408,7 +408,7 @@ static constexpr int ACE_DEFAULT_BUFSIZE = 256; static const ACE_TCHAR *temp_name (const ACE_TCHAR *name) { if (name && *name == ACE_Configuration::NULL_String_) - return 0; + return nullptr; return name; } @@ -441,7 +441,7 @@ ACE_Configuration_Win32Registry::operator!= (const ACE_Configuration_Win32Regist ACE_Configuration_Win32Registry::ACE_Configuration_Win32Registry (HKEY hKey, u_long security_access) : security_access_ (security_access) { - ACE_Section_Key_Win32 *temp = 0; + ACE_Section_Key_Win32* temp {}; ACE_NEW (temp, ACE_Section_Key_Win32 (hKey)); @@ -492,7 +492,7 @@ ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_K } } - ACE_Section_Key_Win32 *temp; + ACE_Section_Key_Win32* temp {}; ACE_NEW_RETURN (temp, ACE_Section_Key_Win32 (result_key), -1); result = ACE_Configuration_Section_Key (temp); @@ -565,14 +565,14 @@ ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Secti DWORD buffer_size = ACE_DEFAULT_BUFSIZE; DWORD value_type; - int rc = ACE_TEXT_RegEnumValue (base_key, - index, - name_buffer, - &buffer_size, - 0, - &value_type, - 0, - 0); + int const rc = ACE_TEXT_RegEnumValue (base_key, + index, + name_buffer, + &buffer_size, + 0, + &value_type, + 0, + 0); if (rc == ERROR_NO_MORE_ITEMS) return 1; else if (rc != ERROR_SUCCESS) @@ -756,7 +756,7 @@ ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Secti return -1; } - ACE_TCHAR *temp = 0; + ACE_TCHAR* temp {}; ACE_NEW_RETURN (temp, ACE_TCHAR[buffer_length], -1); @@ -852,7 +852,7 @@ ACE_Configuration_Win32Registry::get_binary_value ( length = buffer_length; - BYTE * the_data = 0; + BYTE* the_data {}; ACE_NEW_RETURN (the_data, BYTE[length], -1); std::unique_ptr safe_data (the_data); @@ -863,7 +863,7 @@ ACE_Configuration_Win32Registry::get_binary_value ( the_data, &buffer_length)) != ERROR_SUCCESS) { - data = 0; + data = nullptr; errno = errnum; return -1; } @@ -969,7 +969,7 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, } // recurse through the path - ACE_TCHAR *temp_path = 0; + ACE_TCHAR* temp_path {}; ACE_NEW_RETURN (temp_path, ACE_TCHAR[ACE_OS::strlen (path) + 1], 0); @@ -1024,7 +1024,7 @@ ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId () : type_ (ACE_Configuration::INVALID), length_ (0) { - this->data_.ptr_ = 0; + this->data_.ptr_ = nullptr; } ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (ACE_TCHAR* string) @@ -1201,7 +1201,7 @@ ACE_Configuration_Heap::~ACE_Configuration_Heap () int ACE_Configuration_Heap::open (size_t default_map_size) { - if (this->allocator_ != 0) + if (this->allocator_) { errno = EBUSY; return -1; @@ -1223,7 +1223,7 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* file_name, void* base_address, size_t default_map_size) { - if (this->allocator_ != 0) + if (this->allocator_) { errno = EBUSY; return -1; @@ -1262,7 +1262,7 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* file_name, int ACE_Configuration_Heap::create_index () { - void *section_index = nullptr; + void* section_index {}; // This is the easy case since if we find hash table in the // memory-mapped file we know it's already initialized. diff --git a/ACE/tests/Config_Test.cpp b/ACE/tests/Config_Test.cpp index e16932db307e5..469ba712bce06 100644 --- a/ACE/tests/Config_Test.cpp +++ b/ACE/tests/Config_Test.cpp @@ -12,7 +12,6 @@ */ //============================================================================= - #include "test_config.h" #include "Config_Test.h" #include "ace/Configuration_Import_Export.h" @@ -95,10 +94,10 @@ test (ACE_Configuration *config, else if (intvalue != 42) return -9; - u_char *data_out (0); + u_char* data_out {}; { - void *data_tmp = 0; // Workaround for GCC strict aliasing warning. + void* data_tmp {}; // Workaround for GCC strict aliasing warning. size_t length = 0; if (config->get_binary_value (testsection, @@ -244,8 +243,7 @@ test (ACE_Configuration *config, static int test (ACE_Configuration *config) { - const ACE_Configuration_Section_Key& root = - config->root_section (); + const ACE_Configuration_Section_Key& root = config->root_section (); { // Scope this so the testsection key is closed before trying to @@ -258,7 +256,7 @@ test (ACE_Configuration *config) testsection)) return -2; - int ret_val = test (config, testsection); + int const ret_val = test (config, testsection); if (ret_val) return ret_val; } @@ -302,8 +300,7 @@ test (ACE_Configuration *config) static int test_subkey_path (ACE_Configuration* config) { - ACE_Configuration_Section_Key root = - config->root_section (); + ACE_Configuration_Section_Key root = config->root_section (); ACE_Configuration_Section_Key testsection; @@ -313,7 +310,7 @@ test_subkey_path (ACE_Configuration* config) testsection)) return -26; - int ret_val = test (config, testsection); + int const ret_val = test (config, testsection); if (ret_val) return ret_val; @@ -525,25 +522,23 @@ run_tests () #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) { - ACE_Configuration_Win32Registry RegConfig (HKEY_LOCAL_MACHINE); - int result = test_subkey_path (&RegConfig); + ACE_Configuration_Win32Registry RegConfig (HKEY_CURRENT_USER); + int const result = test_subkey_path (std::addressof (RegConfig)); if (result) ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Win32Registry test HKEY_LOCAL_MACHINE") + ACE_TEXT ("Win32Registry test HKEY_CURRENT_USER") ACE_TEXT (" failed (%d)\n"), result), -1); } // test win32 registry implementation. - HKEY root = - ACE_Configuration_Win32Registry::resolve_key (HKEY_LOCAL_MACHINE, + HKEY const root = ACE_Configuration_Win32Registry::resolve_key (HKEY_CURRENT_USER, ACE_TEXT ("Software\\ACE\\test")); if (!root) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("resolve_key is broken\n")), -2); // test resolving of forward slashes - HKEY root_fs = - ACE_Configuration_Win32Registry::resolve_key (HKEY_LOCAL_MACHINE, + HKEY const root_fs = ACE_Configuration_Win32Registry::resolve_key (HKEY_CURRENT_USER, ACE_TEXT ("Software/ACE/test"), 0); if (!root_fs) ACE_ERROR_RETURN ((LM_ERROR, @@ -552,7 +547,7 @@ run_tests () ACE_Configuration_Win32Registry RegConfig (root); { - int const result = test (&RegConfig); + int const result = test (std::addressof (RegConfig)); if (result) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Win32 registry test root failed (%d)\n"), @@ -585,7 +580,7 @@ run_tests () -1); } { - int result = test_subkey_path (&heap_config); + int const result = test_subkey_path (std::addressof(heap_config)); if (result) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Heap Config subkey test failed (%d)\n"), @@ -594,7 +589,7 @@ run_tests () } { - int result = test (&heap_config); + int const result = test (std::addressof(heap_config)); if (result) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Heap Configuration test failed (%d)\n"), @@ -642,7 +637,7 @@ run_tests () } { - int result = test (&pers_config); + int const result = test (std::addressof(pers_config)); if (result) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Persistent Heap Config test failed (%d)\n"), @@ -748,7 +743,7 @@ build_config_object (ACE_Configuration& cfg) -16); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("here\n"))); - //return 0; + //ACE_TString string; ACE_TString name ((ACE_TCHAR*)0); if (cfg.get_string_value (LoggerSection, From 15e17eb01885345477dc53b72468bf9c0a6c830a Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 11 Mar 2026 14:45:50 +0100 Subject: [PATCH 2/2] Update Config_Test.cpp --- ACE/tests/Config_Test.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ACE/tests/Config_Test.cpp b/ACE/tests/Config_Test.cpp index 469ba712bce06..372bb460731cc 100644 --- a/ACE/tests/Config_Test.cpp +++ b/ACE/tests/Config_Test.cpp @@ -305,7 +305,7 @@ test_subkey_path (ACE_Configuration* config) ACE_Configuration_Section_Key testsection; if (config->open_section (root, - ACE_TEXT ("Software\\ACE\\test"), + ACE_TEXT ("Software\\ACETEST\\test"), 1, testsection)) return -26; @@ -321,7 +321,7 @@ test_subkey_path (ACE_Configuration* config) return -27; if (config->remove_section (testsection, - ACE_TEXT ("ACE"), + ACE_TEXT ("ACETEST"), 1)) return -28; @@ -532,14 +532,14 @@ run_tests () } // test win32 registry implementation. HKEY const root = ACE_Configuration_Win32Registry::resolve_key (HKEY_CURRENT_USER, - ACE_TEXT ("Software\\ACE\\test")); + ACE_TEXT ("Software\\ACETEST\\test")); if (!root) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("resolve_key is broken\n")), -2); // test resolving of forward slashes HKEY const root_fs = ACE_Configuration_Win32Registry::resolve_key (HKEY_CURRENT_USER, - ACE_TEXT ("Software/ACE/test"), 0); + ACE_TEXT ("Software/ACETEST/test"), 0); if (!root_fs) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("resolve_key resolving slashes is broken\n")), @@ -743,7 +743,7 @@ build_config_object (ACE_Configuration& cfg) -16); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("here\n"))); - + //ACE_TString string; ACE_TString name ((ACE_TCHAR*)0); if (cfg.get_string_value (LoggerSection,