diff --git a/core/base/inc/TBuffer.h b/core/base/inc/TBuffer.h index e383bb738d672..edafce36448f7 100644 --- a/core/base/inc/TBuffer.h +++ b/core/base/inc/TBuffer.h @@ -64,9 +64,9 @@ class TBuffer : public TObject { void operator=(const TBuffer &) = delete; Int_t Read(const char *name) override { return TObject::Read(name); } - Int_t Write(const char *name, Int_t opt, Int_t bufsize) override + Int_t Write(const char *name, Int_t opt, Long64_t bufsize) override { return TObject::Write(name, opt, bufsize); } - Int_t Write(const char *name, Int_t opt, Int_t bufsize) const override + Int_t Write(const char *name, Int_t opt, Long64_t bufsize) const override { return TObject::Write(name, opt, bufsize); } public: @@ -78,8 +78,8 @@ class TBuffer : public TObject { enum { kInitialSize = 1024, kMinimalSize = 128 }; TBuffer(EMode mode); - TBuffer(EMode mode, Int_t bufsize); - TBuffer(EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); + TBuffer(EMode mode, Long64_t bufsize); + TBuffer(EMode mode, Long64_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); virtual ~TBuffer(); Int_t GetBufferVersion() const { return fVersion; } @@ -87,10 +87,10 @@ class TBuffer : public TObject { Bool_t IsWriting() const { return (fMode & kWrite) != 0; } void SetReadMode(); void SetWriteMode(); - void SetBuffer(void *buf, UInt_t bufsize = 0, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); + void SetBuffer(void *buf, Long64_t bufsize = 0, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); ReAllocCharFun_t GetReAllocFunc() const; void SetReAllocFunc(ReAllocCharFun_t reallocfunc = nullptr); - void SetBufferOffset(Int_t offset = 0) { fBufCur = fBuffer+offset; } + void SetBufferOffset(Long64_t offset = 0) { fBufCur = fBuffer+offset; } void SetParent(TObject *parent); TObject *GetParent() const; char *Buffer() const { return fBuffer; } @@ -98,33 +98,33 @@ class TBuffer : public TObject { Int_t BufferSize() const { return fBufSize; } void DetachBuffer() { fBuffer = nullptr; } Int_t Length() const { return (Int_t)(fBufCur - fBuffer); } - void Expand(Int_t newsize, Bool_t copy = kTRUE); // expand buffer to newsize - void AutoExpand(Int_t size_needed); // expand buffer to newsize + void Expand(Long64_t newsize, Bool_t copy = kTRUE); // expand buffer to newsize + void AutoExpand(Long64_t size_needed); // expand buffer to newsize Bool_t ByteSwapBuffer(Long64_t n, EDataType type); // Byte-swap N primitive-elements in the buffer virtual Bool_t CheckObject(const TObject *obj) = 0; virtual Bool_t CheckObject(const void *obj, const TClass *ptrClass) = 0; - virtual Int_t ReadBuf(void *buf, Int_t max) = 0; - virtual void WriteBuf(const void *buf, Int_t max) = 0; + virtual Long64_t ReadBuf(void *buf, Long64_t max) = 0; + virtual void WriteBuf(const void *buf, Long64_t max) = 0; - virtual char *ReadString(char *s, Int_t max) = 0; + virtual char *ReadString(char *s, Long64_t max) = 0; virtual void WriteString(const char *s) = 0; virtual Int_t GetVersionOwner() const = 0; virtual Int_t GetMapCount() const = 0; virtual void GetMappedObject(UInt_t tag, void* &ptr, TClass* &ClassPtr) const = 0; - virtual void MapObject(const TObject *obj, UInt_t offset = 1) = 0; - virtual void MapObject(const void *obj, const TClass *cl, UInt_t offset = 1) = 0; + virtual void MapObject(const TObject *obj, ULong64_t offset = 1) = 0; + virtual void MapObject(const void *obj, const TClass *cl, ULong64_t offset = 1) = 0; virtual void Reset() = 0; virtual void InitMap() = 0; virtual void ResetMap() = 0; virtual void SetReadParam(Int_t mapsize) = 0; virtual void SetWriteParam(Int_t mapsize) = 0; - virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) = 0; - virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname) = 0; - virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion = kFALSE)= 0; + virtual Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss) = 0; + virtual Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const char *classname) = 0; + virtual void SetByteCount(ULong64_t cntpos, Bool_t packInVersion = kFALSE)= 0; virtual void SkipVersion(const TClass *cl = nullptr) = 0; virtual Version_t ReadVersion(UInt_t *start = nullptr, UInt_t *bcnt = nullptr, const TClass *cl = nullptr) = 0; @@ -164,7 +164,7 @@ class TBuffer : public TObject { virtual void SetPidOffset(UShort_t offset) = 0; virtual Int_t GetBufferDisplacement() const = 0; virtual void SetBufferDisplacement() = 0; - virtual void SetBufferDisplacement(Int_t skipped) = 0; + virtual void SetBufferDisplacement(Long64_t skipped) = 0; // basic types and arrays of basic types virtual void ReadFloat16 (Float_t *f, TStreamerElement *ele = nullptr) = 0; @@ -320,8 +320,8 @@ class TBuffer : public TObject { // Utilities for TStreamerInfo virtual void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) = 0; virtual void ForceWriteInfoClones(TClonesArray *a) = 0; - virtual Int_t ReadClones (TClonesArray *a, Int_t nobjects, Version_t objvers) = 0; - virtual Int_t WriteClones(TClonesArray *a, Int_t nobjects) = 0; + virtual Int_t ReadClones (TClonesArray *a, Long64_t nobjects, Version_t objvers) = 0; + virtual Int_t WriteClones(TClonesArray *a, Long64_t nobjects) = 0; // Utilities for TClass virtual Int_t ReadClassEmulated(const TClass *cl, void *object, const TClass *onfile_class = nullptr) = 0; diff --git a/core/base/inc/TDirectory.h b/core/base/inc/TDirectory.h index 9a7e5af175a5c..566eac06e3982 100644 --- a/core/base/inc/TDirectory.h +++ b/core/base/inc/TDirectory.h @@ -254,7 +254,7 @@ can be replaced with the simpler and exception safe: virtual void Save() {} virtual Int_t SaveObjectAs(const TObject * /*obj*/, const char * /*filename*/="", Option_t * /*option*/="") const; virtual void SaveSelf(Bool_t /*force*/ = kFALSE) {} - virtual void SetBufferSize(Int_t /* bufsize */) {} + virtual void SetBufferSize(Long64_t /* bufsize */) {} virtual void SetModified() {} virtual void SetMother(TObject *mother) {fMother = (TObject*)mother;} void SetName(const char* newname) override; @@ -262,12 +262,12 @@ can be replaced with the simpler and exception safe: virtual void SetSeekDir(Long64_t) {} virtual void SetWritable(Bool_t) {} Int_t Sizeof() const override {return 0;} - virtual Int_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Int_t /*bufsize*/=0) override {return 0;} - virtual Int_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Int_t /*bufsize*/=0) const override {return 0;} - virtual Int_t WriteTObject(const TObject *obj, const char *name =nullptr, Option_t * /*option*/="", Int_t /*bufsize*/ =0); + virtual Int_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Long64_t /*bufsize*/=0) override {return 0;} + virtual Int_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Long64_t /*bufsize*/=0) const override {return 0;} + virtual Int_t WriteTObject(const TObject *obj, const char *name =nullptr, Option_t * /*option*/="", Long64_t /*bufsize*/ =0); private: /// \cond HIDDEN_SYMBOLS - Int_t WriteObject(void *obj, const char* name, Option_t *option="", Int_t bufsize=0); // Intentionally not implemented. + Int_t WriteObject(void *obj, const char* name, Option_t *option="", Long64_t bufsize=0); // Intentionally not implemented. /// \endcond public: /// \brief Write an object with proper type checking. @@ -280,7 +280,7 @@ can be replaced with the simpler and exception safe: /// from TObject. The method redirects to TDirectory::WriteObjectAny. template inline std::enable_if_t::value, Int_t> - WriteObject(const T *obj, const char *name, Option_t *option = "", Int_t bufsize = 0) + WriteObject(const T *obj, const char *name, Option_t *option = "", Long64_t bufsize = 0) { return WriteObjectAny(obj, TClass::GetClass(), name, option, bufsize); } @@ -294,12 +294,12 @@ can be replaced with the simpler and exception safe: /// TObject. The method redirects to TDirectory::WriteTObject. template inline std::enable_if_t::value, Int_t> - WriteObject(const T *obj, const char *name, Option_t *option = "", Int_t bufsize = 0) + WriteObject(const T *obj, const char *name, Option_t *option = "", Long64_t bufsize = 0) { return WriteTObject(obj, name, option, bufsize); } - virtual Int_t WriteObjectAny(const void *, const char * /*classname*/, const char * /*name*/, Option_t * /*option*/="", Int_t /*bufsize*/ =0) {return 0;} - virtual Int_t WriteObjectAny(const void *, const TClass * /*cl*/, const char * /*name*/, Option_t * /*option*/="", Int_t /*bufsize*/ =0) {return 0;} + virtual Int_t WriteObjectAny(const void *, const char * /*classname*/, const char * /*name*/, Option_t * /*option*/="", Long64_t /*bufsize*/ =0) {return 0;} + virtual Int_t WriteObjectAny(const void *, const TClass * /*cl*/, const char * /*name*/, Option_t * /*option*/="", Long64_t /*bufsize*/ =0) {return 0;} virtual void WriteDirHeader() {} virtual void WriteKeys() {} diff --git a/core/base/inc/TObject.h b/core/base/inc/TObject.h index 5456204156b2d..cf4596809273d 100644 --- a/core/base/inc/TObject.h +++ b/core/base/inc/TObject.h @@ -170,8 +170,8 @@ class TObject { virtual void SetDrawOption(Option_t *option=""); // *MENU* virtual void SetUniqueID(UInt_t uid); virtual void UseCurrentStyle(); - virtual Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0); - virtual Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0) const; + virtual Int_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0); + virtual Int_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const; /// IsDestructed /// diff --git a/core/base/src/TBuffer.cxx b/core/base/src/TBuffer.cxx index 8a0c2b78e99e6..0a27db1c284c4 100644 --- a/core/base/src/TBuffer.cxx +++ b/core/base/src/TBuffer.cxx @@ -69,10 +69,10 @@ TBuffer::TBuffer(EMode mode) /// Create an I/O buffer object. Mode should be either TBuffer::kRead or /// TBuffer::kWrite. -TBuffer::TBuffer(EMode mode, Int_t bufsize) +TBuffer::TBuffer(EMode mode, Long64_t bufsize) { - if (bufsize < 0) - Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize); + if (bufsize > kMaxBufferSize) + Fatal("TBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", bufsize, kMaxBufferSize); if (bufsize < kMinimalSize) bufsize = kMinimalSize; fBufSize = bufsize; fMode = mode; @@ -100,10 +100,10 @@ TBuffer::TBuffer(EMode mode, Int_t bufsize) /// is provided, a Fatal error will be issued if the Buffer attempts to /// expand. -TBuffer::TBuffer(EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) +TBuffer::TBuffer(EMode mode, Long64_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) { - if (bufsize < 0) - Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize); + if (bufsize > kMaxBufferSize) + Fatal("TBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", bufsize, kMaxBufferSize); fBufSize = bufsize; fMode = mode; fVersion = 0; @@ -154,10 +154,10 @@ TBuffer::~TBuffer() /// If the size_needed is larger than the current size, the policy /// is to expand to double the current size or the size_needed which ever is largest. -void TBuffer::AutoExpand(Int_t size_needed) +void TBuffer::AutoExpand(Long64_t size_needed) { - if (size_needed < 0) { - Fatal("AutoExpand","Request to expand to a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", size_needed, kMaxBufferSize); + if (size_needed > kMaxBufferSize) { + Fatal("AutoExpand","Request to expand a too large buffer: 0x%llx for a max of 0x%x.", size_needed, kMaxBufferSize); } if (size_needed > fBufSize) { Long64_t doubling = 2LLU * fBufSize; @@ -183,8 +183,10 @@ void TBuffer::AutoExpand(Int_t size_needed) /// is provided, a Fatal error will be issued if the Buffer attempts to /// expand. -void TBuffer::SetBuffer(void *buf, UInt_t newsiz, Bool_t adopt, ReAllocCharFun_t reallocfunc) +void TBuffer::SetBuffer(void *buf, Long64_t newsiz, Bool_t adopt, ReAllocCharFun_t reallocfunc) { + if (newsiz > kMaxBufferSize) + Fatal("SetBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", newsiz, kMaxBufferSize); if (fBuffer && TestBit(kIsOwner)) delete [] fBuffer; @@ -219,19 +221,19 @@ void TBuffer::SetBuffer(void *buf, UInt_t newsiz, Bool_t adopt, ReAllocCharFun_t /// In order to avoid losing data, if the current length is greater than /// the requested size, we only shrink down to the current length. -void TBuffer::Expand(Int_t newsize, Bool_t copy) +void TBuffer::Expand(Long64_t newsize, Bool_t copy) { Int_t l = Length(); - if ( (l > newsize) && copy ) { + if ( (Long64_t(l) > newsize) && copy ) { newsize = l; } const Int_t extraspace = (fMode&kWrite)!=0 ? kExtraSpace : 0; - if ( ((Long64_t)newsize+extraspace) > kMaxBufferSize) { + if ( newsize > kMaxBufferSize - kExtraSpace) { if (l < kMaxBufferSize) { newsize = kMaxBufferSize - extraspace; } else { - Fatal("Expand","Requested size (%d) is too large (max is %d).", newsize, kMaxBufferSize); + Fatal("Expand","Requested size (%lld) is too large (max is %d).", newsize, kMaxBufferSize); } } if ( (fMode&kWrite)!=0 ) { diff --git a/core/base/src/TDirectory.cxx b/core/base/src/TDirectory.cxx index 9bebee0e74a1d..cc49cb16917da 100644 --- a/core/base/src/TDirectory.cxx +++ b/core/base/src/TDirectory.cxx @@ -342,11 +342,12 @@ static TBuffer* R__CreateBuffer() if (!creator) { R__LOCKGUARD(gROOTMutex); TClass *c = TClass::GetClass("TBufferFile"); - TMethod *m = c->GetMethodWithPrototype("TBufferFile","TBuffer::EMode,Int_t",kFALSE,ROOT::kExactMatch); + TMethod *m = c->GetMethodWithPrototype("TBufferFile","TBuffer::EMode,Long64_t",kFALSE,ROOT::kExactMatch); + assert(m != nullptr); creator = (tcling_callfunc_Wrapper_t)( m->InterfaceMethod() ); } TBuffer::EMode mode = TBuffer::kWrite; - Int_t size = 10000; + Long64_t size = 10000; void *args[] = { &mode, &size }; TBuffer *result; creator(nullptr,2,args,&result); @@ -1423,9 +1424,9 @@ void TDirectory::RegisterGDirectory(TDirectory::SharedGDirectory_t &gdirectory_p } //////////////////////////////////////////////////////////////////////////////// -/// \copydoc TDirectoryFile::WriteObject(const T*,const char*,Option_t*,Int_t). +/// \copydoc TDirectoryFile::WriteObject(const T*,const char*,Option_t*,Long64_t). -Int_t TDirectory::WriteTObject(const TObject *obj, const char *name, Option_t * /*option*/, Int_t /*bufsize*/) +Int_t TDirectory::WriteTObject(const TObject *obj, const char *name, Option_t * /*option*/, Long64_t /*bufsize*/) { const char *objname = "no name specified"; if (name) objname = name; diff --git a/core/base/src/TObject.cxx b/core/base/src/TObject.cxx index 1512ab7e1a026..c6aee86439936 100644 --- a/core/base/src/TObject.cxx +++ b/core/base/src/TObject.cxx @@ -939,7 +939,7 @@ void TObject::UseCurrentStyle() /// The function returns the total number of bytes written to the file. /// It returns 0 if the object cannot be written. -Int_t TObject::Write(const char *name, Int_t option, Int_t bufsize) const +Int_t TObject::Write(const char *name, Int_t option, Long64_t bufsize) const { if (R__unlikely(option & kOnlyPrepStep)) return 0; @@ -961,7 +961,7 @@ Int_t TObject::Write(const char *name, Int_t option, Int_t bufsize) const /// Write this object to the current directory. For more see the /// const version of this method. -Int_t TObject::Write(const char *name, Int_t option, Int_t bufsize) +Int_t TObject::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TObject*)this)->Write(name, option, bufsize); } diff --git a/core/cont/inc/TCollection.h b/core/cont/inc/TCollection.h index 5ddfe4cb511b6..66e2a053c852b 100644 --- a/core/cont/inc/TCollection.h +++ b/core/cont/inc/TCollection.h @@ -207,8 +207,8 @@ class TCollection : public TObject { void SetName(const char *name) { fName = name; } virtual void SetOwner(Bool_t enable = kTRUE); virtual bool UseRWLock(Bool_t enable = true); - Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0) override; - Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0) const override; + Int_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0) override; + Int_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const override; R__ALWAYS_INLINE Bool_t IsUsingRWLock() const { return TestBit(TCollection::kUseRWLock); } diff --git a/core/cont/inc/TMap.h b/core/cont/inc/TMap.h index 69e5fbf9af71d..a095ff566a265 100644 --- a/core/cont/inc/TMap.h +++ b/core/cont/inc/TMap.h @@ -84,8 +84,8 @@ friend class TMapIter; TPair *RemoveEntry(TObject *key); virtual void SetOwnerValue(Bool_t enable = kTRUE); virtual void SetOwnerKeyValue(Bool_t ownkeys = kTRUE, Bool_t ownvals = kTRUE); - Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override; - Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override; + Int_t Write(const char *name=nullptr, Int_t option=0, Long64_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t option=0, Long64_t bufsize=0) const override; ClassDefOverride(TMap,3) //A (key,value) map }; diff --git a/core/cont/src/TCollection.cxx b/core/cont/src/TCollection.cxx index 81fe664eea6fb..33378c4d7774c 100644 --- a/core/cont/src/TCollection.cxx +++ b/core/cont/src/TCollection.cxx @@ -676,7 +676,7 @@ void TCollection::Streamer(TBuffer &b) /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TCollection::Write(const char *name, Int_t option, Int_t bufsize) const +Int_t TCollection::Write(const char *name, Int_t option, Long64_t bufsize) const { if ((option & kSingleKey)) { return TObject::Write(name, option, bufsize); @@ -700,7 +700,7 @@ Int_t TCollection::Write(const char *name, Int_t option, Int_t bufsize) const /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TCollection::Write(const char *name, Int_t option, Int_t bufsize) +Int_t TCollection::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TCollection*)this)->Write(name,option,bufsize); } diff --git a/core/cont/src/TMap.cxx b/core/cont/src/TMap.cxx index a1af3bac25490..338e636a7b1a0 100644 --- a/core/cont/src/TMap.cxx +++ b/core/cont/src/TMap.cxx @@ -401,7 +401,7 @@ void TMap::Streamer(TBuffer &b) /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TMap::Write(const char *name, Int_t option, Int_t bufsize) const +Int_t TMap::Write(const char *name, Int_t option, Long64_t bufsize) const { if ((option & kSingleKey)) { return TObject::Write(name, option, bufsize); @@ -428,7 +428,7 @@ Int_t TMap::Write(const char *name, Int_t option, Int_t bufsize) const /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TMap::Write(const char *name, Int_t option, Int_t bufsize) +Int_t TMap::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TMap*)this)->Write(name,option,bufsize); } diff --git a/hist/hbook/inc/THbookBranch.h b/hist/hbook/inc/THbookBranch.h index ef5881462aae4..70e4cbbbb8958 100644 --- a/hist/hbook/inc/THbookBranch.h +++ b/hist/hbook/inc/THbookBranch.h @@ -30,8 +30,8 @@ class THbookBranch : public TBranch { public: THbookBranch() {} - THbookBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); - THbookBranch(TBranch *branch, const char *name, void *address, const char *leaflist, Int_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + THbookBranch(TTree *tree, const char *name, void *address, const char *leaflist, Long64_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + THbookBranch(TBranch *branch, const char *name, void *address, const char *leaflist, Long64_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); ~THbookBranch() override; void Browse(TBrowser *b) override; Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override; diff --git a/hist/hbook/src/THbookBranch.cxx b/hist/hbook/src/THbookBranch.cxx index a8e8f26140ff9..97d67e1759c6d 100644 --- a/hist/hbook/src/THbookBranch.cxx +++ b/hist/hbook/src/THbookBranch.cxx @@ -21,14 +21,14 @@ //////////////////////////////////////////////////////////////////////////////// -THbookBranch::THbookBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize, Int_t compress) +THbookBranch::THbookBranch(TTree *tree, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) :TBranch(tree, name,address,leaflist,basketsize,compress) { } //////////////////////////////////////////////////////////////////////////////// -THbookBranch::THbookBranch(TBranch *branch, const char *name, void *address, const char *leaflist, Int_t basketsize, Int_t compress) +THbookBranch::THbookBranch(TBranch *branch, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) :TBranch(branch,name,address,leaflist,basketsize,compress) { } diff --git a/hist/hbook/src/THbookFile.cxx b/hist/hbook/src/THbookFile.cxx index f44e724f71c1a..20956391e9ea5 100644 --- a/hist/hbook/src/THbookFile.cxx +++ b/hist/hbook/src/THbookFile.cxx @@ -760,7 +760,7 @@ TObject *THbookFile::ConvertCWN(Int_t id) } - Int_t bufsize = 8000; + Long64_t bufsize = 8000; THbookBranch *branch = new THbookBranch(tree,name,(void*)&bigbuf[bufpos],fullname,bufsize); tree->GetListOfBranches()->Add(branch); branch->SetBlockName(block); diff --git a/hist/hist/inc/TH1.h b/hist/hist/inc/TH1.h index 1c58a1b2ff088..4f2029d80e15c 100644 --- a/hist/hist/inc/TH1.h +++ b/hist/hist/inc/TH1.h @@ -627,13 +627,13 @@ class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker { const Double_t *zBins); virtual void SetBinsLength(Int_t = -1) { } //redefined in derived classes virtual void SetBinErrorOption(EBinErrorOpt type) { fBinStatErrOpt = type; } - virtual void SetBuffer(Int_t bufsize, Option_t *option=""); + virtual void SetBuffer(Long64_t bufsize, Option_t *option=""); virtual UInt_t SetCanExtend(UInt_t extendBitMask); virtual void SetContent(const Double_t *content); virtual void SetContour(Int_t nlevels, const Double_t *levels = nullptr); virtual void SetContourLevel(Int_t level, Double_t value); virtual void SetColors(Color_t linecolor = -1, Color_t markercolor = -1, Color_t fillcolor = -1); - static void SetDefaultBufferSize(Int_t bufsize=1000); + static void SetDefaultBufferSize(Long64_t bufsize=1000); static void SetDefaultSumw2(Bool_t sumw2=kTRUE); virtual void SetDirectory(TDirectory *dir); virtual void SetEntries(Double_t n) { fEntries = n; } diff --git a/hist/hist/inc/TProfile.h b/hist/hist/inc/TProfile.h index e1b00a80bd4b2..316f61f3d2eb3 100644 --- a/hist/hist/inc/TProfile.h +++ b/hist/hist/inc/TProfile.h @@ -132,7 +132,7 @@ class TProfile : public TH1D { void SetBins(Int_t nbins, Double_t xmin, Double_t xmax) override; void SetBins(Int_t nx, const Double_t *xbins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t bufsize, Option_t *option="") override; + void SetBuffer(Long64_t bufsize, Option_t *option="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; diff --git a/hist/hist/inc/TProfile2D.h b/hist/hist/inc/TProfile2D.h index 564141207c4f3..5215608e2dd30 100644 --- a/hist/hist/inc/TProfile2D.h +++ b/hist/hist/inc/TProfile2D.h @@ -146,7 +146,7 @@ class TProfile2D : public TH2D { void SetBins(Int_t nbinsx, Double_t xmin, Double_t xmax, Int_t nbinsy, Double_t ymin, Double_t ymax) override; void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t *yBins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t bufsize, Option_t *option="") override; + void SetBuffer(Long64_t bufsize, Option_t *option="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; Double_t GetNumberOfBins() { return fBinEntries.GetSize(); } diff --git a/hist/hist/inc/TProfile3D.h b/hist/hist/inc/TProfile3D.h index 93ce0f310e793..f30498444071d 100644 --- a/hist/hist/inc/TProfile3D.h +++ b/hist/hist/inc/TProfile3D.h @@ -144,7 +144,7 @@ class TProfile3D : public TH3D { void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t * yBins, Int_t nz, const Double_t *zBins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t bufsize, Option_t *opt="") override; + void SetBuffer(Long64_t bufsize, Option_t *opt="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; diff --git a/hist/hist/src/TH1.cxx b/hist/hist/src/TH1.cxx index 46b5c06fdce24..c88f1eb7424e2 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -6740,8 +6740,9 @@ UInt_t TH1::GetAxisLabelStatus() const /// or equal to its upper limit, the function SetBuffer is automatically /// called with the default buffer size. -void TH1::SetDefaultBufferSize(Int_t bufsize) +void TH1::SetDefaultBufferSize(Long64_t bufsize) { + assert(bufsize <= kMaxInt); fgBufferSize = bufsize > 0 ? bufsize : 0; } @@ -8498,7 +8499,7 @@ Double_t TH1::GetContourLevelPad(Int_t level) const //////////////////////////////////////////////////////////////////////////////// /// Set the maximum number of entries to be kept in the buffer. -void TH1::SetBuffer(Int_t bufsize, Option_t * /*option*/) +void TH1::SetBuffer(Long64_t bufsize, Option_t * /*option*/) { if (fBuffer) { BufferEmpty(); @@ -8510,6 +8511,8 @@ void TH1::SetBuffer(Int_t bufsize, Option_t * /*option*/) return; } if (bufsize < 100) bufsize = 100; + if (1 + bufsize*(fDimension+1)> kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + bufsize*(fDimension+1), kMaxInt); fBufferSize = 1 + bufsize*(fDimension+1); fBuffer = new Double_t[fBufferSize]; memset(fBuffer, 0, sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TProfile.cxx b/hist/hist/src/TProfile.cxx index 021bc95c3fb1a..9f2eb71458953 100644 --- a/hist/hist/src/TProfile.cxx +++ b/hist/hist/src/TProfile.cxx @@ -1769,7 +1769,7 @@ void TProfile::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile::SetBuffer(Int_t bufsize, Option_t *) +void TProfile::SetBuffer(Long64_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); @@ -1781,6 +1781,8 @@ void TProfile::SetBuffer(Int_t bufsize, Option_t *) return; } if (bufsize < 100) bufsize = 100; + if (1 + 3*bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + 3*bufsize, kMaxInt); fBufferSize = 1 + 3*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TProfile2D.cxx b/hist/hist/src/TProfile2D.cxx index e61d826cf30d6..776b4418cc567 100644 --- a/hist/hist/src/TProfile2D.cxx +++ b/hist/hist/src/TProfile2D.cxx @@ -2022,7 +2022,7 @@ void TProfile2D::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile2D::SetBuffer(Int_t bufsize, Option_t *) +void TProfile2D::SetBuffer(Long64_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); @@ -2034,6 +2034,8 @@ void TProfile2D::SetBuffer(Int_t bufsize, Option_t *) return; } if (bufsize < 100) bufsize = 100; + if (1 + 4*bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + 4*bufsize, kMaxInt); fBufferSize = 1 + 4*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TProfile3D.cxx b/hist/hist/src/TProfile3D.cxx index 2b6569a642692..7ac5db17a4987 100644 --- a/hist/hist/src/TProfile3D.cxx +++ b/hist/hist/src/TProfile3D.cxx @@ -1391,7 +1391,7 @@ void TProfile3D::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile3D::SetBuffer(Int_t bufsize, Option_t *) +void TProfile3D::SetBuffer(Long64_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); @@ -1403,6 +1403,8 @@ void TProfile3D::SetBuffer(Int_t bufsize, Option_t *) return; } if (bufsize < 100) bufsize = 100; + if (1 + 5*bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + 5*bufsize, kMaxInt); fBufferSize = 1 + 5*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TScatter.cxx b/hist/hist/src/TScatter.cxx index 13476f84d3e60..f54506847eb3b 100644 --- a/hist/hist/src/TScatter.cxx +++ b/hist/hist/src/TScatter.cxx @@ -83,6 +83,9 @@ TScatter::TScatter(Int_t n, const Double_t *x, const Double_t *y, const Double_t fMaxSize = fGraph->GetMaxSize(); Int_t bufsize = sizeof(Double_t) * fNpoints; + if (sizeof(Double_t) * fNpoints > kMaxInt || bufsize < 0) { + Fatal("TScatter", "Negative buffer size likely due to an integer overflow: 0x%x.", bufsize); + } if (col) { fColor = new Double_t[fMaxSize]; memcpy(fColor, col, bufsize); diff --git a/hist/histpainter/src/TPainter3dAlgorithms.cxx b/hist/histpainter/src/TPainter3dAlgorithms.cxx index f0884c9aa3656..7a4f7f8fb4595 100644 --- a/hist/histpainter/src/TPainter3dAlgorithms.cxx +++ b/hist/histpainter/src/TPainter3dAlgorithms.cxx @@ -2009,7 +2009,9 @@ void TPainter3dAlgorithms::InitRaster(Double_t xmin, Double_t ymin, Double_t xma fDYrast = ymax - ymin; // Create buffer for raster - Int_t bufsize = nx*ny/30 + 1; + if (Long64_t(nx)*ny / 30 + 1 > kMaxInt) + Fatal("InitRaster", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", Long64_t(nx)*ny / 30 + 1, kMaxInt); + Int_t bufsize = Long64_t(nx)*ny/30 + 1; fRaster.resize(bufsize); // S E T M A S K S diff --git a/io/io/inc/ROOT/TBufferMerger.hxx b/io/io/inc/ROOT/TBufferMerger.hxx index d3c8ac86849a2..09fd41d58e802 100644 --- a/io/io/inc/ROOT/TBufferMerger.hxx +++ b/io/io/inc/ROOT/TBufferMerger.hxx @@ -172,7 +172,7 @@ public: * This function must be called before the TBufferMergerFile gets destroyed, * or no data is appended to the TBufferMerger. */ - Int_t Write(const char *name = nullptr, Int_t opt = 0, Int_t bufsize = 0) override; + Int_t Write(const char *name = nullptr, Int_t opt = 0, Long64_t bufsize = 0) override; ClassDefOverride(TBufferMergerFile, 0); }; diff --git a/io/io/inc/TBufferFile.h b/io/io/inc/TBufferFile.h index 5aaf5f1916f83..3d2e37141fcc4 100644 --- a/io/io/inc/TBufferFile.h +++ b/io/io/inc/TBufferFile.h @@ -59,9 +59,9 @@ class TBufferFile : public TBufferIO { TBufferFile(const TBufferFile &) = delete; ///< not implemented void operator=(const TBufferFile &) = delete; ///< not implemented - Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss, const char* classname); - void CheckCount(UInt_t offset) override; - UInt_t CheckObject(UInt_t offset, const TClass *cl, Bool_t readClass = kFALSE); + Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss, const char* classname); + void CheckCount(UInt_t offset) override; + UInt_t CheckObject(UInt_t offset, const TClass *cl, Bool_t readClass = kFALSE); void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) override; @@ -69,13 +69,13 @@ class TBufferFile : public TBufferIO { enum { kStreamedMemberWise = BIT(14) }; //added to version number to know if a collection has been stored member-wise TBufferFile(TBuffer::EMode mode); - TBufferFile(TBuffer::EMode mode, Int_t bufsize); - TBufferFile(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); + TBufferFile(TBuffer::EMode mode, Long64_t bufsize); + TBufferFile(TBuffer::EMode mode, Long64_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); ~TBufferFile() override; - Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) override; - Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname) override; - void SetByteCount(UInt_t cntpos, Bool_t packInVersion = kFALSE) override; + Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss) override; + Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const char *classname) override; + void SetByteCount(ULong64_t cntpos, Bool_t packInVersion = kFALSE) override; void SkipVersion(const TClass *cl = nullptr) override; Version_t ReadVersion(UInt_t *start = nullptr, UInt_t *bcnt = nullptr, const TClass *cl = nullptr) override; @@ -95,10 +95,10 @@ class TBufferFile : public TBufferIO { void ClassEnd(const TClass*) override {} void ClassMember(const char*, const char * = nullptr, Int_t = -1, Int_t = -1) override {} - Int_t ReadBuf(void *buf, Int_t max) override; - void WriteBuf(const void *buf, Int_t max) override; + Long64_t ReadBuf(void *buf, Long64_t max) override; + void WriteBuf(const void *buf, Long64_t max) override; - char *ReadString(char *s, Int_t max) override; + char *ReadString(char *s, Long64_t max) override; void WriteString(const char *s) override; TClass *ReadClass(const TClass *cl = nullptr, UInt_t *objTag = nullptr) override; diff --git a/io/io/inc/TBufferIO.h b/io/io/inc/TBufferIO.h index 1500beed2616e..eeec87582d007 100644 --- a/io/io/inc/TBufferIO.h +++ b/io/io/inc/TBufferIO.h @@ -25,6 +25,8 @@ #include "TString.h" +#include + class TExMap; class TBufferIO : public TBuffer { @@ -44,8 +46,8 @@ class TBufferIO : public TBuffer { TBufferIO() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300 TBufferIO(TBuffer::EMode mode); - TBufferIO(TBuffer::EMode mode, Int_t bufsize); - TBufferIO(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, + TBufferIO(TBuffer::EMode mode, Long64_t bufsize); + TBufferIO(TBuffer::EMode mode, Long64_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); //////////////////////////////////////////////////////////////////////////////// @@ -80,7 +82,7 @@ class TBufferIO : public TBuffer { void SetPidOffset(UShort_t offset) override; Int_t GetBufferDisplacement() const override { return fDisplacement; } void SetBufferDisplacement() override { fDisplacement = 0; } - void SetBufferDisplacement(Int_t skipped) override { fDisplacement = (Int_t)(Length() - skipped); } + void SetBufferDisplacement(Long64_t skipped) override { assert(skipped <= kMaxInt); fDisplacement = (Int_t)(Length() - skipped); } // Utilities for objects map void SetReadParam(Int_t mapsize) override; @@ -89,8 +91,8 @@ class TBufferIO : public TBuffer { void ResetMap() override; void Reset() override; Int_t GetMapCount() const override { return fMapCount; } - void MapObject(const TObject *obj, UInt_t offset = 1) override; - void MapObject(const void *obj, const TClass *cl, UInt_t offset = 1) override; + void MapObject(const TObject *obj, ULong64_t offset = 1) override; + void MapObject(const void *obj, const TClass *cl, ULong64_t offset = 1) override; Bool_t CheckObject(const TObject *obj) override; Bool_t CheckObject(const void *obj, const TClass *ptrClass) override; void GetMappedObject(UInt_t tag, void *&ptr, TClass *&ClassPtr) const override; @@ -98,8 +100,8 @@ class TBufferIO : public TBuffer { // Utilities for TStreamerInfo void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override; void ForceWriteInfoClones(TClonesArray *a) override; - Int_t ReadClones(TClonesArray *a, Int_t nobjects, Version_t objvers) override; - Int_t WriteClones(TClonesArray *a, Int_t nobjects) override; + Int_t ReadClones(TClonesArray *a, Long64_t nobjects, Version_t objvers) override; + Int_t WriteClones(TClonesArray *a, Long64_t nobjects) override; void TagStreamerInfo(TVirtualStreamerInfo *info) override; // Special basic ROOT objects and collections diff --git a/io/io/inc/TBufferText.h b/io/io/inc/TBufferText.h index e19cd7ca8d0e6..a5cbffc99deb0 100644 --- a/io/io/inc/TBufferText.h +++ b/io/io/inc/TBufferText.h @@ -75,20 +75,20 @@ class TBufferText : public TBufferIO { // virtual abstract TBuffer methods, which are not used in text streaming - Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const TClass * /* clss */) final { return 0; } - Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const char * /* classname */) final { return 0; } - void SetByteCount(UInt_t /* cntpos */, Bool_t /* packInVersion */ = kFALSE) final {} + Long64_t CheckByteCount(ULong64_t /* startpos */, ULong64_t /* bcnt */, const TClass * /* clss */) final { return 0; } + Long64_t CheckByteCount(ULong64_t /* startpos */, ULong64_t /* bcnt */, const char * /* classname */) final { return 0; } + void SetByteCount(ULong64_t /* cntpos */, Bool_t /* packInVersion */ = kFALSE) final {} void SkipVersion(const TClass *cl = nullptr) final; Version_t ReadVersionNoCheckSum(UInt_t *, UInt_t *) final { return 0; } - Int_t ReadBuf(void * /*buf*/, Int_t /*max*/) final + Long64_t ReadBuf(void * /*buf*/, Long64_t /*max*/) final { Error("ReadBuf", "useless in text streamers"); return 0; } - void WriteBuf(const void * /*buf*/, Int_t /*max*/) final { Error("WriteBuf", "useless in text streamers"); } + void WriteBuf(const void * /*buf*/, Long64_t /*max*/) final { Error("WriteBuf", "useless in text streamers"); } - char *ReadString(char * /*s*/, Int_t /*max*/) final + char *ReadString(char * /*s*/, Long64_t /*max*/) final { Error("ReadString", "useless"); return nullptr; diff --git a/io/io/inc/TDirectoryFile.h b/io/io/inc/TDirectoryFile.h index 16f2d2edaa4e4..d09720d4b7662 100644 --- a/io/io/inc/TDirectoryFile.h +++ b/io/io/inc/TDirectoryFile.h @@ -114,17 +114,17 @@ class TDirectoryFile : public TDirectory { void Save() override; void SaveSelf(Bool_t force = kFALSE) override; Int_t SaveObjectAs(const TObject *obj, const char *filename="", Option_t *option="") const override; - void SetBufferSize(Int_t bufsize) override; + void SetBufferSize(Long64_t bufsize) override; void SetModified() override {fModified = kTRUE;} void SetSeekDir(Long64_t v) override { fSeekDir = v; } void SetTRefAction(TObject *ref, TObject *parent) override; void SetWritable(Bool_t writable=kTRUE) override; Int_t Sizeof() const override; - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override; - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override; - Int_t WriteTObject(const TObject *obj, const char *name=nullptr, Option_t *option="", Int_t bufsize=0) override; - Int_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Int_t bufsize=0) override; - Int_t WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option="", Int_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) const override; + Int_t WriteTObject(const TObject *obj, const char *name=nullptr, Option_t *option="", Long64_t bufsize=0) override; + Int_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Long64_t bufsize=0) override; + Int_t WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option="", Long64_t bufsize=0) override; void WriteDirHeader() override; void WriteKeys() override; diff --git a/io/io/inc/TFile.h b/io/io/inc/TFile.h index 5460e47384a41..81442ad7ffefa 100644 --- a/io/io/inc/TFile.h +++ b/io/io/inc/TFile.h @@ -286,10 +286,10 @@ class TFile : public TDirectoryFile { void Close(Option_t *option="") override; // *MENU* void Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); } - virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE,UInt_t bufsize = 1000000); - virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize); + virtual Bool_t Cp(const char *dst, Bool_t progressbar = kTRUE, Long64_t bufsize = 1000000); + virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, const char* name, Long64_t bufsize); virtual TKey* CreateKey(TDirectory* mother, const void* obj, const TClass* cl, - const char* name, Int_t bufsize); + const char* name, Long64_t bufsize); static TFile *&CurrentFile(); // Return the current file for this thread. void Delete(const char *namecycle="") override; void Draw(Option_t *option="") override; @@ -373,10 +373,10 @@ class TFile : public TDirectoryFile { virtual void SetReadCalls(Int_t readcalls = 0) { fReadCalls = readcalls; } virtual void ShowStreamerInfo(); Int_t Sizeof() const override; - void SumBuffer(Int_t bufsize); + void SumBuffer(Long64_t bufsize); virtual Bool_t WriteBuffer(const char *buf, Int_t len); - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override; - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) const override; virtual void WriteFree(); virtual void WriteHeader(); virtual UShort_t WriteProcessID(TProcessID *pid); @@ -404,8 +404,8 @@ class TFile : public TDirectoryFile { static void SetFileBytesRead(Long64_t bytes = 0); static void SetFileBytesWritten(Long64_t bytes = 0); - static void SetFileReadCalls(Int_t readcalls = 0); - static void SetReadaheadSize(Int_t bufsize = 256000); + static void SetFileReadCalls(Long64_t readcalls = 0); + static void SetReadaheadSize(Long64_t bytes = 256000); static void SetReadStreamerInfo(Bool_t readinfo=kTRUE); static Bool_t GetReadStreamerInfo(); @@ -417,7 +417,7 @@ class TFile : public TDirectoryFile { static const char *GetCacheFileDir(); static Bool_t ShrinkCacheFileDir(Long64_t shrinkSize, Long_t cleanupInteval = 0); static Bool_t Cp(const char *src, const char *dst, Bool_t progressbar = kTRUE, - UInt_t buffersize = 1000000); + Long64_t bufsize = 1000000); static UInt_t SetOpenTimeout(UInt_t timeout); // in ms static UInt_t GetOpenTimeout(); // in ms diff --git a/io/io/inc/TFileCacheRead.h b/io/io/inc/TFileCacheRead.h index 0f05c7e8bb199..429bb865dd8ae 100644 --- a/io/io/inc/TFileCacheRead.h +++ b/io/io/inc/TFileCacheRead.h @@ -78,7 +78,7 @@ class TFileCacheRead : public TObject { public: TFileCacheRead(); - TFileCacheRead(TFile *file, Int_t bufsize, TObject *tree = nullptr); + TFileCacheRead(TFile *file, Long64_t bufsize, TObject *tree = nullptr); ~TFileCacheRead() override; virtual Int_t AddBranch(TBranch * /*b*/, Bool_t /*subbranches*/ = kFALSE) { return 0; } virtual Int_t AddBranch(const char * /*branch*/, Bool_t /*subbranches*/ = kFALSE) { return 0; } @@ -107,7 +107,7 @@ class TFileCacheRead : public TObject { virtual Int_t ReadBufferExtNormal(char *buf, Long64_t pos, Int_t len, Int_t &loc); virtual Int_t ReadBufferExtPrefetch(char *buf, Long64_t pos, Int_t len, Int_t &loc); virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len); - virtual Int_t SetBufferSize(Long64_t buffersize); + virtual Int_t SetBufferSize(Long64_t bufsize); virtual void SetFile(TFile *file, TFile::ECacheAction action = TFile::kDisconnect); virtual void SetSkipZip(Bool_t /*skip*/ = kTRUE) {} // This function is only used by TTreeCacheUnzip (ignore it) virtual void Sort(); diff --git a/io/io/inc/TFileCacheWrite.h b/io/io/inc/TFileCacheWrite.h index 83366eabcfc68..e3cce1ab15e1d 100644 --- a/io/io/inc/TFileCacheWrite.h +++ b/io/io/inc/TFileCacheWrite.h @@ -32,7 +32,7 @@ class TFileCacheWrite : public TObject { public: TFileCacheWrite(); - TFileCacheWrite(TFile *file, Int_t bufsize); + TFileCacheWrite(TFile *file, Long64_t bufsize); ~TFileCacheWrite() override; virtual Bool_t Flush(); virtual Int_t GetBytesInCache() const { return fNtot; } diff --git a/io/io/inc/TKey.h b/io/io/inc/TKey.h index a94081326ada1..77635ca9b9242 100644 --- a/io/io/inc/TKey.h +++ b/io/io/inc/TKey.h @@ -52,7 +52,7 @@ class TKey : public TNamed { TDirectory *fMotherDir; ///(fBufCur - fBuffer) + assert( cntpos <= kMaxUInt && (sizeof(UInt_t) + cntpos) < static_cast(fBufCur - fBuffer) && (fBufCur >= fBuffer) && static_cast(fBufCur - fBuffer) <= std::numeric_limits::max() && "Byte count position is after the end of the buffer"); - const UInt_t cnt = UInt_t(fBufCur - fBuffer) - cntpos - sizeof(UInt_t); + const UInt_t cnt = UInt_t(fBufCur - fBuffer) - UInt_t(cntpos) - sizeof(UInt_t); char *buf = (char *)(fBuffer + cntpos); // if true, pack byte count in two consecutive shorts, so it can @@ -358,11 +358,11 @@ void TBufferFile::SetByteCount(UInt_t cntpos, Bool_t packInVersion) /// Returns 0 if everything is ok, otherwise the bytecount offset /// (< 0 when read too little, >0 when read too much). -Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss, const char *classname) +Long64_t TBufferFile::CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss, const char *classname) { if (!bcnt) return 0; - - Int_t offset = 0; + R__ASSERT(startpos <= kMaxUInt && bcnt <= kMaxUInt); + Long64_t offset = 0; Longptr_t endpos = Longptr_t(fBuffer) + startpos + bcnt + sizeof(UInt_t); @@ -373,11 +373,11 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl if (name) { if (offset < 0) { - Error("CheckByteCount", "object of class %s read too few bytes: %d instead of %d", + Error("CheckByteCount", "object of class %s read too few bytes: %lld instead of %llu", name,bcnt+offset,bcnt); } if (offset > 0) { - Error("CheckByteCount", "object of class %s read too many bytes: %d instead of %d", + Error("CheckByteCount", "object of class %s read too many bytes: %lld instead of %llu", name,bcnt+offset,bcnt); if (fParent) Warning("CheckByteCount","%s::Streamer() not in sync with data on file %s, fix Streamer()", @@ -390,7 +390,7 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl if ( ((char *)endpos) > fBufMax ) { offset = fBufMax-fBufCur; Error("CheckByteCount", - "Byte count probably corrupted around buffer position %d:\n\t%d for a possible maximum of %d", + "Byte count probably corrupted around buffer position %llu:\n\t%llu for a possible maximum of %lld", startpos, bcnt, offset); fBufCur = fBufMax; @@ -411,7 +411,7 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl /// Returns 0 if everything is ok, otherwise the bytecount offset /// (< 0 when read too little, >0 when read too much). -Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) +Long64_t TBufferFile::CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss) { if (!bcnt) return 0; return CheckByteCount( startpos, bcnt, clss, nullptr); @@ -425,7 +425,7 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl /// Returns 0 if everything is ok, otherwise the bytecount offset /// (< 0 when read too little, >0 when read too much). -Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname) +Long64_t TBufferFile::CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const char *classname) { if (!bcnt) return 0; return CheckByteCount( startpos, bcnt, nullptr, classname); @@ -3332,13 +3332,13 @@ UInt_t TBufferFile::CheckObject(UInt_t offset, const TClass *cl, Bool_t readClas /// Read max bytes from the I/O buffer into buf. The function returns /// the actual number of bytes read. -Int_t TBufferFile::ReadBuf(void *buf, Int_t max) +Long64_t TBufferFile::ReadBuf(void *buf, Long64_t max) { R__ASSERT(IsReading()); if (max == 0) return 0; - Int_t n = std::min(max, (Int_t)(fBufMax - fBufCur)); + Long64_t n = std::min(max, (Long64_t)(fBufMax - fBufCur)); memcpy(buf, fBufCur, n); fBufCur += n; @@ -3349,7 +3349,7 @@ Int_t TBufferFile::ReadBuf(void *buf, Int_t max) //////////////////////////////////////////////////////////////////////////////// /// Write max bytes from buf into the I/O buffer. -void TBufferFile::WriteBuf(const void *buf, Int_t max) +void TBufferFile::WriteBuf(const void *buf, Long64_t max) { R__ASSERT(IsWriting()); @@ -3365,14 +3365,14 @@ void TBufferFile::WriteBuf(const void *buf, Int_t max) /// Read string from I/O buffer. String is read till 0 character is /// found or till max-1 characters are read (i.e. string s has max /// bytes allocated). If max = -1 no check on number of character is -/// made, reading continues till 0 character is found. +/// made, reading continues till 0 character is found or MaxInt-1 chars are read. -char *TBufferFile::ReadString(char *s, Int_t max) +char *TBufferFile::ReadString(char *s, Long64_t max) { R__ASSERT(IsReading()); - + R__ASSERT(max <= kMaxInt); char ch; - Int_t nr = 0; + Long64_t nr = 0; if (max == -1) max = kMaxInt; diff --git a/io/io/src/TBufferIO.cxx b/io/io/src/TBufferIO.cxx index 15296409dce64..3e366004fc000 100644 --- a/io/io/src/TBufferIO.cxx +++ b/io/io/src/TBufferIO.cxx @@ -47,7 +47,7 @@ TBufferIO::TBufferIO(TBuffer::EMode mode) : TBuffer(mode) //////////////////////////////////////////////////////////////////////////////// /// constructor -TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize) : TBuffer(mode, bufsize) +TBufferIO::TBufferIO(TBuffer::EMode mode, Long64_t bufsize) : TBuffer(mode, bufsize) { fMapSize = fgMapSize; } @@ -55,7 +55,7 @@ TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize) : TBuffer(mode, bufsize //////////////////////////////////////////////////////////////////////////////// /// constructor -TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) +TBufferIO::TBufferIO(TBuffer::EMode mode, Long64_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) : TBuffer(mode, bufsize, buf, adopt, reallocfunc) { fMapSize = fgMapSize; @@ -159,8 +159,9 @@ void TBufferIO::InitMap() /// contains (via via) a pointer to itself. In that case offset must be 1 /// (default value for offset). -void TBufferIO::MapObject(const TObject *obj, UInt_t offset) +void TBufferIO::MapObject(const TObject *obj, ULong64_t offset) { + R__ASSERT(offset <= kMaxUInt); if (IsWriting()) { if (!fMap) InitMap(); @@ -192,8 +193,9 @@ void TBufferIO::MapObject(const TObject *obj, UInt_t offset) /// contains (via via) a pointer to itself. In that case offset must be 1 /// (default value for offset). -void TBufferIO::MapObject(const void *obj, const TClass *cl, UInt_t offset) +void TBufferIO::MapObject(const void *obj, const TClass *cl, ULong64_t offset) { + R__ASSERT(offset <= kMaxUInt); if (IsWriting()) { if (!fMap) InitMap(); @@ -368,8 +370,9 @@ void TBufferIO::TagStreamerInfo(TVirtualStreamerInfo *info) //////////////////////////////////////////////////////////////////////////////// /// Interface to TStreamerInfo::ReadBufferClones. -Int_t TBufferIO::ReadClones(TClonesArray *a, Int_t nobjects, Version_t objvers) +Int_t TBufferIO::ReadClones(TClonesArray *a, Long64_t nobjects, Version_t objvers) { + assert(nobjects <= kMaxInt); char **arr = (char **)a->GetObjectRef(0); char **end = arr + nobjects; // a->GetClass()->GetStreamerInfo()->ReadBufferClones(*this,a,nobjects,-1,0); @@ -381,8 +384,9 @@ Int_t TBufferIO::ReadClones(TClonesArray *a, Int_t nobjects, Version_t objvers) //////////////////////////////////////////////////////////////////////////////// /// Interface to TStreamerInfo::WriteBufferClones. -Int_t TBufferIO::WriteClones(TClonesArray *a, Int_t nobjects) +Int_t TBufferIO::WriteClones(TClonesArray *a, Long64_t nobjects) { + assert(nobjects <= kMaxInt); char **arr = reinterpret_cast(a->GetObjectRef(0)); // a->GetClass()->GetStreamerInfo()->WriteBufferClones(*this,(TClonesArray*)a,nobjects,-1,0); TStreamerInfo *info = (TStreamerInfo *)a->GetClass()->GetStreamerInfo(); diff --git a/io/io/src/TBufferMergerFile.cxx b/io/io/src/TBufferMergerFile.cxx index 951891e2a46ec..63b0b66d379e9 100644 --- a/io/io/src/TBufferMergerFile.cxx +++ b/io/io/src/TBufferMergerFile.cxx @@ -26,7 +26,7 @@ TBufferMergerFile::~TBufferMergerFile() { } -Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Int_t bufsize) +Int_t TBufferMergerFile::Write(const char *name, Int_t opt, Long64_t bufsize) { // Make sure the compression of the basket is done in the unlocked thread and // not in the locked section. diff --git a/io/io/src/TDirectoryFile.cxx b/io/io/src/TDirectoryFile.cxx index d4f33a9c12a6e..64da883b0e3ee 100644 --- a/io/io/src/TDirectoryFile.cxx +++ b/io/io/src/TDirectoryFile.cxx @@ -406,7 +406,7 @@ TObject *TDirectoryFile::CloneObject(const TObject *obj, Bool_t autoadd /* = kTR // during the streaming .... TFile *filsav = gFile; gFile = nullptr; - const Int_t bufsize = 10000; + const Long64_t bufsize = 10000; TBufferFile buffer(TBuffer::kWrite,bufsize); buffer.MapObject(obj); //register obj in map to handle self reference { @@ -1662,8 +1662,10 @@ void TDirectoryFile::SaveSelf(Bool_t force) /// /// See also TDirectoryFile::GetBufferSize -void TDirectoryFile::SetBufferSize(Int_t bufsize) +void TDirectoryFile::SetBufferSize(Long64_t bufsize) { + if (bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); fBufferSize = bufsize; } @@ -1850,7 +1852,7 @@ void TDirectoryFile::Streamer(TBuffer &b) /// For allowed options see TObject::Write(). /// The directory header info is rewritten on the directory header record. -Int_t TDirectoryFile::Write(const char *, Int_t opt, Int_t bufsize) +Int_t TDirectoryFile::Write(const char *, Int_t opt, Long64_t bufsize) { if (!IsWritable()) return 0; TDirectory::TContext ctxt(this); @@ -1871,7 +1873,7 @@ Int_t TDirectoryFile::Write(const char *, Int_t opt, Int_t bufsize) //////////////////////////////////////////////////////////////////////////////// /// One can not save a const TDirectory object. -Int_t TDirectoryFile::Write(const char *n, Int_t opt, Int_t bufsize) const +Int_t TDirectoryFile::Write(const char *n, Int_t opt, Long64_t bufsize) const { Error("Write const","A const TDirectory object should not be saved. We try to proceed anyway."); return const_cast(this)->Write(n, opt, bufsize); @@ -1921,7 +1923,7 @@ Int_t TDirectoryFile::Write(const char *n, Int_t opt, Int_t bufsize) const /// WARNING: avoid special characters like '^','$','.' in the name as they /// are used by the regular expression parser (see TRegexp). -Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_t *option, Int_t bufsize) +Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_t *option, Long64_t bufsize) { TDirectory::TContext ctxt(this); @@ -1948,7 +1950,11 @@ Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_ TKey *key=0, *oldkey=0; Int_t bsize = GetBufferSize(); - if (bufsize > 0) bsize = bufsize; + if (bufsize > 0) { + if (bufsize > kMaxInt) + Fatal("WriteTObject", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + bsize = bufsize; + } const char *oname; if (name && *name) @@ -2036,7 +2042,7 @@ Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_ /// ~~~ /// See also remarks in TDirectoryFile::WriteTObject -Int_t TDirectoryFile::WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option, Int_t bufsize) +Int_t TDirectoryFile::WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option, Long64_t bufsize) { TClass *cl = TClass::GetClass(classname); if (!cl) { @@ -2063,7 +2069,7 @@ Int_t TDirectoryFile::WriteObjectAny(const void *obj, const char *classname, con /// An alternative is to call the function WriteObjectAny above. /// see TDirectoryFile::WriteTObject for comments -Int_t TDirectoryFile::WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option, Int_t bufsize) +Int_t TDirectoryFile::WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option, Long64_t bufsize) { TDirectory::TContext ctxt(this); @@ -2102,7 +2108,10 @@ Int_t TDirectoryFile::WriteObjectAny(const void *obj, const TClass *cl, const ch TKey *key, *oldkey = nullptr; Int_t bsize = GetBufferSize(); - if (bufsize > 0) bsize = bufsize; + if (bufsize > 0) { + Fatal("WriteObjectAny", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + bsize = bufsize; + } TString opt = option; opt.ToLower(); diff --git a/io/io/src/TFile.cxx b/io/io/src/TFile.cxx index eb6fcc3f5ab6d..df8267622d7c6 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -1053,7 +1053,7 @@ void TFile::Close(Option_t *option) //////////////////////////////////////////////////////////////////////////////// /// Creates key for object and converts data to buffer. -TKey* TFile::CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize) +TKey* TFile::CreateKey(TDirectory* mother, const TObject* obj, const char* name, Long64_t bufsize) { return new TKey(obj, name, bufsize, mother); } @@ -1061,7 +1061,7 @@ TKey* TFile::CreateKey(TDirectory* mother, const TObject* obj, const char* name, //////////////////////////////////////////////////////////////////////////////// /// Creates key for object and converts data to buffer. -TKey* TFile::CreateKey(TDirectory* mother, const void* obj, const TClass* cl, const char* name, Int_t bufsize) +TKey* TFile::CreateKey(TDirectory* mother, const void* obj, const TClass* cl, const char* name, Long64_t bufsize) { return new TKey(obj, cl, name, bufsize, mother); } @@ -2445,11 +2445,16 @@ void TFile::Streamer(TBuffer &b) //////////////////////////////////////////////////////////////////////////////// /// Increment statistics for buffer sizes of objects in this file. -void TFile::SumBuffer(Int_t bufsize) +void TFile::SumBuffer(Long64_t bufsize) { + if (bufsize > kMaxInt) + Fatal("SumBuffer", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + else if (bufsize < 0) + Fatal("SumBuffer", "negative buffer size: 0x%llx.", bufsize); + fWritten++; - fSumBuffer += double(bufsize); - fSum2Buffer += double(bufsize) * double(bufsize); // avoid reaching MAXINT for temporary + fSumBuffer += bufsize; + fSum2Buffer += bufsize * bufsize; } //////////////////////////////////////////////////////////////////////////////// @@ -2464,7 +2469,7 @@ void TFile::SumBuffer(Int_t bufsize) /// The linked list of FREE segments is written. /// The file header is written (bytes 1->fBEGIN). -Int_t TFile::Write(const char *, Int_t opt, Int_t bufsize) +Int_t TFile::Write(const char *, Int_t opt, Long64_t bufsize) { if (!IsWritable()) { if (!TestBit(kWriteError)) { @@ -2494,7 +2499,7 @@ Int_t TFile::Write(const char *, Int_t opt, Int_t bufsize) //////////////////////////////////////////////////////////////////////////////// /// One can not save a const TDirectory object. -Int_t TFile::Write(const char *n, Int_t opt, Int_t bufsize) const +Int_t TFile::Write(const char *n, Int_t opt, Long64_t bufsize) const { Error("Write const","A const TFile object should not be saved. We try to proceed anyway."); return const_cast(this)->Write(n, opt, bufsize); @@ -4285,16 +4290,28 @@ Int_t TFile::GetReadaheadSize() } //______________________________________________________________________________ -void TFile::SetReadaheadSize(Int_t bytes) { fgReadaheadSize = bytes; } +void TFile::SetReadaheadSize(Long64_t bytes) { + assert (bytes <= kMaxInt); + fgReadaheadSize = bytes; +} //______________________________________________________________________________ -void TFile::SetFileBytesRead(Long64_t bytes) { fgBytesRead = bytes; } +void TFile::SetFileBytesRead(Long64_t bytes) { + assert (bytes <= kMaxInt); + fgBytesRead = bytes; +} //______________________________________________________________________________ -void TFile::SetFileBytesWritten(Long64_t bytes) { fgBytesWrite = bytes; } +void TFile::SetFileBytesWritten(Long64_t bytes) { + assert (bytes <= kMaxInt); + fgBytesWrite = bytes; +} //______________________________________________________________________________ -void TFile::SetFileReadCalls(Int_t readcalls) { fgReadCalls = readcalls; } +void TFile::SetFileReadCalls(Long64_t readcalls) { + assert (readcalls <= kMaxInt); + fgReadCalls = readcalls; +} //______________________________________________________________________________ Long64_t TFile::GetFileCounter() { return fgFileCounter; } @@ -4684,7 +4701,7 @@ void TFile::CpProgress(Long64_t bytesread, Long64_t size, TStopwatch &watch) /// Allows to copy this file to the dst URL. Returns kTRUE in case of success, /// kFALSE otherwise. -Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t bufsize) +Bool_t TFile::Cp(const char *dst, Bool_t progressbar, Long64_t bufsize) { Bool_t rmdestiferror = kFALSE; TStopwatch watch; @@ -4739,6 +4756,11 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t bufsize) sfile->Seek(0); dfile->Seek(0); + if (bufsize < 0) + Fatal("TFile::Cp", "Negative buffer size: 0x%llx.", bufsize); + else if (bufsize > kMaxUInt) { + Fatal("TFile::Cp", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxUInt); + } copybuffer = new char[bufsize]; if (!copybuffer) { ::Error("TFile::Cp", "cannot allocate the copy buffer"); @@ -4761,7 +4783,7 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t bufsize) Long64_t b1 = sfile->GetBytesRead() - b00; Long64_t readsize; - if (filesize - b1 > (Long64_t)bufsize) { + if (filesize - b1 > bufsize) { readsize = bufsize; } else { readsize = filesize - b1; @@ -4787,7 +4809,7 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t bufsize) goto copyout; } totalread += read; - } while (read == (Long64_t)bufsize); + } while (read == bufsize); if (progressbar) { CpProgress(totalread, filesize,watch); @@ -4816,7 +4838,7 @@ Bool_t TFile::Cp(const char *dst, Bool_t progressbar, UInt_t bufsize) /// kFALSE otherwise. Bool_t TFile::Cp(const char *src, const char *dst, Bool_t progressbar, - UInt_t bufsize) + Long64_t bufsize) { TUrl sURL(src, kTRUE); diff --git a/io/io/src/TFileCacheRead.cxx b/io/io/src/TFileCacheRead.cxx index 367bfe0048541..0521bc884c9f8 100644 --- a/io/io/src/TFileCacheRead.cxx +++ b/io/io/src/TFileCacheRead.cxx @@ -89,9 +89,14 @@ TFileCacheRead::TFileCacheRead() : TObject() //////////////////////////////////////////////////////////////////////////////// /// Creates a TFileCacheRead data structure. -TFileCacheRead::TFileCacheRead(TFile *file, Int_t bufsize, TObject *tree) +TFileCacheRead::TFileCacheRead(TFile *file, Long64_t bufsize, TObject *tree) : TObject() { + if (bufsize < 0) + Fatal("TFileCacheRead", "Negative buffer size: 0x%llx.", bufsize); + else if (bufsize > kMaxInt) { + Fatal("TFileCacheRead", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + } if (bufsize <=10000) fBufferSize = 100000; else fBufferSize = bufsize; diff --git a/io/io/src/TFileCacheWrite.cxx b/io/io/src/TFileCacheWrite.cxx index 5aadb50ce8791..89c197ac0b1e8 100644 --- a/io/io/src/TFileCacheWrite.cxx +++ b/io/io/src/TFileCacheWrite.cxx @@ -49,9 +49,14 @@ TFileCacheWrite::TFileCacheWrite() : TObject() /// The size of the cache will be bufsize, /// if bufsize < 10000 a default size of 512 Kbytes is used -TFileCacheWrite::TFileCacheWrite(TFile *file, Int_t bufsize) +TFileCacheWrite::TFileCacheWrite(TFile *file, Long64_t bufsize) : TObject() { + if (bufsize < 0) + Fatal("TFileCacheWrite", "Negative buffer size: 0x%llx.", bufsize); + else if (bufsize > kMaxInt) { + Fatal("TFileCacheWrite", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + } if (bufsize < 10000) bufsize = 512000; fBufferSize = bufsize; fSeekStart = 0; @@ -60,7 +65,7 @@ TFileCacheWrite::TFileCacheWrite(TFile *file, Int_t bufsize) fRecursive = kFALSE; fBuffer = new char[fBufferSize]; if (file) file->SetCacheWrite(this); - if (gDebug > 0) Info("TFileCacheWrite","Creating a write cache with buffersize=%d bytes",bufsize); + if (gDebug > 0) Info("TFileCacheWrite","Creating a write cache with buffersize=%lld bytes",bufsize); } //////////////////////////////////////////////////////////////////////////////// diff --git a/io/io/src/TKey.cxx b/io/io/src/TKey.cxx index 65971ad1d427b..4093eb2a14cee 100644 --- a/io/io/src/TKey.cxx +++ b/io/io/src/TKey.cxx @@ -171,11 +171,16 @@ TKey::TKey(TDirectory* motherDir, const TKey &orig, UShort_t pidOffset) : TNamed /// Constructor called by TDirectoryFile::ReadKeys and by TFile::TFile. /// A TKey object is created to read the keys structure itself. -TKey::TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir) : TNamed() +TKey::TKey(Long64_t pointer, Long64_t nbytes, TDirectory* motherDir) : TNamed() { Build(motherDir, "", pointer); fSeekKey = pointer; + if (nbytes > kMaxInt) { + Fatal("TKey", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("TKey", "Negative byte size: 0x%llx.", nbytes); + } fNbytes = nbytes; fBuffer = new char[nbytes]; keyAbsNumber++; SetUniqueID(keyAbsNumber); @@ -187,12 +192,17 @@ TKey::TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir) : TNamed() /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const char *name, const char *title, const TClass *cl, Int_t nbytes, TDirectory* motherDir) +TKey::TKey(const char *name, const char *title, const TClass *cl, Long64_t nbytes, TDirectory* motherDir) : TNamed(name,title) { Build(motherDir, cl->GetName(), -1); fKeylen = Sizeof(); + if (nbytes > kMaxInt) { + Fatal("TKey", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("TKey", "Negative byte size: 0x%llx.", nbytes); + } fObjlen = nbytes; Create(nbytes); } @@ -203,12 +213,17 @@ TKey::TKey(const char *name, const char *title, const TClass *cl, Int_t nbytes, /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const TString &name, const TString &title, const TClass *cl, Int_t nbytes, TDirectory* motherDir) +TKey::TKey(const TString &name, const TString &title, const TClass *cl, Long64_t nbytes, TDirectory* motherDir) : TNamed(name,title) { Build(motherDir, cl->GetName(), -1); fKeylen = Sizeof(); + if (nbytes > kMaxInt) { + Fatal("TKey", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("TKey", "Negative byte size: 0x%llx.", nbytes); + } fObjlen = nbytes; Create(nbytes); } @@ -219,7 +234,7 @@ TKey::TKey(const TString &name, const TString &title, const TClass *cl, Int_t nb /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const TObject *obj, const char *name, Int_t bufsize, TDirectory* motherDir) +TKey::TKey(const TObject *obj, const char *name, Long64_t bufsize, TDirectory* motherDir) : TNamed(name, obj->GetTitle()) { R__ASSERT(obj); @@ -294,7 +309,7 @@ TKey::TKey(const TObject *obj, const char *name, Int_t bufsize, TDirectory* moth /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const void *obj, const TClass *cl, const char *name, Int_t bufsize, TDirectory *motherDir) : TNamed(name, "") +TKey::TKey(const void *obj, const TClass *cl, const char *name, Long64_t bufsize, TDirectory *motherDir) : TNamed(name, "") { R__ASSERT(obj && cl); @@ -458,7 +473,7 @@ void TKey::Browse(TBrowser *b) /// If externFile!=0, key will be allocated in specified file, otherwise file /// of mother directory will be used. -void TKey::Create(Int_t nbytes, TFile* externFile) +void TKey::Create(Long64_t nbytes, TFile* externFile) { keyAbsNumber++; SetUniqueID(keyAbsNumber); @@ -468,7 +483,11 @@ void TKey::Create(Int_t nbytes, TFile* externFile) Error("Create","Cannot create key without file"); return; } - + if (nbytes > kMaxInt - fKeylen) { + Fatal("Create", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("Create", "Negative byte size: 0x%llx.", nbytes); + } Int_t nsize = nbytes + fKeylen; TList *lfree = f->GetListOfFree(); TFree *f1 = (TFree*)lfree->First(); diff --git a/io/io/src/TMapFile.cxx b/io/io/src/TMapFile.cxx index bbb601384114c..fa04ecd592ba7 100644 --- a/io/io/src/TMapFile.cxx +++ b/io/io/src/TMapFile.cxx @@ -1124,7 +1124,7 @@ void TMapFile::ls(Option_t *) const //////////////////////////////////////////////////////////////////////////////// /// Increment statistics for buffer sizes of objects in this file. -void TMapFile::SumBuffer(Int_t bufsize) +void TMapFile::SumBuffer(Long64_t bufsize) { fWritten++; fSumBuffer += bufsize; diff --git a/io/sql/inc/TSQLFile.h b/io/sql/inc/TSQLFile.h index 6212462db8621..6c43069189b1d 100644 --- a/io/sql/inc/TSQLFile.h +++ b/io/sql/inc/TSQLFile.h @@ -205,8 +205,8 @@ class TSQLFile final : public TFile { void StopLogFile(); // *MENU* void Close(Option_t *option = "") final; // *MENU* - TKey *CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize) final; - TKey *CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t bufsize) final; + TKey *CreateKey(TDirectory *mother, const TObject *obj, const char *name, Long64_t bufsize) final; + TKey *CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Long64_t bufsize) final; void DrawMap(const char * = "*", Option_t * = "") final {} void FillBuffer(char *&) final {} void Flush() final {} @@ -245,8 +245,8 @@ class TSQLFile final : public TFile { Int_t Sizeof() const final { return 0; } Bool_t WriteBuffer(const char *, Int_t) final { return kFALSE; } - Int_t Write(const char * = nullptr, Int_t = 0, Int_t = 0) final { return 0; } - Int_t Write(const char * = nullptr, Int_t = 0, Int_t = 0) const final { return 0; } + Int_t Write(const char * = nullptr, Int_t = 0, Long64_t = 0) final { return 0; } + Int_t Write(const char * = nullptr, Int_t = 0, Long64_t = 0) const final { return 0; } void WriteFree() final {} void WriteHeader() final; void WriteStreamerInfo() final; diff --git a/io/sql/src/TSQLFile.cxx b/io/sql/src/TSQLFile.cxx index f51fe01cc657c..3213e1b178936 100644 --- a/io/sql/src/TSQLFile.cxx +++ b/io/sql/src/TSQLFile.cxx @@ -762,7 +762,7 @@ Int_t TSQLFile::ReOpen(Option_t *mode) //////////////////////////////////////////////////////////////////////////////// /// create SQL key, which will store object in data base -TKey *TSQLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t) +TKey *TSQLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Long64_t) { return new TKeySQL(mother, obj, name); } @@ -770,7 +770,7 @@ TKey *TSQLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *na //////////////////////////////////////////////////////////////////////////////// /// create SQL key, which will store object in data base -TKey *TSQLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t) +TKey *TSQLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Long64_t) { return new TKeySQL(mother, obj, cl, name); } diff --git a/io/xml/inc/TXMLFile.h b/io/xml/inc/TXMLFile.h index 12cbc41de4571..346b5833517e8 100644 --- a/io/xml/inc/TXMLFile.h +++ b/io/xml/inc/TXMLFile.h @@ -53,8 +53,8 @@ class TXMLFile final : public TFile, public TXMLSetup { ~TXMLFile() override; void Close(Option_t *option = "") final; // *MENU* - TKey *CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize) final; - TKey *CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t bufsize) final; + TKey *CreateKey(TDirectory *mother, const TObject *obj, const char *name, Long64_t bufsize) final; + TKey *CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Long64_t bufsize) final; void DrawMap(const char * = "*", Option_t * = "") final {} void FillBuffer(char *&) final {} void Flush() final {} @@ -91,8 +91,8 @@ class TXMLFile final : public TFile, public TXMLSetup { Int_t Sizeof() const final { return 0; } Bool_t WriteBuffer(const char *, Int_t) final { return kFALSE; } - Int_t Write(const char * = nullptr, Int_t = 0, Int_t = 0) final { return 0; } - Int_t Write(const char * = nullptr, Int_t = 0, Int_t = 0) const final { return 0; } + Int_t Write(const char * = nullptr, Int_t = 0, Long64_t = 0) final { return 0; } + Int_t Write(const char * = nullptr, Int_t = 0, Long64_t = 0) const final { return 0; } void WriteFree() final {} void WriteHeader() final {} void WriteStreamerInfo() final; diff --git a/io/xml/src/TXMLFile.cxx b/io/xml/src/TXMLFile.cxx index 631f4e963ee34..658c57baa1b6e 100644 --- a/io/xml/src/TXMLFile.cxx +++ b/io/xml/src/TXMLFile.cxx @@ -404,7 +404,7 @@ Int_t TXMLFile::ReOpen(Option_t *mode) //////////////////////////////////////////////////////////////////////////////// /// create XML key, which will store object in xml structures -TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t) +TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Long64_t) { return new TKeyXML(mother, ++fKeyCounter, obj, name); } @@ -412,7 +412,7 @@ TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *na //////////////////////////////////////////////////////////////////////////////// /// create XML key, which will store object in xml structures -TKey *TXMLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t) +TKey *TXMLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Long64_t) { return new TKeyXML(mother, ++fKeyCounter, obj, cl, name); } diff --git a/main/src/h2root.cxx b/main/src/h2root.cxx index b839c9d8319b4..62076d196abee 100644 --- a/main/src/h2root.cxx +++ b/main/src/h2root.cxx @@ -252,7 +252,7 @@ extern void convert_cwn(Int_t id); extern void convert_rwn(Int_t id); Int_t golower = 1; -Int_t bufsize = 64000; +Long64_t bufsize = 64000; Int_t optcwn = 1; int main(int argc, char **argv) { @@ -280,7 +280,7 @@ int main(int argc, char **argv) optcwn = atoi(argv[7]); } if (argc > 6) { - bufsize = atoi(argv[6]); + bufsize = atol(argv[6]); } if (argc > 5) { record_size = atoi(argv[5]); diff --git a/net/net/inc/TMessage.h b/net/net/inc/TMessage.h index 90f4f377d1577..f8b964d925df3 100644 --- a/net/net/inc/TMessage.h +++ b/net/net/inc/TMessage.h @@ -62,11 +62,11 @@ friend class TXSocket; enum EStatusBits { kIsOwnerComp = BIT(19) // if TMessage owns fBufComp }; - TMessage(void *buf, Int_t bufsize, Bool_t adopt = kTRUE); // only called by T(P)Socket::Recv() + TMessage(void *buf, Long64_t bufsize, Bool_t adopt = kTRUE); // only called by T(P)Socket::Recv() void SetLength() const; // only called by T(P)Socket::Send() public: - TMessage(UInt_t what = kMESS_ANY, Int_t bufsize = TBuffer::kInitialSize); + TMessage(UInt_t what = kMESS_ANY, Long64_t bufsize = TBuffer::kInitialSize); virtual ~TMessage(); void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override; diff --git a/net/net/inc/TParallelMergingFile.h b/net/net/inc/TParallelMergingFile.h index 8f15d7ccee07c..fca3dc1652b8f 100644 --- a/net/net/inc/TParallelMergingFile.h +++ b/net/net/inc/TParallelMergingFile.h @@ -51,8 +51,8 @@ class TParallelMergingFile : public TMemFile void Close(Option_t *option="") override; Bool_t UploadAndReset(); - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override; - Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) const override; void WriteStreamerInfo() override; Int_t GetServerIdx() const { return fServerIdx; } diff --git a/net/net/src/TMessage.cxx b/net/net/src/TMessage.cxx index de34e427a5a3d..d2a2a0c6c3833 100644 --- a/net/net/src/TMessage.cxx +++ b/net/net/src/TMessage.cxx @@ -42,7 +42,7 @@ Bool_t TMessage::fgEvolution = kFALSE; /// the message will be compressed in TSocket using the zip algorithm /// (only if message is > 256 bytes). -TMessage::TMessage(UInt_t what, Int_t bufsize) : +TMessage::TMessage(UInt_t what, Long64_t bufsize) : TBufferFile(TBuffer::kWrite, bufsize + 2*sizeof(UInt_t)), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal) { @@ -67,7 +67,7 @@ TMessage::TMessage(UInt_t what, Int_t bufsize) : /// Create a TMessage object for reading objects. The objects will be /// read from buf. Use the What() method to get the message type. -TMessage::TMessage(void *buf, Int_t bufsize, Bool_t adopt) : TBufferFile(TBuffer::kRead, bufsize, buf, adopt), +TMessage::TMessage(void *buf, Long64_t bufsize, Bool_t adopt) : TBufferFile(TBuffer::kRead, bufsize, buf, adopt), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal) { // skip space at the beginning of the message reserved for the message length diff --git a/net/net/src/TParallelMergingFile.cxx b/net/net/src/TParallelMergingFile.cxx index 894a093578611..a8253521f9f3b 100644 --- a/net/net/src/TParallelMergingFile.cxx +++ b/net/net/src/TParallelMergingFile.cxx @@ -175,7 +175,7 @@ Bool_t TParallelMergingFile::UploadAndReset() /// The linked list of FREE segments is written. /// The file header is written (bytes 1->fBEGIN). -Int_t TParallelMergingFile::Write(const char *, Int_t opt, Int_t bufsize) +Int_t TParallelMergingFile::Write(const char *, Int_t opt, Long64_t bufsize) { Int_t nbytes = TMemFile::Write(0,opt,bufsize); if (nbytes) { @@ -187,7 +187,7 @@ Int_t TParallelMergingFile::Write(const char *, Int_t opt, Int_t bufsize) //////////////////////////////////////////////////////////////////////////////// /// One can not save a const TDirectory object. -Int_t TParallelMergingFile::Write(const char *n, Int_t opt, Int_t bufsize) const +Int_t TParallelMergingFile::Write(const char *n, Int_t opt, Long64_t bufsize) const { Error("Write const","A const TFile object should not be saved. We try to proceed anyway."); return const_cast(this)->Write(n, opt, bufsize); diff --git a/roottest/root/meta/MemberComments.ref b/roottest/root/meta/MemberComments.ref index 8400913ce23c6..eff28b41cf151 100644 --- a/roottest/root/meta/MemberComments.ref +++ b/roottest/root/meta/MemberComments.ref @@ -538,9 +538,9 @@ OBJ: TList TList Doubly linked list : 0 OBJ: TMethod Warning : 0 void TObject::Warning(const char* method, const char* msgfmt,...) const OBJ: TMethod Write : 0 - Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) + Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) OBJ: TMethod Write : 0 - Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) const + Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const OBJ: TMethod ls : 0 void TLine::ls(Option_t* option = "") const OBJ: TMethod ls : 0 diff --git a/roottest/root/meta/MemberComments_win32.ref b/roottest/root/meta/MemberComments_win32.ref index 0e757f7949501..ef6188770304b 100644 --- a/roottest/root/meta/MemberComments_win32.ref +++ b/roottest/root/meta/MemberComments_win32.ref @@ -538,9 +538,9 @@ OBJ: TList TList Doubly linked list : 0 OBJ: TMethod Warning : 0 void TObject::Warning(const char* method, const char* msgfmt,...) const OBJ: TMethod Write : 0 - Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) + Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) OBJ: TMethod Write : 0 - Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) const + Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const OBJ: TMethod ls : 0 void TLine::ls(Option_t* option = "") const OBJ: TMethod ls : 0 diff --git a/roottest/root/meta/MemberComments_win64.ref b/roottest/root/meta/MemberComments_win64.ref index 0e757f7949501..ef6188770304b 100644 --- a/roottest/root/meta/MemberComments_win64.ref +++ b/roottest/root/meta/MemberComments_win64.ref @@ -538,9 +538,9 @@ OBJ: TList TList Doubly linked list : 0 OBJ: TMethod Warning : 0 void TObject::Warning(const char* method, const char* msgfmt,...) const OBJ: TMethod Write : 0 - Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) + Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) OBJ: TMethod Write : 0 - Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) const + Int_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const OBJ: TMethod ls : 0 void TLine::ls(Option_t* option = "") const OBJ: TMethod ls : 0 diff --git a/tree/dataframe/src/RDFSnapshotHelpers.cxx b/tree/dataframe/src/RDFSnapshotHelpers.cxx index 3958c43f7e1e1..0c62f1e8ee3a8 100644 --- a/tree/dataframe/src/RDFSnapshotHelpers.cxx +++ b/tree/dataframe/src/RDFSnapshotHelpers.cxx @@ -196,7 +196,7 @@ void CreateFundamentalTypeBranch(TTree &outputTree, RBranchData &bd, void *value { // Logic taken from // TTree::BranchImpRef( - // const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Int_t bufsize, Int_t splitlevel) + // const char *branchname, TClass *ptrClass, EDataType datatype, void *addobj, Long64_t bufsize, Int_t splitlevel) auto rootTypeChar = ROOT::Internal::RDF::TypeID2ROOTTypeName(*bd.fInputTypeID); if (rootTypeChar == ' ') { Warning("Snapshot", diff --git a/tree/ntuple/src/RFieldMeta.cxx b/tree/ntuple/src/RFieldMeta.cxx index f524169362970..90a67a2ce9fef 100644 --- a/tree/ntuple/src/RFieldMeta.cxx +++ b/tree/ntuple/src/RFieldMeta.cxx @@ -993,7 +993,7 @@ class TBufferRecStreamer : public TBufferFile { RCallbackStreamerInfo fCallbackStreamerInfo; public: - TBufferRecStreamer(TBuffer::EMode mode, Int_t bufsize, RCallbackStreamerInfo callbackStreamerInfo) + TBufferRecStreamer(TBuffer::EMode mode, Long64_t bufsize, RCallbackStreamerInfo callbackStreamerInfo) : TBufferFile(mode, bufsize), fCallbackStreamerInfo(callbackStreamerInfo) { } diff --git a/tree/tree/inc/TBranch.h b/tree/tree/inc/TBranch.h index a74cd85c01d15..2701ae46cad70 100644 --- a/tree/tree/inc/TBranch.h +++ b/tree/tree/inc/TBranch.h @@ -191,8 +191,8 @@ class TBranch : public TNamed, public TAttFill { public: TBranch(); - TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); - TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Int_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Long64_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Long64_t basketsize=32000, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); ~TBranch() override; virtual void AddBasket(TBasket &b, bool ondisk, Long64_t startEntry); @@ -270,7 +270,7 @@ class TBranch : public TNamed, public TAttFill { virtual void SetAddress(void *add); virtual void SetObject(void *objadd); virtual void SetAutoDelete(bool autodel=true); - virtual void SetBasketSize(Int_t bufsize); + virtual void SetBasketSize(Long64_t bufsize); virtual void SetBufferAddress(TBuffer *entryBuffer); void SetCompressionAlgorithm(Int_t algorithm = ROOT::RCompressionSetting::EAlgorithm::kUseGlobal); void SetCompressionLevel(Int_t level = ROOT::RCompressionSetting::ELevel::kUseMin); diff --git a/tree/tree/inc/TBranchClones.h b/tree/tree/inc/TBranchClones.h index 6154609a91906..4f57f1587aa27 100644 --- a/tree/tree/inc/TBranchClones.h +++ b/tree/tree/inc/TBranchClones.h @@ -38,13 +38,13 @@ class TBranchClones : public TBranch { friend class TTreeCloner; - void Init(TTree *tree, TBranch *parent, const char *name, void *clonesaddress, Int_t basketsize=32000,Int_t compress=-1, Int_t splitlevel=1); + void Init(TTree *tree, TBranch *parent, const char *name, void *clonesaddress, Long64_t basketsize=32000,Int_t compress=-1, Int_t splitlevel=1); Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; public: TBranchClones(); - TBranchClones(TTree *tree, const char *name, void *clonesaddress, Int_t basketsize=32000,Int_t compress=-1, Int_t splitlevel=1); - TBranchClones(TBranch *parent, const char *name, void *clonesaddress, Int_t basketsize=32000,Int_t compress=-1, Int_t splitlevel=1); + TBranchClones(TTree *tree, const char *name, void *clonesaddress, Long64_t basketsize=32000,Int_t compress=-1, Int_t splitlevel=1); + TBranchClones(TBranch *parent, const char *name, void *clonesaddress, Long64_t basketsize=32000,Int_t compress=-1, Int_t splitlevel=1); ~TBranchClones() override; void Browse(TBrowser *b) override; @@ -57,7 +57,7 @@ class TBranchClones : public TBranch { void Reset(Option_t *option="") override; void ResetAfterMerge(TFileMergeInfo *) override; void SetAddress(void *add) override; - void SetBasketSize(Int_t bufsize) override; + void SetBasketSize(Long64_t bufsize) override; void SetTree(TTree *tree) override { fTree = tree; fBranchCount->SetTree(tree); } void UpdateFile() override; diff --git a/tree/tree/inc/TBranchElement.h b/tree/tree/inc/TBranchElement.h index 39c762041c414..4a451cc32bf53 100644 --- a/tree/tree/inc/TBranchElement.h +++ b/tree/tree/inc/TBranchElement.h @@ -122,12 +122,12 @@ class TBranchElement : public TBranch { void SetupInfo(); void SetBranchCount(TBranchElement* bre); void SetBranchCount2(TBranchElement* bre) { fBranchCount2 = bre; } - Int_t Unroll(const char* name, TClass* cltop, TClass* cl, char* ptr, Int_t basketsize, Int_t splitlevel, Int_t btype); + Int_t Unroll(const char* name, TClass* cltop, TClass* cl, char* ptr, Long64_t basketsize, Int_t splitlevel, Int_t btype); inline void ValidateAddress() const; - void Init(TTree *tree, TBranch *parent, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0); - void Init(TTree *tree, TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); - void Init(TTree *tree, TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + void Init(TTree *tree, TBranch *parent, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0); + void Init(TTree *tree, TBranch *parent, const char* name, TClonesArray* clones, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + void Init(TTree *tree, TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); void SetActionSequence(TClass *originalClass, TStreamerInfo *localInfo, TStreamerInfoActions::TActionSequence::SequenceGetter_t create, TStreamerInfoActions::TActionSequence *&actionSequence); void ReadLeavesImpl(TBuffer& b); @@ -166,12 +166,12 @@ class TBranchElement : public TBranch { // Public Interface. public: TBranchElement(); - TBranchElement(TTree *tree, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0); - TBranchElement(TTree *tree, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); - TBranchElement(TTree *tree, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); - TBranchElement(TBranch *parent, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0); - TBranchElement(TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); - TBranchElement(TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + TBranchElement(TTree *tree, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0); + TBranchElement(TTree *tree, const char* name, TClonesArray* clones, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + TBranchElement(TTree *tree, const char* name, TVirtualCollectionProxy* cont, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + TBranchElement(TBranch *parent, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0); + TBranchElement(TBranch *parent, const char* name, TClonesArray* clones, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); + TBranchElement(TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Long64_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit); ~TBranchElement() override; @@ -222,7 +222,7 @@ class TBranchElement : public TBranch { void SetAddress(void* addobj) override; bool SetMakeClass(bool decomposeObj = true) override; void SetObject(void *objadd) override; - void SetBasketSize(Int_t bufsize) override; + void SetBasketSize(Long64_t bufsize) override; virtual void SetBranchFolder() { SetBit(kBranchFolder); } virtual void SetClassName(const char* name) { fClassName = name; } void SetOffset(Int_t offset) override; @@ -233,7 +233,7 @@ class TBranchElement : public TBranch { void SetupAddresses() override; virtual void SetType(Int_t btype) { fType = btype; } void UpdateFile() override; - void Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, char* objptr, Int_t bufsize, Int_t splitlevel); + void Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, char* objptr, Long64_t bufsize, Int_t splitlevel); enum EBranchElementType { kLeafNode = 0, diff --git a/tree/tree/inc/TBranchObject.h b/tree/tree/inc/TBranchObject.h index 75dbbf96e5cf2..586b085490b23 100644 --- a/tree/tree/inc/TBranchObject.h +++ b/tree/tree/inc/TBranchObject.h @@ -42,12 +42,12 @@ class TBranchObject : public TBranch { TString fClassName; ///< Class name of referenced object TObject *fOldObject; ///< !Pointer to old object - void Init(TTree *tree, TBranch *parent, const char *name, const char *classname, void *addobj, Int_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr); + void Init(TTree *tree, TBranch *parent, const char *name, const char *classname, void *addobj, Long64_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr); public: TBranchObject(); - TBranchObject(TBranch *parent, const char *name, const char *classname, void *addobj, Int_t basketsize=32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit, bool isptrptr = true); - TBranchObject(TTree *tree, const char *name, const char *classname, void *addobj, Int_t basketsize=32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit, bool isptrptr = true); + TBranchObject(TBranch *parent, const char *name, const char *classname, void *addobj, Long64_t basketsize=32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit, bool isptrptr = true); + TBranchObject(TTree *tree, const char *name, const char *classname, void *addobj, Long64_t basketsize=32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit, bool isptrptr = true); ~TBranchObject() override; void Browse(TBrowser *b) override; @@ -61,7 +61,7 @@ class TBranchObject : public TBranch { void ResetAfterMerge(TFileMergeInfo *) override; void SetAddress(void *addobj) override; void SetAutoDelete(bool autodel=true) override; - void SetBasketSize(Int_t bufsize) override; + void SetBasketSize(Long64_t bufsize) override; void SetupAddresses() override; void UpdateAddress() override; diff --git a/tree/tree/inc/TBranchSTL.h b/tree/tree/inc/TBranchSTL.h index 9afff67341619..0ec1442edd6bc 100644 --- a/tree/tree/inc/TBranchSTL.h +++ b/tree/tree/inc/TBranchSTL.h @@ -24,10 +24,10 @@ class TBranchSTL: public TBranch { TBranchSTL(); TBranchSTL( TTree* tree, const char* name, TVirtualCollectionProxy* collProxy, - Int_t bufsize, Int_t splitlevel ); + Long64_t bufsize, Int_t splitlevel ); TBranchSTL( TBranch* parent, const char* name, TVirtualCollectionProxy* collProxy, - Int_t bufsize, Int_t splitlevel, + Long64_t bufsize, Int_t splitlevel, TStreamerInfo* info, Int_t id ); ~TBranchSTL() override; void Browse( TBrowser *b ) override; diff --git a/tree/tree/inc/TBufferSQL.h b/tree/tree/inc/TBufferSQL.h index eff029fa978b8..7813147842999 100644 --- a/tree/tree/inc/TBufferSQL.h +++ b/tree/tree/inc/TBufferSQL.h @@ -43,8 +43,8 @@ class TBufferSQL final : public TBufferFile { public: TBufferSQL(); TBufferSQL(TBuffer::EMode mode, std::vector *vc, TString *insert_query, TSQLRow **rowPtr); - TBufferSQL(TBuffer::EMode mode, Int_t bufsiz, std::vector *vc, TString *insert_query, TSQLRow **rowPtr); - TBufferSQL(TBuffer::EMode mode, Int_t bufsiz, std::vector *vc, TString *insert_query, TSQLRow **rowPtr,void *buf, bool adopt = true); + TBufferSQL(TBuffer::EMode mode, Long64_t bufsiz, std::vector *vc, TString *insert_query, TSQLRow **rowPtr); + TBufferSQL(TBuffer::EMode mode, Long64_t bufsiz, std::vector *vc, TString *insert_query, TSQLRow **rowPtr,void *buf, bool adopt = true); ~TBufferSQL() override; void ResetOffset(); diff --git a/tree/tree/inc/TChain.h b/tree/tree/inc/TChain.h index 8d362124ec261..24c20e8713858 100644 --- a/tree/tree/inc/TChain.h +++ b/tree/tree/inc/TChain.h @@ -132,7 +132,7 @@ class TChain : public TTree { virtual Long64_t Merge(const char *name, Option_t *option = ""); Long64_t Merge(TCollection *list, Option_t *option = "") override; Long64_t Merge(TCollection *list, TFileMergeInfo *info) override; - virtual Long64_t Merge(TFile *file, Int_t basketsize, Option_t *option=""); + virtual Long64_t Merge(TFile *file, Long64_t basketsize, Option_t *option=""); void Print(Option_t *option="") const override; Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0) override; // *MENU* Long64_t Process(TSelector* selector, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) override; diff --git a/tree/tree/inc/TNtuple.h b/tree/tree/inc/TNtuple.h index 3794097b6bb04..527eb4af63ffb 100644 --- a/tree/tree/inc/TNtuple.h +++ b/tree/tree/inc/TNtuple.h @@ -39,7 +39,7 @@ class TNtuple : public TTree { public: TNtuple(); - TNtuple(const char *name,const char *title, const char *varlist, Int_t bufsize=32000); + TNtuple(const char *name,const char *title, const char *varlist, Long64_t bufsize=32000); ~TNtuple() override; void Browse(TBrowser *b) override; diff --git a/tree/tree/inc/TNtupleD.h b/tree/tree/inc/TNtupleD.h index 63aded6eae49e..cac5381597e05 100644 --- a/tree/tree/inc/TNtupleD.h +++ b/tree/tree/inc/TNtupleD.h @@ -39,7 +39,7 @@ class TNtupleD : public TTree { public: TNtupleD(); - TNtupleD(const char *name,const char *title, const char *varlist, Int_t bufsize=32000); + TNtupleD(const char *name,const char *title, const char *varlist, Long64_t bufsize=32000); ~TNtupleD() override; void Browse(TBrowser *b) override; diff --git a/tree/tree/inc/TTree.h b/tree/tree/inc/TTree.h index 7609529df00fe..69cfe992749eb 100644 --- a/tree/tree/inc/TTree.h +++ b/tree/tree/inc/TTree.h @@ -81,8 +81,8 @@ namespace ROOT::Internal::TreeUtils { void TBranch__SetTree(TTree *tree, TObjArray &branches); TBranch *CallBranchImpRef(TTree &tree, const char *branchname, TClass *ptrClass, EDataType datatype, void *addobj, - Int_t bufsize = 32000, Int_t splitlevel = 99); -TBranch *CallBranchImp(TTree &tree, const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize = 32000, + Long64_t bufsize = 32000, Int_t splitlevel = 99); +TBranch *CallBranchImp(TTree &tree, const char *branchname, TClass *ptrClass, void *addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99); } @@ -187,19 +187,19 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker protected: friend TBranch *ROOT::Internal::TreeUtils::CallBranchImpRef(TTree &tree, const char *branchname, TClass *ptrClass, - EDataType datatype, void *addobj, Int_t bufsize, + EDataType datatype, void *addobj, Long64_t bufsize, Int_t splitlevel); friend TBranch *ROOT::Internal::TreeUtils::CallBranchImp(TTree &tree, const char *branchname, TClass *ptrClass, - void *addobj, Int_t bufsize, Int_t splitlevel); + void *addobj, Long64_t bufsize, Int_t splitlevel); virtual void KeepCircular(); - virtual TBranch *BranchImp(const char* branchname, const char* classname, TClass* ptrClass, void* addobj, Int_t bufsize, Int_t splitlevel); - virtual TBranch *BranchImp(const char* branchname, TClass* ptrClass, void* addobj, Int_t bufsize, Int_t splitlevel); - virtual TBranch *BranchImpRef(const char* branchname, const char* classname, TClass* ptrClass, void* addobj, Int_t bufsize, Int_t splitlevel); - virtual TBranch *BranchImpRef(const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Int_t bufsize, Int_t splitlevel); - virtual TBranch *BranchImpArr(const char* branchname, EDataType datatype, std::size_t N, void* addobj, Int_t bufsize, Int_t splitlevel); + virtual TBranch *BranchImp(const char* branchname, const char* classname, TClass* ptrClass, void* addobj, Long64_t bufsize, Int_t splitlevel); + virtual TBranch *BranchImp(const char* branchname, TClass* ptrClass, void* addobj, Long64_t bufsize, Int_t splitlevel); + virtual TBranch *BranchImpRef(const char* branchname, const char* classname, TClass* ptrClass, void* addobj, Long64_t bufsize, Int_t splitlevel); + virtual TBranch *BranchImpRef(const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Long64_t bufsize, Int_t splitlevel); + virtual TBranch *BranchImpArr(const char* branchname, EDataType datatype, std::size_t N, void* addobj, Long64_t bufsize, Int_t splitlevel); virtual Int_t CheckBranchAddressType(TBranch* branch, TClass* ptrClass, EDataType datatype, bool ptr); - virtual TBranch *BronchExec(const char* name, const char* classname, void* addobj, bool isptrptr, Int_t bufsize, Int_t splitlevel); - friend TBranch *TTreeBranchImpRef(TTree *tree, const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Int_t bufsize, Int_t splitlevel); + virtual TBranch *BronchExec(const char* name, const char* classname, void* addobj, bool isptrptr, Long64_t bufsize, Int_t splitlevel); + friend TBranch *TTreeBranchImpRef(TTree *tree, const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Long64_t bufsize, Int_t splitlevel); Int_t SetBranchAddressImp(TBranch *branch, void* addr, TBranch** ptr); virtual TLeaf *GetLeafImpl(const char* branchname, const char* leafname); @@ -386,7 +386,7 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker /// A small value for bufsize is beneficial if entries in the Tree are accessed randomly and the Tree is in split mode. /// \param[in] splitlevel If T is a class or struct and splitlevel > 0, the members of the object are serialised as separate branches. /// \return Pointer to the TBranch that was created. The branch is owned by the tree. - template TBranch *Branch(const char* name, T* obj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, T* obj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { return BranchImpRef(name, TClass::GetClass(), TDataType::GetType(typeid(T)), obj, bufsize, splitlevel); } @@ -403,42 +403,42 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker /// A small value for bufsize is beneficial if entries in the Tree are accessed randomly and the Tree is in split mode. /// \param[in] splitlevel If T is a class or struct and splitlevel > 0, the members of the object are serialised as separate branches. /// \return Pointer to the TBranch that was created. The branch is owned by the tree. - template TBranch *Branch(const char* name, T** addobj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, T** addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { return BranchImp(name, TClass::GetClass(), addobj, bufsize, splitlevel); } - virtual Int_t Branch(TCollection* list, Int_t bufsize = 32000, Int_t splitlevel = 99, const char* name = ""); - virtual Int_t Branch(TList* list, Int_t bufsize = 32000, Int_t splitlevel = 99); - virtual Int_t Branch(const char* folder, Int_t bufsize = 32000, Int_t splitlevel = 99); - virtual TBranch *Branch(const char* name, void* address, const char* leaflist, Int_t bufsize = 32000); - TBranch *Branch(const char* name, char* address, const char* leaflist, Int_t bufsize = 32000) + virtual Int_t Branch(TCollection* list, Long64_t bufsize = 32000, Int_t splitlevel = 99, const char* name = ""); + virtual Int_t Branch(TList* list, Long64_t bufsize = 32000, Int_t splitlevel = 99); + virtual Int_t Branch(const char* folder, Long64_t bufsize = 32000, Int_t splitlevel = 99); + virtual TBranch *Branch(const char* name, void* address, const char* leaflist, Long64_t bufsize = 32000); + TBranch *Branch(const char* name, char* address, const char* leaflist, Long64_t bufsize = 32000) { // Overload to avoid confusion between this signature and the template instance. return Branch(name,(void*)address,leaflist,bufsize); } - TBranch *Branch(const char* name, Longptr_t address, const char* leaflist, Int_t bufsize = 32000) + TBranch *Branch(const char* name, Longptr_t address, const char* leaflist, Long64_t bufsize = 32000) { // Overload to avoid confusion between this signature and the template instance. return Branch(name,(void*)address,leaflist,bufsize); } - TBranch *Branch(const char* name, int address, const char* leaflist, Int_t bufsize = 32000) + TBranch *Branch(const char* name, int address, const char* leaflist, Long64_t bufsize = 32000) { // Overload to avoid confusion between this signature and the template instance. return Branch(name,(void*)(Longptr_t)address,leaflist,bufsize); } - virtual TBranch *Branch(const char* name, const char* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 99); - template TBranch *Branch(const char* name, const char* classname, T* obj, Int_t bufsize = 32000, Int_t splitlevel = 99) + virtual TBranch *Branch(const char* name, const char* classname, void* addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99); + template TBranch *Branch(const char* name, const char* classname, T* obj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { // See BranchImpRed for details. Here we __ignore return BranchImpRef(name, classname, TClass::GetClass(), obj, bufsize, splitlevel); } - template TBranch *Branch(const char* name, const char* classname, T** addobj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, const char* classname, T** addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { // See BranchImp for details return BranchImp(name, classname, TClass::GetClass(), addobj, bufsize, splitlevel); } - template TBranch *Branch(const char* name, std::array *obj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, std::array *obj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { TClass *cl = TClass::GetClass(); if (cl) { @@ -449,8 +449,8 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker } return BranchImpArr(name, TDataType::GetType(typeid(T)), N, obj, bufsize, splitlevel); } - virtual TBranch *Bronch(const char* name, const char* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 99); - virtual TBranch *BranchOld(const char* name, const char* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 1); + virtual TBranch *Bronch(const char* name, const char* classname, void* addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99); + virtual TBranch *BranchOld(const char* name, const char* classname, void* addobj, Long64_t bufsize = 32000, Int_t splitlevel = 1); virtual TBranch *BranchRef(); void Browse(TBrowser*) override; virtual Int_t BuildIndex(const char *majorname, const char *minorname = "0", bool long64major = false, bool long64minor = false); @@ -660,7 +660,7 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker virtual bool SetAlias(const char* aliasName, const char* aliasFormula); virtual void SetAutoSave(Long64_t autos = -300000000); virtual void SetAutoFlush(Long64_t autof = -30000000); - virtual void SetBasketSize(const char* bname, Int_t buffsize = 16000); + virtual void SetBasketSize(const char* bname, Long64_t bufsize = 16000); virtual Int_t SetBranchAddress(const char *bname,void *add, TBranch **ptr = nullptr); virtual Int_t SetBranchAddress(const char *bname,void *add, TClass *realClass, EDataType datatype, bool isptr); virtual Int_t SetBranchAddress(const char *bname,void *add, TBranch **ptr, TClass *realClass, EDataType datatype, bool isptr); @@ -743,8 +743,8 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker virtual Int_t StopCacheLearningPhase(); virtual Int_t UnbinnedFit(const char* funcname, const char* varexp, const char* selection = "", Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0); void UseCurrentStyle() override; - Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override; - Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override; + Int_t Write(const char *name=nullptr, Int_t option=0, Long64_t bufsize=0) override; + Int_t Write(const char *name=nullptr, Int_t option=0, Long64_t bufsize=0) const override; ClassDefOverride(TTree, 20) // Tree descriptor (the main ROOT I/O class) }; diff --git a/tree/tree/inc/TTreeCache.h b/tree/tree/inc/TTreeCache.h index 9b8621c3d7be7..dce5fddc0a125 100644 --- a/tree/tree/inc/TTreeCache.h +++ b/tree/tree/inc/TTreeCache.h @@ -127,7 +127,7 @@ class TTreeCache : public TFileCacheRead { public: TTreeCache(); - TTreeCache(TTree *tree, Int_t bufsize=0); + TTreeCache(TTree *tree, Long64_t bufsize=0); ~TTreeCache() override; Int_t AddBranch(TBranch *b, bool subgbranches = false) override; Int_t AddBranch(const char *branch, bool subbranches = false) override; @@ -162,7 +162,7 @@ class TTreeCache : public TFileCacheRead { virtual void ResetCache(); void ResetMissCache(); // Reset the miss cache. void SetAutoCreated(bool val) {fAutoCreated = val;} - Int_t SetBufferSize(Long64_t buffersize) override; + Int_t SetBufferSize(Long64_t bufsize) override; virtual void SetEntryRange(Long64_t emin, Long64_t emax); void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect) override; virtual void SetLearnPrefill(EPrefillType type = kNoPrefill); diff --git a/tree/tree/inc/TTreeCacheUnzip.h b/tree/tree/inc/TTreeCacheUnzip.h index 28177e2ca61fb..71553d86be09d 100644 --- a/tree/tree/inc/TTreeCacheUnzip.h +++ b/tree/tree/inc/TTreeCacheUnzip.h @@ -117,7 +117,7 @@ class TTreeCacheUnzip : public TTreeCache { public: TTreeCacheUnzip(); - TTreeCacheUnzip(TTree *tree, Int_t buffersize=0); + TTreeCacheUnzip(TTree *tree, Long64_t buffersize=0); ~TTreeCacheUnzip() override; Int_t AddBranch(TBranch *b, bool subbranches = false) override; diff --git a/tree/tree/inc/TTreeSQL.h b/tree/tree/inc/TTreeSQL.h index 5fedf6d5d64bb..b51051b1bf63b 100644 --- a/tree/tree/inc/TTreeSQL.h +++ b/tree/tree/inc/TTreeSQL.h @@ -65,21 +65,21 @@ class TTreeSQL : public TTree { bool CreateTable(const TString& table); TBasket *CreateBasket(TBranch * br) override; - TBranch *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override; - TBranch *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override; + TBranch *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Long64_t bufsize, Int_t splitlevel) override; + TBranch *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Long64_t bufsize, Int_t splitlevel) override; public: TTreeSQL(TSQLServer * server, TString DB, const TString& table); ~TTreeSQL() override; - Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="") override; - Int_t Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99) override; - Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99) override; - TBranch *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override; - TBranch *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1) override; - TBranch *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override; + Int_t Branch(TCollection *list, Long64_t bufsize=32000, Int_t splitlevel=99, const char *name="") override; + Int_t Branch(TList *list, Long64_t bufsize=32000, Int_t splitlevel=99) override; + Int_t Branch(const char *folder, Long64_t bufsize=32000, Int_t splitlevel=99) override; + TBranch *Bronch(const char *name, const char *classname, void *addobj, Long64_t bufsize=32000, Int_t splitlevel=99) override; + TBranch *BranchOld(const char *name, const char *classname, void *addobj, Long64_t bufsize=32000, Int_t splitlevel=1) override; + TBranch *Branch(const char *name, const char *classname, void *addobj, Long64_t bufsize=32000, Int_t splitlevel=99) override; - TBranch *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize) override; + TBranch *Branch(const char *name, void *address, const char *leaflist, Long64_t bufsize) override; Int_t Fill() override; Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override; diff --git a/tree/tree/src/TBranch.cxx b/tree/tree/src/TBranch.cxx index a44cf713d1916..6b9d1102625a9 100644 --- a/tree/tree/src/TBranch.cxx +++ b/tree/tree/src/TBranch.cxx @@ -195,7 +195,7 @@ TBranch::TBranch() /// /// Note that this function is invoked by TTree::Branch -TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize, Int_t compress) +TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) : TNamed(name, leaflist) , TAttFill(0, 1001) , fCompress(compress) @@ -239,6 +239,8 @@ TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leafl , fReadLeaves(&TBranch::ReadLeavesImpl) , fFillLeaves(&TBranch::FillLeavesImpl) { + if (basketsize > kMaxInt) + Fatal("TBranch", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); Init(name,leaflist,compress); } @@ -248,7 +250,7 @@ TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leafl /// See documentation for /// TBranch::TBranch(TTree *, const char *, void *, const char *, Int_t, Int_t) -TBranch::TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Int_t basketsize, +TBranch::TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) : TNamed(name, leaflist) , TAttFill(0, 1001) @@ -293,6 +295,8 @@ TBranch::TBranch(TBranch *parent, const char *name, void *address, const char *l , fReadLeaves(&TBranch::ReadLeavesImpl) , fFillLeaves(&TBranch::FillLeavesImpl) { + if (basketsize > kMaxInt) + Fatal("TBranch", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); Init(name,leaflist,compress); } @@ -2738,8 +2742,10 @@ void TBranch::SetAutoDelete(bool autodel) /// Set the basket size /// The function makes sure that the basket size is greater than fEntryOffsetlen -void TBranch::SetBasketSize(Int_t bufsize) +void TBranch::SetBasketSize(Long64_t bufsize) { + if (bufsize > kMaxInt) + Fatal("SetBasketSize", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); Int_t minsize = 100 + fName.Length(); if (bufsize < minsize+fEntryOffsetLen) bufsize = minsize+fEntryOffsetLen; fBasketSize = bufsize; diff --git a/tree/tree/src/TBranchClones.cxx b/tree/tree/src/TBranchClones.cxx index 13c51dbc03278..7909c8cfd75ce 100644 --- a/tree/tree/src/TBranchClones.cxx +++ b/tree/tree/src/TBranchClones.cxx @@ -49,7 +49,7 @@ TBranchClones::TBranchClones() //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBranchClones::TBranchClones(TTree *tree, const char* name, void* pointer, Int_t basketsize, Int_t compress, Int_t splitlevel) +TBranchClones::TBranchClones(TTree *tree, const char* name, void* pointer, Long64_t basketsize, Int_t compress, Int_t splitlevel) : TBranch() , fList(nullptr) , fRead(0) @@ -63,7 +63,7 @@ TBranchClones::TBranchClones(TTree *tree, const char* name, void* pointer, Int_t //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBranchClones::TBranchClones(TBranch *parent, const char* name, void* pointer, Int_t basketsize, Int_t compress, Int_t splitlevel) +TBranchClones::TBranchClones(TBranch *parent, const char* name, void* pointer, Long64_t basketsize, Int_t compress, Int_t splitlevel) : TBranch() , fList(nullptr) , fRead(0) @@ -77,7 +77,7 @@ TBranchClones::TBranchClones(TBranch *parent, const char* name, void* pointer, I //////////////////////////////////////////////////////////////////////////////// /// Initialization (non-virtual, to be called from constructor). -void TBranchClones::Init(TTree *tree, TBranch *parent, const char* name, void* pointer, Int_t basketsize, Int_t compress, Int_t splitlevel) +void TBranchClones::Init(TTree *tree, TBranch *parent, const char* name, void* pointer, Long64_t basketsize, Int_t compress, Int_t splitlevel) { if (tree==nullptr && parent!=nullptr) tree = parent->GetTree(); fTree = tree; @@ -110,6 +110,8 @@ void TBranchClones::Init(TTree *tree, TBranch *parent, const char* name, void* p fSplitLevel = splitlevel; // Create a branch to store the array count. + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); if (basketsize < 100) { basketsize = 100; } @@ -369,7 +371,7 @@ void TBranchClones::SetAddress(void* addr) //////////////////////////////////////////////////////////////////////////////// /// Reset basket size for all sub-branches. -void TBranchClones::SetBasketSize(Int_t bufsize) +void TBranchClones::SetBasketSize(Long64_t bufsize) { TBranch::SetBasketSize(bufsize); diff --git a/tree/tree/src/TBranchElement.cxx b/tree/tree/src/TBranchElement.cxx index a8227be2e1bac..175035d6ef8e9 100644 --- a/tree/tree/src/TBranchElement.cxx +++ b/tree/tree/src/TBranchElement.cxx @@ -209,7 +209,7 @@ TBranchElement::TBranchElement() /// /// If splitlevel > 0 this branch in turn is split into sub-branches. -TBranchElement::TBranchElement(TTree *tree, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype) +TBranchElement::TBranchElement(TTree *tree, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize, Int_t splitlevel, Int_t btype) : TBranch() , fClassName(sinfo->GetName()) , fParentName() @@ -256,7 +256,7 @@ TBranchElement::TBranchElement(TTree *tree, const char* bname, TStreamerInfo* si /// /// If splitlevel > 0 this branch in turn is split into sub-branches. -TBranchElement::TBranchElement(TBranch *parent, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype) +TBranchElement::TBranchElement(TBranch *parent, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize, Int_t splitlevel, Int_t btype) : TBranch() , fClassName(sinfo->GetName()) , fParentName() @@ -301,7 +301,7 @@ TBranchElement::TBranchElement(TBranch *parent, const char* bname, TStreamerInfo /// /// If splitlevel > 0 this branch in turn is split into sub-branches. -void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype) +void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize, Int_t splitlevel, Int_t btype) { TString name(bname); @@ -367,7 +367,8 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea // Make sure the basket is big enough to contain the // entry offset array plus 100 bytes of data. // - + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); if (basketsize < (100 + fEntryOffsetLen)) { basketsize = 100 + fEntryOffsetLen; } @@ -693,7 +694,7 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TTree *tree, const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TTree *tree, const char* bname, TClonesArray* clones, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName("TClonesArray") , fParentName() @@ -720,7 +721,7 @@ TBranchElement::TBranchElement(TTree *tree, const char* bname, TClonesArray* clo /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TBranch *parent, const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TBranch *parent, const char* bname, TClonesArray* clones, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName("TClonesArray") , fParentName() @@ -747,7 +748,7 @@ TBranchElement::TBranchElement(TBranch *parent, const char* bname, TClonesArray* /// /// If splitlevel > 0 this branch in turn is split into sub branches. -void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress) +void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TClonesArray* clones, Long64_t basketsize, Int_t splitlevel, Int_t compress) { fCollProxy = nullptr; fSplitLevel = splitlevel; @@ -848,7 +849,7 @@ void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TClon /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TTree *tree, const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TTree *tree, const char* bname, TVirtualCollectionProxy* cont, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName(cont->GetCollectionClass()->GetName()) , fParentName() @@ -874,7 +875,7 @@ TBranchElement::TBranchElement(TTree *tree, const char* bname, TVirtualCollectio /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName(cont->GetCollectionClass()->GetName()) , fParentName() @@ -900,7 +901,7 @@ TBranchElement::TBranchElement(TBranch *parent, const char* bname, TVirtualColle /// /// If splitlevel > 0 this branch in turn is split into sub branches. -void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress) +void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Long64_t basketsize, Int_t splitlevel, Int_t compress) { fCollProxy = cont->Generate(); TString name( bname ); @@ -945,7 +946,8 @@ void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TVirt fCompress = bfile->GetCompressionSettings(); } } - + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); if (basketsize < 100) { basketsize = 100; } @@ -5574,7 +5576,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) //////////////////////////////////////////////////////////////////////////////// /// Reset the basket size for all sub-branches of this branch element. -void TBranchElement::SetBasketSize(Int_t bufsize) +void TBranchElement::SetBasketSize(Long64_t bufsize) { TBranch::SetBasketSize(bufsize); Int_t nbranches = fBranches.GetEntriesFast(); @@ -6136,7 +6138,7 @@ void TBranchElement::Streamer(TBuffer& R__b) /// This version of Unroll was formerly embedded in TTree::BronchExec /// It is moved here so we can make sure to call SetReadActionSequence. -void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, char* objptr, Int_t bufsize, Int_t splitlevel) +void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, char* objptr, Long64_t bufsize, Int_t splitlevel) { // // Do we have a final dot in our name? @@ -6270,7 +6272,7 @@ void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, /// except for a TObject base class of a class which has the /// can ignore tobject streamer flag set. -Int_t TBranchElement::Unroll(const char* name, TClass* clParent, TClass* cl, char* ptr, Int_t basketsize, Int_t splitlevel, Int_t btype) +Int_t TBranchElement::Unroll(const char* name, TClass* clParent, TClass* cl, char* ptr, Long64_t basketsize, Int_t splitlevel, Int_t btype) { //---------------------------------------------------------------------------- // Handling the case of STL collections of pointers diff --git a/tree/tree/src/TBranchObject.cxx b/tree/tree/src/TBranchObject.cxx index 7f77edee333ee..5f955502ed22c 100644 --- a/tree/tree/src/TBranchObject.cxx +++ b/tree/tree/src/TBranchObject.cxx @@ -46,7 +46,7 @@ TBranchObject::TBranchObject() //////////////////////////////////////////////////////////////////////////////// /// Create a BranchObject. -TBranchObject::TBranchObject(TTree *tree, const char* name, const char* classname, void* addobj, Int_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) +TBranchObject::TBranchObject(TTree *tree, const char* name, const char* classname, void* addobj, Long64_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) : TBranch() { Init(tree,nullptr,name,classname,addobj,basketsize,splitlevel,compress,isptrptr); @@ -55,7 +55,7 @@ TBranchObject::TBranchObject(TTree *tree, const char* name, const char* classnam //////////////////////////////////////////////////////////////////////////////// /// Create a BranchObject. -TBranchObject::TBranchObject(TBranch *parent, const char* name, const char* classname, void* addobj, Int_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) +TBranchObject::TBranchObject(TBranch *parent, const char* name, const char* classname, void* addobj, Long64_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) : TBranch() { Init(nullptr,parent,name,classname,addobj,basketsize,splitlevel,compress,isptrptr); @@ -64,7 +64,7 @@ TBranchObject::TBranchObject(TBranch *parent, const char* name, const char* clas //////////////////////////////////////////////////////////////////////////////// /// Initialization routine (run from the constructor so do not make this function virtual) -void TBranchObject::Init(TTree *tree, TBranch *parent, const char* name, const char* classname, void* addobj, Int_t basketsize, Int_t /*splitlevel*/, Int_t compress, bool isptrptr) +void TBranchObject::Init(TTree *tree, TBranch *parent, const char* name, const char* classname, void* addobj, Long64_t basketsize, Int_t /*splitlevel*/, Int_t compress, bool isptrptr) { if (tree==nullptr && parent!=nullptr) tree = parent->GetTree(); fTree = tree; @@ -113,6 +113,8 @@ void TBranchObject::Init(TTree *tree, TBranch *parent, const char* name, const c if (basketsize < 100) { basketsize = 100; } + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); fBasketSize = basketsize; fAddress = (char*) addobj; fClassName = classname; @@ -527,7 +529,7 @@ void TBranchObject::SetAutoDelete(bool autodel) //////////////////////////////////////////////////////////////////////////////// /// Reset basket size for all subbranches of this branch. -void TBranchObject::SetBasketSize(Int_t bufsize) +void TBranchObject::SetBasketSize(Long64_t bufsize) { TBranch::SetBasketSize(bufsize); diff --git a/tree/tree/src/TBranchSTL.cxx b/tree/tree/src/TBranchSTL.cxx index 7e69b3ba0422b..3703d5d9df421 100644 --- a/tree/tree/src/TBranchSTL.cxx +++ b/tree/tree/src/TBranchSTL.cxx @@ -46,10 +46,12 @@ TBranchSTL::TBranchSTL(): TBranchSTL::TBranchSTL(TTree *tree, const char *name, TVirtualCollectionProxy *collProxy, - Int_t bufsize, Int_t splitlevel ) + Long64_t bufsize, Int_t splitlevel ) { fTree = tree; fCollProxy = collProxy; + if (bufsize > kMaxInt) + Fatal("TBranchSTL", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); fBasketSize = bufsize; fSplitLevel = splitlevel; fContName = collProxy->GetCollectionClass()->GetName(); @@ -88,11 +90,13 @@ TBranchSTL::TBranchSTL(TTree *tree, const char *name, TBranchSTL::TBranchSTL(TBranch* parent, const char* name, TVirtualCollectionProxy* collProxy, - Int_t bufsize, Int_t splitlevel, + Long64_t bufsize, Int_t splitlevel, TStreamerInfo* info, Int_t id ) { fTree = parent->GetTree(); fCollProxy = collProxy; + if (bufsize > kMaxInt) + Fatal("TBranchSTL", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); fBasketSize = bufsize; fSplitLevel = splitlevel; fContName = collProxy->GetCollectionClass()->GetName(); diff --git a/tree/tree/src/TBufferSQL.cxx b/tree/tree/src/TBufferSQL.cxx index 2e93a05253040..ba4d09306ef5c 100644 --- a/tree/tree/src/TBufferSQL.cxx +++ b/tree/tree/src/TBufferSQL.cxx @@ -41,7 +41,7 @@ TBufferSQL::TBufferSQL(TBuffer::EMode mode, std::vector *vc, //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *vc, +TBufferSQL::TBufferSQL(TBuffer::EMode mode, Long64_t bufsize, std::vector *vc, TString *insert_query, TSQLRow ** r) : TBufferFile(mode,bufsize), fColumnVec(vc), fInsertQuery(insert_query), fRowPtr(r) @@ -52,7 +52,7 @@ TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *v //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *vc, +TBufferSQL::TBufferSQL(TBuffer::EMode mode, Long64_t bufsize, std::vector *vc, TString *insert_query, TSQLRow ** r, void *buf, bool adopt) : TBufferFile(mode,bufsize,buf,adopt), diff --git a/tree/tree/src/TChain.cxx b/tree/tree/src/TChain.cxx index 2708eea14233d..ebbe87fca120f 100644 --- a/tree/tree/src/TChain.cxx +++ b/tree/tree/src/TChain.cxx @@ -2016,7 +2016,7 @@ Long64_t TChain::Merge(TCollection* /* list */, TFileMergeInfo *) /// } /// ~~~ -Long64_t TChain::Merge(TFile* file, Int_t basketsize, Option_t* option) +Long64_t TChain::Merge(TFile* file, Long64_t basketsize, Option_t* option) { // We must have been passed a file, we will use it // later to reset the compression level of the branches. diff --git a/tree/tree/src/TNtuple.cxx b/tree/tree/src/TNtuple.cxx index 69dbc12efd682..2ff552bbcd8ba 100644 --- a/tree/tree/src/TNtuple.cxx +++ b/tree/tree/src/TNtuple.cxx @@ -62,7 +62,7 @@ TNtuple::TNtuple(): TTree() /// - Use TTree to create branches with variables of different data types. /// - Use TTree when the number of branches is large (> 100). -TNtuple::TNtuple(const char *name, const char *title, const char *varlist, Int_t bufsize) +TNtuple::TNtuple(const char *name, const char *title, const char *varlist, Long64_t bufsize) :TTree(name,title) { Int_t i; diff --git a/tree/tree/src/TNtupleD.cxx b/tree/tree/src/TNtupleD.cxx index 1aa334611895c..b4ec305581499 100644 --- a/tree/tree/src/TNtupleD.cxx +++ b/tree/tree/src/TNtupleD.cxx @@ -61,7 +61,7 @@ TNtupleD::TNtupleD(): TTree() /// - Use TTree to create branches with variables of different data types. /// - Use TTree when the number of branches is large (> 100). -TNtupleD::TNtupleD(const char *name, const char *title, const char *varlist, Int_t bufsize) +TNtupleD::TNtupleD(const char *name, const char *title, const char *varlist, Long64_t bufsize) :TTree(name,title) { Int_t i; diff --git a/tree/tree/src/TTree.cxx b/tree/tree/src/TTree.cxx index 35b4f9699d054..101b08b3ba06a 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -1579,7 +1579,7 @@ namespace { /// \see TTree::Branch() /// -TBranch* TTree::BranchImp(const char* branchname, const char* classname, TClass* ptrClass, void* addobj, Int_t bufsize, Int_t splitlevel) +TBranch* TTree::BranchImp(const char* branchname, const char* classname, TClass* ptrClass, void* addobj, Long64_t bufsize, Int_t splitlevel) { TClass* claim = TClass::GetClass(classname); if (!ptrClass) { @@ -1627,7 +1627,7 @@ TBranch* TTree::BranchImp(const char* branchname, const char* classname, TClass* /// Same as TTree::Branch but automatic detection of the class name. /// \see TTree::Branch -TBranch* TTree::BranchImp(const char* branchname, TClass* ptrClass, void* addobj, Int_t bufsize, Int_t splitlevel) +TBranch* TTree::BranchImp(const char* branchname, TClass* ptrClass, void* addobj, Long64_t bufsize, Int_t splitlevel) { if (!ptrClass) { Error("Branch", "The pointer specified for %s is not of a class known to ROOT", branchname); @@ -1660,7 +1660,7 @@ TBranch* TTree::BranchImp(const char* branchname, TClass* ptrClass, void* addobj /// Same as TTree::Branch but automatic detection of the class name. /// \see TTree::Branch -TBranch* TTree::BranchImpRef(const char* branchname, const char *classname, TClass* ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) +TBranch* TTree::BranchImpRef(const char* branchname, const char *classname, TClass* ptrClass, void *addobj, Long64_t bufsize, Int_t splitlevel) { TClass* claim = TClass::GetClass(classname); if (!ptrClass) { @@ -1720,7 +1720,7 @@ TBranch* TTree::BranchImpRef(const char* branchname, const char *classname, TCla /// Same as TTree::Branch but automatic detection of the class name. /// \see TTree::Branch -TBranch* TTree::BranchImpRef(const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Int_t bufsize, Int_t splitlevel) +TBranch* TTree::BranchImpRef(const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Long64_t bufsize, Int_t splitlevel) { if (!ptrClass) { if (datatype == kOther_t || datatype == kNoType_t) { @@ -1756,7 +1756,7 @@ TBranch* TTree::BranchImpRef(const char* branchname, TClass* ptrClass, EDataType //////////////////////////////////////////////////////////////////////////////// // Wrapper to turn Branch call with an std::array into the relevant leaf list // call -TBranch *TTree::BranchImpArr(const char *branchname, EDataType datatype, std::size_t N, void *addobj, Int_t bufsize, +TBranch *TTree::BranchImpArr(const char *branchname, EDataType datatype, std::size_t N, void *addobj, Long64_t bufsize, Int_t /* splitlevel */) { if (datatype == kOther_t || datatype == kNoType_t) { @@ -1774,7 +1774,7 @@ TBranch *TTree::BranchImpArr(const char *branchname, EDataType datatype, std::si //////////////////////////////////////////////////////////////////////////////// /// Deprecated function. Use next function instead. -Int_t TTree::Branch(TList* li, Int_t bufsize /* = 32000 */ , Int_t splitlevel /* = 99 */) +Int_t TTree::Branch(TList* li, Long64_t bufsize /* = 32000 */ , Int_t splitlevel /* = 99 */) { return Branch((TCollection*) li, bufsize, splitlevel); } @@ -1861,7 +1861,7 @@ Int_t TTree::Branch(TList* li, Int_t bufsize /* = 32000 */ , Int_t splitlevel /* /// } /// ~~~ -Int_t TTree::Branch(TCollection* li, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */, const char* name /* = "" */) +Int_t TTree::Branch(TCollection* li, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */, const char* name /* = "" */) { if (!li) { @@ -1908,7 +1908,7 @@ Int_t TTree::Branch(TCollection* li, Int_t bufsize /* = 32000 */, Int_t splitlev /// Create one branch for each element in the folder. /// Returns the total number of branches created. -Int_t TTree::Branch(const char* foldername, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) +Int_t TTree::Branch(const char* foldername, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) { TObject* ob = gROOT->FindObjectAny(foldername); if (!ob) { @@ -2014,7 +2014,7 @@ Int_t TTree::Branch(const char* foldername, Int_t bufsize /* = 32000 */, Int_t s /// A small value for bufsize is optimum if you intend to access /// the entries in the Tree randomly and your Tree is in split mode. -TBranch* TTree::Branch(const char* name, void* address, const char* leaflist, Int_t bufsize /* = 32000 */) +TBranch* TTree::Branch(const char* name, void* address, const char* leaflist, Long64_t bufsize /* = 32000 */) { TBranch* branch = new TBranch(this, name, address, leaflist, bufsize); if (branch->IsZombie()) { @@ -2049,7 +2049,7 @@ TBranch* TTree::Branch(const char* name, void* address, const char* leaflist, In /// Note: if the split level is set to the default (99), TTree::Branch will /// not issue a warning if the class can not be split. -TBranch* TTree::Branch(const char* name, const char* classname, void* addobj, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) +TBranch* TTree::Branch(const char* name, const char* classname, void* addobj, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) { if (fgBranchStyle == 1) { return Bronch(name, classname, addobj, bufsize, splitlevel); @@ -2102,7 +2102,7 @@ TBranch* TTree::Branch(const char* name, const char* classname, void* addobj, In /// A small value for bufsize is optimum if you intend to access /// the entries in the Tree randomly and your Tree is in split mode. -TBranch* TTree::BranchOld(const char* name, const char* classname, void* addobj, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 1 */) +TBranch* TTree::BranchOld(const char* name, const char* classname, void* addobj, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 1 */) { TClass* cl = TClass::GetClass(classname); if (!cl) { @@ -2432,7 +2432,7 @@ TBranch* TTree::BranchRef() /// Note: if the split level is set to the default (99), TTree::Branch will /// not issue a warning if the class can not be split. -TBranch* TTree::Bronch(const char* name, const char* classname, void* addr, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) +TBranch* TTree::Bronch(const char* name, const char* classname, void* addr, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) { return BronchExec(name, classname, addr, true, bufsize, splitlevel); } @@ -2440,7 +2440,7 @@ TBranch* TTree::Bronch(const char* name, const char* classname, void* addr, Int_ //////////////////////////////////////////////////////////////////////////////// /// Helper function implementing TTree::Bronch and TTree::Branch(const char *name, T &obj); -TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, bool isptrptr, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) +TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, bool isptrptr, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) { TClass* cl = TClass::GetClass(classname); if (!cl) { @@ -8563,7 +8563,7 @@ void TTree::SetAutoSave(Long64_t autos) /// see TRegexp for wildcarding options /// bufsize = branch basket size -void TTree::SetBasketSize(const char* bname, Int_t bufsize) +void TTree::SetBasketSize(const char* bname, Long64_t bufsize) { Int_t nleaves = fLeaves.GetEntriesFast(); TRegexp re(bname, true); @@ -10006,7 +10006,7 @@ void TTree::UseCurrentStyle() /// Write this object to the current directory. For more see TObject::Write /// If option & kFlushBasket, call FlushBasket before writing the tree. -Int_t TTree::Write(const char *name, Int_t option, Int_t bufsize) const +Int_t TTree::Write(const char *name, Int_t option, Long64_t bufsize) const { FlushBasketsImpl(); if (R__unlikely(option & kOnlyPrepStep)) @@ -10018,7 +10018,7 @@ Int_t TTree::Write(const char *name, Int_t option, Int_t bufsize) const /// Write this object to the current directory. For more see TObject::Write /// If option & kFlushBasket, call FlushBasket before writing the tree. -Int_t TTree::Write(const char *name, Int_t option, Int_t bufsize) +Int_t TTree::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TTree*)this)->Write(name, option, bufsize); } @@ -10125,13 +10125,13 @@ Option_t* TTreeFriendLeafIter::GetOption() const } TBranch *ROOT::Internal::TreeUtils::CallBranchImpRef(TTree &tree, const char *branchname, TClass *ptrClass, - EDataType datatype, void *addobj, Int_t bufsize, Int_t splitlevel) + EDataType datatype, void *addobj, Long64_t bufsize, Int_t splitlevel) { return tree.BranchImpRef(branchname, ptrClass, datatype, addobj, bufsize, splitlevel); } TBranch *ROOT::Internal::TreeUtils::CallBranchImp(TTree &tree, const char *branchname, TClass *ptrClass, void *addobj, - Int_t bufsize, Int_t splitlevel) + Long64_t bufsize, Int_t splitlevel) { return tree.BranchImp(branchname, ptrClass, addobj, bufsize, splitlevel); } diff --git a/tree/tree/src/TTreeCache.cxx b/tree/tree/src/TTreeCache.cxx index 285cbc6b47c3d..45720e634b115 100644 --- a/tree/tree/src/TTreeCache.cxx +++ b/tree/tree/src/TTreeCache.cxx @@ -316,7 +316,7 @@ TTreeCache::TTreeCache() : TFileCacheRead(), fPrefillType(GetConfiguredPrefillTy //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TTreeCache::TTreeCache(TTree *tree, Int_t bufsize) +TTreeCache::TTreeCache(TTree *tree, Long64_t bufsize) : TFileCacheRead(tree->GetCurrentFile(), bufsize, tree), fEntryMax(tree->GetEntriesFast()), fEntryNext(0), fBrNames(new TList), fTree(tree), fPrefillType(GetConfiguredPrefillType()) { @@ -2069,15 +2069,15 @@ void TTreeCache::ResetCache() /// - 1 if some or all of the buffer content has been made unavailable /// - -1 on error -Int_t TTreeCache::SetBufferSize(Long64_t buffersize) +Int_t TTreeCache::SetBufferSize(Long64_t bufsize) { Int_t prevsize = GetBufferSize(); - Int_t res = TFileCacheRead::SetBufferSize(buffersize); + Int_t res = TFileCacheRead::SetBufferSize(bufsize); if (res < 0) { return res; } - if (res == 0 && buffersize <= prevsize) { + if (res == 0 && bufsize <= prevsize) { return res; } diff --git a/tree/tree/src/TTreeCacheUnzip.cxx b/tree/tree/src/TTreeCacheUnzip.cxx index 507a23d0e218c..ced580eabd241 100644 --- a/tree/tree/src/TTreeCacheUnzip.cxx +++ b/tree/tree/src/TTreeCacheUnzip.cxx @@ -174,7 +174,7 @@ TTreeCacheUnzip::TTreeCacheUnzip() : TTreeCache(), //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TTreeCacheUnzip::TTreeCacheUnzip(TTree *tree, Int_t bufsize) : TTreeCache(tree,bufsize), +TTreeCacheUnzip::TTreeCacheUnzip(TTree *tree, Long64_t bufsize) : TTreeCache(tree,bufsize), fAsyncReading(false), fEmpty(true), fCycle(0), @@ -356,9 +356,9 @@ bool TTreeCacheUnzip::FillBuffer() /// - 1 if some or all of the buffer content has been made unavailable /// - -1 on error -Int_t TTreeCacheUnzip::SetBufferSize(Long64_t buffersize) +Int_t TTreeCacheUnzip::SetBufferSize(Long64_t bufsize) { - Int_t res = TTreeCache::SetBufferSize(buffersize); + Int_t res = TTreeCache::SetBufferSize(bufsize); if (res < 0) { return res; } diff --git a/tree/tree/src/TTreeSQL.cxx b/tree/tree/src/TTreeSQL.cxx index 6e7106d35f96c..d47b36fb0bd5a 100644 --- a/tree/tree/src/TTreeSQL.cxx +++ b/tree/tree/src/TTreeSQL.cxx @@ -73,7 +73,7 @@ TTreeSQL::TTreeSQL(TSQLServer *server, TString DB, const TString& table) : /// Not implemented yet TBranch* TTreeSQL::BranchImp(const char *, const char *, - TClass *, void *, Int_t , + TClass *, void *, Long64_t , Int_t ) { Fatal("BranchImp","Not implemented yet"); @@ -84,7 +84,7 @@ TBranch* TTreeSQL::BranchImp(const char *, const char *, /// Not implemented yet TBranch* TTreeSQL::BranchImp(const char *, TClass *, - void *, Int_t , Int_t ) + void *, Long64_t , Int_t ) { Fatal("BranchImp","Not implemented yet"); return nullptr; @@ -92,7 +92,7 @@ TBranch* TTreeSQL::BranchImp(const char *, TClass *, //////////////////////////////////////////////////////////////////////////////// /// Not implemented yet -Int_t TTreeSQL::Branch(TCollection *, Int_t, +Int_t TTreeSQL::Branch(TCollection *, Long64_t, Int_t, const char *) { Fatal("Branch","Not implemented yet"); @@ -102,7 +102,7 @@ Int_t TTreeSQL::Branch(TCollection *, Int_t, //////////////////////////////////////////////////////////////////////////////// /// Not implemented yet -Int_t TTreeSQL::Branch(TList *, Int_t, Int_t) +Int_t TTreeSQL::Branch(TList *, Long64_t, Int_t) { Fatal("Branch","Not implemented yet"); return 0; @@ -111,7 +111,7 @@ Int_t TTreeSQL::Branch(TList *, Int_t, Int_t) //////////////////////////////////////////////////////////////////////////////// /// Not implemented yet -Int_t TTreeSQL::Branch(const char *, Int_t , +Int_t TTreeSQL::Branch(const char *, Long64_t , Int_t) { Fatal("Branch","Not implemented yet"); @@ -122,7 +122,7 @@ Int_t TTreeSQL::Branch(const char *, Int_t , /// Not implemented yet TBranch* TTreeSQL::Bronch(const char *, const char *, void *, - Int_t, Int_t) + Long64_t, Int_t) { Fatal("Bronch","Not implemented yet"); return nullptr; @@ -132,7 +132,7 @@ TBranch* TTreeSQL::Bronch(const char *, const char *, void *, /// Not implemented yet TBranch* TTreeSQL::BranchOld(const char *, const char *, - void *, Int_t, Int_t) + void *, Long64_t, Int_t) { Fatal("BranchOld","Not implemented yet"); return nullptr; @@ -142,7 +142,7 @@ TBranch* TTreeSQL::BranchOld(const char *, const char *, /// Not implemented yet TBranch *TTreeSQL::Branch(const char *, const char *, void *, - Int_t, Int_t) + Long64_t, Int_t) { Fatal("Branch","Not implemented yet"); return nullptr; @@ -152,7 +152,7 @@ TBranch *TTreeSQL::Branch(const char *, const char *, void *, /// Create a branch TBranch * TTreeSQL::Branch(const char *name, void *address, - const char *leaflist, Int_t bufsize) + const char *leaflist, Long64_t bufsize) { Int_t nb = fBranches.GetEntriesFast(); TBranch *branch;