Skip to content

Commit 7dd3780

Browse files
authored
Merge pull request #2513 from DOCGroup/jwi-configtest
Use HKEY_CURRENT_USER for testing
2 parents 86b3dfc + 15e17eb commit 7dd3780

2 files changed

Lines changed: 39 additions & 44 deletions

File tree

ACE/ace/Configuration.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static constexpr int ACE_DEFAULT_BUFSIZE = 256;
408408
static const ACE_TCHAR *temp_name (const ACE_TCHAR *name)
409409
{
410410
if (name && *name == ACE_Configuration::NULL_String_)
411-
return 0;
411+
return nullptr;
412412
return name;
413413
}
414414

@@ -441,7 +441,7 @@ ACE_Configuration_Win32Registry::operator!= (const ACE_Configuration_Win32Regist
441441
ACE_Configuration_Win32Registry::ACE_Configuration_Win32Registry (HKEY hKey, u_long security_access)
442442
: security_access_ (security_access)
443443
{
444-
ACE_Section_Key_Win32 *temp = 0;
444+
ACE_Section_Key_Win32* temp {};
445445

446446
ACE_NEW (temp, ACE_Section_Key_Win32 (hKey));
447447

@@ -492,7 +492,7 @@ ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_K
492492
}
493493
}
494494

495-
ACE_Section_Key_Win32 *temp;
495+
ACE_Section_Key_Win32* temp {};
496496

497497
ACE_NEW_RETURN (temp, ACE_Section_Key_Win32 (result_key), -1);
498498
result = ACE_Configuration_Section_Key (temp);
@@ -565,14 +565,14 @@ ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Secti
565565
DWORD buffer_size = ACE_DEFAULT_BUFSIZE;
566566
DWORD value_type;
567567

568-
int rc = ACE_TEXT_RegEnumValue (base_key,
569-
index,
570-
name_buffer,
571-
&buffer_size,
572-
0,
573-
&value_type,
574-
0,
575-
0);
568+
int const rc = ACE_TEXT_RegEnumValue (base_key,
569+
index,
570+
name_buffer,
571+
&buffer_size,
572+
0,
573+
&value_type,
574+
0,
575+
0);
576576
if (rc == ERROR_NO_MORE_ITEMS)
577577
return 1;
578578
else if (rc != ERROR_SUCCESS)
@@ -756,7 +756,7 @@ ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Secti
756756
return -1;
757757
}
758758

759-
ACE_TCHAR *temp = 0;
759+
ACE_TCHAR* temp {};
760760
ACE_NEW_RETURN (temp,
761761
ACE_TCHAR[buffer_length],
762762
-1);
@@ -852,7 +852,7 @@ ACE_Configuration_Win32Registry::get_binary_value (
852852

853853
length = buffer_length;
854854

855-
BYTE * the_data = 0;
855+
BYTE* the_data {};
856856
ACE_NEW_RETURN (the_data, BYTE[length], -1);
857857
std::unique_ptr<BYTE[]> safe_data (the_data);
858858

@@ -863,7 +863,7 @@ ACE_Configuration_Win32Registry::get_binary_value (
863863
the_data,
864864
&buffer_length)) != ERROR_SUCCESS)
865865
{
866-
data = 0;
866+
data = nullptr;
867867
errno = errnum;
868868
return -1;
869869
}
@@ -969,7 +969,7 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey,
969969
}
970970

971971
// recurse through the path
972-
ACE_TCHAR *temp_path = 0;
972+
ACE_TCHAR* temp_path {};
973973
ACE_NEW_RETURN (temp_path,
974974
ACE_TCHAR[ACE_OS::strlen (path) + 1],
975975
0);
@@ -1024,7 +1024,7 @@ ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId ()
10241024
: type_ (ACE_Configuration::INVALID),
10251025
length_ (0)
10261026
{
1027-
this->data_.ptr_ = 0;
1027+
this->data_.ptr_ = nullptr;
10281028
}
10291029

10301030
ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (ACE_TCHAR* string)
@@ -1201,7 +1201,7 @@ ACE_Configuration_Heap::~ACE_Configuration_Heap ()
12011201
int
12021202
ACE_Configuration_Heap::open (size_t default_map_size)
12031203
{
1204-
if (this->allocator_ != 0)
1204+
if (this->allocator_)
12051205
{
12061206
errno = EBUSY;
12071207
return -1;
@@ -1223,7 +1223,7 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* file_name,
12231223
void* base_address,
12241224
size_t default_map_size)
12251225
{
1226-
if (this->allocator_ != 0)
1226+
if (this->allocator_)
12271227
{
12281228
errno = EBUSY;
12291229
return -1;
@@ -1262,7 +1262,7 @@ ACE_Configuration_Heap::open (const ACE_TCHAR* file_name,
12621262
int
12631263
ACE_Configuration_Heap::create_index ()
12641264
{
1265-
void *section_index = nullptr;
1265+
void* section_index {};
12661266

12671267
// This is the easy case since if we find hash table in the
12681268
// memory-mapped file we know it's already initialized.

ACE/tests/Config_Test.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
//=============================================================================
1414

15-
1615
#include "test_config.h"
1716
#include "Config_Test.h"
1817
#include "ace/Configuration_Import_Export.h"
@@ -95,10 +94,10 @@ test (ACE_Configuration *config,
9594
else if (intvalue != 42)
9695
return -9;
9796

98-
u_char *data_out (0);
97+
u_char* data_out {};
9998

10099
{
101-
void *data_tmp = 0; // Workaround for GCC strict aliasing warning.
100+
void* data_tmp {}; // Workaround for GCC strict aliasing warning.
102101
size_t length = 0;
103102

104103
if (config->get_binary_value (testsection,
@@ -244,8 +243,7 @@ test (ACE_Configuration *config,
244243
static int
245244
test (ACE_Configuration *config)
246245
{
247-
const ACE_Configuration_Section_Key& root =
248-
config->root_section ();
246+
const ACE_Configuration_Section_Key& root = config->root_section ();
249247

250248
{
251249
// Scope this so the testsection key is closed before trying to
@@ -258,7 +256,7 @@ test (ACE_Configuration *config)
258256
testsection))
259257
return -2;
260258

261-
int ret_val = test (config, testsection);
259+
int const ret_val = test (config, testsection);
262260
if (ret_val)
263261
return ret_val;
264262
}
@@ -302,18 +300,17 @@ test (ACE_Configuration *config)
302300
static int
303301
test_subkey_path (ACE_Configuration* config)
304302
{
305-
ACE_Configuration_Section_Key root =
306-
config->root_section ();
303+
ACE_Configuration_Section_Key root = config->root_section ();
307304

308305
ACE_Configuration_Section_Key testsection;
309306

310307
if (config->open_section (root,
311-
ACE_TEXT ("Software\\ACE\\test"),
308+
ACE_TEXT ("Software\\ACETEST\\test"),
312309
1,
313310
testsection))
314311
return -26;
315312

316-
int ret_val = test (config, testsection);
313+
int const ret_val = test (config, testsection);
317314
if (ret_val)
318315
return ret_val;
319316

@@ -324,7 +321,7 @@ test_subkey_path (ACE_Configuration* config)
324321
return -27;
325322

326323
if (config->remove_section (testsection,
327-
ACE_TEXT ("ACE"),
324+
ACE_TEXT ("ACETEST"),
328325
1))
329326
return -28;
330327

@@ -525,34 +522,32 @@ run_tests ()
525522

526523
#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY)
527524
{
528-
ACE_Configuration_Win32Registry RegConfig (HKEY_LOCAL_MACHINE);
529-
int result = test_subkey_path (&RegConfig);
525+
ACE_Configuration_Win32Registry RegConfig (HKEY_CURRENT_USER);
526+
int const result = test_subkey_path (std::addressof (RegConfig));
530527
if (result)
531528
ACE_ERROR_RETURN ((LM_ERROR,
532-
ACE_TEXT ("Win32Registry test HKEY_LOCAL_MACHINE")
529+
ACE_TEXT ("Win32Registry test HKEY_CURRENT_USER")
533530
ACE_TEXT (" failed (%d)\n"), result),
534531
-1);
535532
}
536533
// test win32 registry implementation.
537-
HKEY root =
538-
ACE_Configuration_Win32Registry::resolve_key (HKEY_LOCAL_MACHINE,
539-
ACE_TEXT ("Software\\ACE\\test"));
534+
HKEY const root = ACE_Configuration_Win32Registry::resolve_key (HKEY_CURRENT_USER,
535+
ACE_TEXT ("Software\\ACETEST\\test"));
540536
if (!root)
541537
ACE_ERROR_RETURN ((LM_ERROR,
542538
ACE_TEXT ("resolve_key is broken\n")), -2);
543539

544540
// test resolving of forward slashes
545-
HKEY root_fs =
546-
ACE_Configuration_Win32Registry::resolve_key (HKEY_LOCAL_MACHINE,
547-
ACE_TEXT ("Software/ACE/test"), 0);
541+
HKEY const root_fs = ACE_Configuration_Win32Registry::resolve_key (HKEY_CURRENT_USER,
542+
ACE_TEXT ("Software/ACETEST/test"), 0);
548543
if (!root_fs)
549544
ACE_ERROR_RETURN ((LM_ERROR,
550545
ACE_TEXT ("resolve_key resolving slashes is broken\n")),
551546
-2);
552547

553548
ACE_Configuration_Win32Registry RegConfig (root);
554549
{
555-
int const result = test (&RegConfig);
550+
int const result = test (std::addressof (RegConfig));
556551
if (result)
557552
ACE_ERROR_RETURN ((LM_ERROR,
558553
ACE_TEXT ("Win32 registry test root failed (%d)\n"),
@@ -585,7 +580,7 @@ run_tests ()
585580
-1);
586581
}
587582
{
588-
int result = test_subkey_path (&heap_config);
583+
int const result = test_subkey_path (std::addressof(heap_config));
589584
if (result)
590585
ACE_ERROR_RETURN ((LM_ERROR,
591586
ACE_TEXT ("Heap Config subkey test failed (%d)\n"),
@@ -594,7 +589,7 @@ run_tests ()
594589
}
595590

596591
{
597-
int result = test (&heap_config);
592+
int const result = test (std::addressof(heap_config));
598593
if (result)
599594
ACE_ERROR_RETURN ((LM_ERROR,
600595
ACE_TEXT ("Heap Configuration test failed (%d)\n"),
@@ -642,7 +637,7 @@ run_tests ()
642637
}
643638

644639
{
645-
int result = test (&pers_config);
640+
int const result = test (std::addressof(pers_config));
646641
if (result)
647642
ACE_ERROR_RETURN ((LM_ERROR,
648643
ACE_TEXT ("Persistent Heap Config test failed (%d)\n"),
@@ -748,7 +743,7 @@ build_config_object (ACE_Configuration& cfg)
748743
-16);
749744

750745
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("here\n")));
751-
//return 0;
746+
752747
//ACE_TString string;
753748
ACE_TString name ((ACE_TCHAR*)0);
754749
if (cfg.get_string_value (LoggerSection,

0 commit comments

Comments
 (0)