Skip to content

Commit 019f4e7

Browse files
committed
[io] use UUIDv4 in TFile unconditionally
1 parent f20d779 commit 019f4e7

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

core/base/inc/TDirectory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ can be replaced with the simpler and exception safe:
140140

141141
TObject *fMother{nullptr}; ///< pointer to mother of the directory
142142
TList *fList{nullptr}; ///< List of objects in memory
143-
TUUID fUUID; ///< Unique identifier
143+
TUUID fUUID{TUUID::UUIDv4()}; ///< Unique identifier
144144
mutable TString fPathBuffer; ///<! Buffer for GetPath() function
145145
TContext *fContext{nullptr}; ///<! Pointer to a list of TContext object pointing to this TDirectory
146146

core/base/src/TDirectory.cxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ Describe directory structure in memory.
5252

5353
TDirectory::TDirectory() : TNamed()
5454
{
55-
// In the context of rootcling, we don't have gSystem
56-
if (gSystem)
57-
fUUID = TUUID::UUIDv4();
58-
5955
// MSVC doesn't support fSpinLock=ATOMIC_FLAG_INIT; in the class definition
6056
std::atomic_flag_clear( &fSpinLock );
6157
}
@@ -76,10 +72,6 @@ TDirectory::TDirectory() : TNamed()
7672
TDirectory::TDirectory(const char *name, const char *title, Option_t * /*classname*/, TDirectory* initMotherDir)
7773
: TNamed(name, title)
7874
{
79-
// In the context of rootcling, we don't have gSystem
80-
if (gSystem)
81-
fUUID = TUUID::UUIDv4();
82-
8375
// MSVC doesn't support fSpinLock=ATOMIC_FLAG_INIT; in the class definition
8476
std::atomic_flag_clear( &fSpinLock );
8577

core/base/src/TUUID.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ system clock tick, the UUID generator will stall until the
113113
system clock catches up.
114114
*/
115115

116+
#include <ROOT/RCryptoRandom.hxx>
117+
116118
#include "TROOT.h"
117119
#include "TDatime.h"
118120
#include "TUUID.h"
@@ -165,9 +167,8 @@ TUUID::TUUID(TV4Marker)
165167
// Ensure we can treat the memory starting at uuid.fTimeLow as an array of 16 octets
166168
assert(&fNode[5] - reinterpret_cast<unsigned char *>(&fTimeLow) + 1 == 16);
167169

168-
R__ASSERT(gSystem);
169-
const auto rv = gSystem->GetCryptoRandom(&fTimeLow, 16);
170-
R__ASSERT(rv == 16);
170+
const auto rv = ROOT::Internal::GetCryptoRandom(&fTimeLow, 16);
171+
R__ASSERT(rv);
171172
// Fix up variant
172173
fClockSeqHiAndReserved = (fClockSeqHiAndReserved & 0x3F) | (2 << 6);
173174
// Fix up version

0 commit comments

Comments
 (0)