From 789ca33732dc49532b02780602b717fdc60604ed Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 11 Mar 2026 14:35:06 +0100 Subject: [PATCH 1/3] 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 (cherry picked from commit 5f51784b337ac57f273f091a3207ce683e685340) # Conflicts: # ACE/ace/Configuration.cpp --- ACE/ace/Configuration.cpp | 40 +++++++++++++++++++++------------------ ACE/tests/Config_Test.cpp | 37 ++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/ACE/ace/Configuration.cpp b/ACE/ace/Configuration.cpp index d1086423d71ea..31b09fbba87ea 100644 --- a/ACE/ace/Configuration.cpp +++ b/ACE/ace/Configuration.cpp @@ -428,7 +428,7 @@ static const 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; } @@ -461,7 +461,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)); @@ -516,7 +516,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); @@ -589,14 +589,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) @@ -780,7 +780,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); @@ -876,7 +876,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); ACE_Auto_Basic_Array_Ptr safe_data (the_data); @@ -887,7 +887,7 @@ ACE_Configuration_Win32Registry::get_binary_value ( the_data, &buffer_length)) != ERROR_SUCCESS) { - data = 0; + data = nullptr; errno = errnum; return -1; } @@ -997,7 +997,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); @@ -1060,7 +1060,7 @@ ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void) : 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) @@ -1255,7 +1255,7 @@ ACE_Configuration_Heap::~ACE_Configuration_Heap (void) int ACE_Configuration_Heap::open (size_t default_map_size) { - if (this->allocator_ != 0) + if (this->allocator_) { errno = EBUSY; return -1; @@ -1277,7 +1277,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; @@ -1316,7 +1316,11 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* file_name, int ACE_Configuration_Heap::create_index (void) { +<<<<<<< HEAD void *section_index = 0; +======= + void* section_index {}; +>>>>>>> 5f51784b33 (Use HKEY_CURRENT_USER for testing) // 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 56d8b26b64cd5..8f78d1aa69b1e 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" @@ -97,10 +96,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, @@ -246,8 +245,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 @@ -260,7 +258,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; } @@ -304,8 +302,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; @@ -315,7 +312,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; @@ -527,25 +524,23 @@ run_tests (void) #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, @@ -554,7 +549,7 @@ run_tests (void) 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"), @@ -587,7 +582,7 @@ run_tests (void) -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"), @@ -596,7 +591,7 @@ run_tests (void) } { - 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"), @@ -644,7 +639,7 @@ run_tests (void) } { - 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"), @@ -750,7 +745,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 be3b10d8affd3860f74db849da27c9fc0a844a7c Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 11 Mar 2026 14:45:50 +0100 Subject: [PATCH 2/3] Update Config_Test.cpp (cherry picked from commit 15e17eb01885345477dc53b72468bf9c0a6c830a) --- 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 8f78d1aa69b1e..5a986a873bd27 100644 --- a/ACE/tests/Config_Test.cpp +++ b/ACE/tests/Config_Test.cpp @@ -307,7 +307,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; @@ -323,7 +323,7 @@ test_subkey_path (ACE_Configuration* config) return -27; if (config->remove_section (testsection, - ACE_TEXT ("ACE"), + ACE_TEXT ("ACETEST"), 1)) return -28; @@ -534,14 +534,14 @@ run_tests (void) } // 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")), @@ -745,7 +745,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, From c70300b4dcc66be4af5b0236db6ca5a3379d026c Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 11 Mar 2026 20:27:46 +0100 Subject: [PATCH 3/3] Fixed merge --- ACE/ace/Configuration.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ACE/ace/Configuration.cpp b/ACE/ace/Configuration.cpp index 31b09fbba87ea..63c7f4a56bffa 100644 --- a/ACE/ace/Configuration.cpp +++ b/ACE/ace/Configuration.cpp @@ -1316,11 +1316,7 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* file_name, int ACE_Configuration_Heap::create_index (void) { -<<<<<<< HEAD - void *section_index = 0; -======= void* section_index {}; ->>>>>>> 5f51784b33 (Use HKEY_CURRENT_USER for testing) // This is the easy case since if we find hash table in the // memory-mapped file we know it's already initialized.