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 c81a3a0944fef..2c79b0d87053f 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 6cb2bc3651b14..e63a30ca89976 100644 --- a/core/base/src/TBuffer.cxx +++ b/core/base/src/TBuffer.cxx @@ -70,10 +70,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; @@ -101,10 +101,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; @@ -155,10 +155,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; @@ -184,8 +184,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; @@ -220,19 +222,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 e8c7db988298b..675a6402b21d4 100644 --- a/core/base/src/TDirectory.cxx +++ b/core/base/src/TDirectory.cxx @@ -343,11 +343,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); @@ -1424,9 +1425,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 a00fbea945dc1..409f895ecdc43 100644 --- a/core/base/src/TObject.cxx +++ b/core/base/src/TObject.cxx @@ -940,7 +940,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; @@ -962,7 +962,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 2ddd60513d44a..3d312d5ed68bd 100644 --- a/core/cont/inc/TCollection.h +++ b/core/cont/inc/TCollection.h @@ -206,8 +206,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 8380df1f53e24..4ce0dcc1a91ac 100644 --- a/core/cont/src/TCollection.cxx +++ b/core/cont/src/TCollection.cxx @@ -678,7 +678,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); @@ -702,7 +702,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 89abc3e1a45e4..736e474d3a077 100644 --- a/core/cont/src/TMap.cxx +++ b/core/cont/src/TMap.cxx @@ -402,7 +402,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); @@ -429,7 +429,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 6b2bc3e8c73a2..2f1204b4691c1 100644 --- a/hist/hbook/src/THbookBranch.cxx +++ b/hist/hbook/src/THbookBranch.cxx @@ -22,14 +22,14 @@ ClassImp(THbookBranch); //////////////////////////////////////////////////////////////////////////////// -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 1c09f73e58aa7..4bd51b144c03c 100644 --- a/hist/hbook/src/THbookFile.cxx +++ b/hist/hbook/src/THbookFile.cxx @@ -761,7 +761,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 5cc6fc7ef3ae4..88861473bd8af 100644 --- a/hist/hist/inc/TH1.h +++ b/hist/hist/inc/TH1.h @@ -628,13 +628,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 2149b1b478aea..d1edb584a4cb9 100644 --- a/hist/hist/inc/TProfile.h +++ b/hist/hist/inc/TProfile.h @@ -131,7 +131,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 f7a0edc755600..0524b05d8bf17 100644 --- a/hist/hist/inc/TProfile2D.h +++ b/hist/hist/inc/TProfile2D.h @@ -145,7 +145,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 4fe600436ff10..6ad9d063b83f1 100644 --- a/hist/hist/inc/TProfile3D.h +++ b/hist/hist/inc/TProfile3D.h @@ -143,7 +143,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 fd04afcbc589d..6c30de7547458 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -6728,8 +6728,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; } @@ -8486,7 +8487,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(); @@ -8498,6 +8499,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 80d5247596a4a..2d11569a10ead 100644 --- a/hist/hist/src/TProfile.cxx +++ b/hist/hist/src/TProfile.cxx @@ -1742,7 +1742,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(); @@ -1754,6 +1754,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 aad49759731bf..3cf8aa40166f4 100644 --- a/hist/hist/src/TProfile2D.cxx +++ b/hist/hist/src/TProfile2D.cxx @@ -1995,7 +1995,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(); @@ -2007,6 +2007,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 8703c8d30577e..b980f82462eb5 100644 --- a/hist/hist/src/TProfile3D.cxx +++ b/hist/hist/src/TProfile3D.cxx @@ -1364,7 +1364,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(); @@ -1376,6 +1376,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 ebef44676274b..8933f150ce47f 100644 --- a/hist/hist/src/TScatter.cxx +++ b/hist/hist/src/TScatter.cxx @@ -93,6 +93,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 94da4349b38d9..0f8a9a27a5091 100644 --- a/hist/histpainter/src/TPainter3dAlgorithms.cxx +++ b/hist/histpainter/src/TPainter3dAlgorithms.cxx @@ -2000,7 +2000,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..2b93f9fac0f88 100644 --- a/io/io/inc/TBufferIO.h +++ b/io/io/inc/TBufferIO.h @@ -44,8 +44,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 +80,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 +89,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 +98,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 c8518369493d0..d92d5a5ba947d 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 @@ -359,11 +359,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); @@ -374,11 +374,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()", @@ -391,7 +391,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; @@ -412,7 +412,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); @@ -426,7 +426,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); @@ -3333,13 +3333,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; @@ -3350,7 +3350,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()); @@ -3366,14 +3366,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 fe2efabeaa052..acc9b95f74640 100644 --- a/io/io/src/TBufferIO.cxx +++ b/io/io/src/TBufferIO.cxx @@ -48,7 +48,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; } @@ -56,7 +56,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; @@ -160,8 +160,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(); @@ -193,8 +194,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(); @@ -369,8 +371,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); @@ -382,8 +385,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 e0d368b003acb..fa8980ea5a17e 100644 --- a/io/io/src/TDirectoryFile.cxx +++ b/io/io/src/TDirectoryFile.cxx @@ -407,7 +407,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 { @@ -1663,8 +1663,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; } @@ -1851,7 +1853,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); @@ -1872,7 +1874,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); @@ -1922,7 +1924,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); @@ -1949,7 +1951,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) @@ -2037,7 +2043,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) { @@ -2064,7 +2070,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); @@ -2103,7 +2109,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 43e3818f4e311..0a888727a3777 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -1054,7 +1054,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); } @@ -1062,7 +1062,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); } @@ -2446,11 +2446,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; } //////////////////////////////////////////////////////////////////////////////// @@ -2465,7 +2470,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)) { @@ -2495,7 +2500,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); @@ -4286,16 +4291,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; } @@ -4685,7 +4702,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; @@ -4740,6 +4757,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"); @@ -4762,7 +4784,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; @@ -4788,7 +4810,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); @@ -4817,7 +4839,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 670f1712c4611..cf71ac843ce60 100644 --- a/io/io/src/TFileCacheRead.cxx +++ b/io/io/src/TFileCacheRead.cxx @@ -90,9 +90,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 e69943f9aaafd..2afa07ad8c527 100644 --- a/io/io/src/TFileCacheWrite.cxx +++ b/io/io/src/TFileCacheWrite.cxx @@ -50,9 +50,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; @@ -61,7 +66,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 9ba7a6f98d317..bac31eca621c9 100644 --- a/io/io/src/TKey.cxx +++ b/io/io/src/TKey.cxx @@ -172,11 +172,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); @@ -188,12 +193,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); } @@ -204,12 +214,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); } @@ -220,7 +235,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); @@ -295,7 +310,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); @@ -459,7 +474,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); @@ -469,7 +484,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 1bba942f7e240..45b03116ffaa9 100644 --- a/io/io/src/TMapFile.cxx +++ b/io/io/src/TMapFile.cxx @@ -1125,7 +1125,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 7c26c41bb9c3f..052c158b2674d 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 060ef3b7579cf..6bc1daf075dfd 100644 --- a/io/sql/src/TSQLFile.cxx +++ b/io/sql/src/TSQLFile.cxx @@ -763,7 +763,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); } @@ -771,7 +771,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 743bce1035522..3b399702bc2a3 100644 --- a/io/xml/src/TXMLFile.cxx +++ b/io/xml/src/TXMLFile.cxx @@ -405,7 +405,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); } @@ -413,7 +413,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 4fd724a8d58b5..456d98aa36aeb 100644 --- a/net/net/src/TMessage.cxx +++ b/net/net/src/TMessage.cxx @@ -43,7 +43,7 @@ ClassImp(TMessage); /// 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) { @@ -68,7 +68,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 94c254f4d7078..4648134cfbe60 100644 --- a/tree/dataframe/src/RDFSnapshotHelpers.cxx +++ b/tree/dataframe/src/RDFSnapshotHelpers.cxx @@ -138,7 +138,7 @@ void CreateFundamentalTypeBranch(TTree &outputTree, const std::string &outputBra { // 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(valueTypeID); if (rootTypeChar == ' ') { Warning("Snapshot", diff --git a/tree/ntuple/src/RFieldMeta.cxx b/tree/ntuple/src/RFieldMeta.cxx index 988501b10d243..cebb7f500328f 100644 --- a/tree/ntuple/src/RFieldMeta.cxx +++ b/tree/ntuple/src/RFieldMeta.cxx @@ -822,7 +822,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 1caa795fdf0d2..be41f9a2bbc00 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 31e9b2a02516e..8e61435cd438d 100644 --- a/tree/tree/inc/TChain.h +++ b/tree/tree/inc/TChain.h @@ -133,7 +133,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 98646a1191dea..a9f6fcb4c3627 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); @@ -384,7 +384,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); } @@ -401,42 +401,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) { @@ -447,8 +447,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); @@ -658,7 +658,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); @@ -736,8 +736,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 1fd91674fe754..95b3aa5166514 100644 --- a/tree/tree/src/TBranch.cxx +++ b/tree/tree/src/TBranch.cxx @@ -196,7 +196,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) @@ -240,6 +240,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); } @@ -249,7 +251,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) @@ -294,6 +296,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); } @@ -2739,8 +2743,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 bea3cf646b237..abb9a1543fe23 100644 --- a/tree/tree/src/TBranchClones.cxx +++ b/tree/tree/src/TBranchClones.cxx @@ -50,7 +50,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) @@ -64,7 +64,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) @@ -78,7 +78,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; @@ -111,6 +111,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; } @@ -370,7 +372,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 604e9d5439b3d..ff2e6a5c056e4 100644 --- a/tree/tree/src/TBranchElement.cxx +++ b/tree/tree/src/TBranchElement.cxx @@ -176,7 +176,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() @@ -223,7 +223,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() @@ -268,7 +268,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); @@ -334,7 +334,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; } @@ -660,7 +661,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() @@ -687,7 +688,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() @@ -714,7 +715,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; @@ -815,7 +816,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() @@ -841,7 +842,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() @@ -867,7 +868,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 ); @@ -912,7 +913,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; } @@ -5548,7 +5550,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(); @@ -6110,7 +6112,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? @@ -6244,7 +6246,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 9b6f9b9185009..ca39a4557b995 100644 --- a/tree/tree/src/TBranchObject.cxx +++ b/tree/tree/src/TBranchObject.cxx @@ -47,7 +47,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); @@ -56,7 +56,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); @@ -65,7 +65,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; @@ -114,6 +114,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; @@ -528,7 +530,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 65887ae835d04..a18b9c5e13e9c 100644 --- a/tree/tree/src/TBranchSTL.cxx +++ b/tree/tree/src/TBranchSTL.cxx @@ -47,10 +47,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(); @@ -89,11 +91,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 b14c56f64f876..0021b25d133f0 100644 --- a/tree/tree/src/TBufferSQL.cxx +++ b/tree/tree/src/TBufferSQL.cxx @@ -42,7 +42,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) @@ -53,7 +53,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 12f526c8314ba..f2d18f6affd26 100644 --- a/tree/tree/src/TChain.cxx +++ b/tree/tree/src/TChain.cxx @@ -2001,7 +2001,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 c7f18c074e2b9..5ace86db79d8c 100644 --- a/tree/tree/src/TNtuple.cxx +++ b/tree/tree/src/TNtuple.cxx @@ -63,7 +63,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 72817e6a9bfb3..853cfc71c97ea 100644 --- a/tree/tree/src/TNtupleD.cxx +++ b/tree/tree/src/TNtupleD.cxx @@ -62,7 +62,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 63cd8b6b48921..b62907714c948 100644 --- a/tree/tree/src/TTree.cxx +++ b/tree/tree/src/TTree.cxx @@ -1580,7 +1580,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) { @@ -1628,7 +1628,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); @@ -1661,7 +1661,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) { @@ -1721,7 +1721,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) { @@ -1757,7 +1757,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) { @@ -1775,7 +1775,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); } @@ -1862,7 +1862,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) { @@ -1909,7 +1909,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) { @@ -2015,7 +2015,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()) { @@ -2050,7 +2050,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); @@ -2103,7 +2103,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) { @@ -2433,7 +2433,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); } @@ -2441,7 +2441,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) { @@ -8524,7 +8524,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); @@ -9958,7 +9958,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)) @@ -9970,7 +9970,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); } @@ -10078,13 +10078,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 ae2490383a38a..c367847bb1483 100644 --- a/tree/tree/src/TTreeCache.cxx +++ b/tree/tree/src/TTreeCache.cxx @@ -317,7 +317,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()) { @@ -2070,15 +2070,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 5d338e32b5198..29d230ee515bf 100644 --- a/tree/tree/src/TTreeCacheUnzip.cxx +++ b/tree/tree/src/TTreeCacheUnzip.cxx @@ -175,7 +175,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), @@ -357,9 +357,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 4730f4710a2ab..0474a6e0f8cf2 100644 --- a/tree/tree/src/TTreeSQL.cxx +++ b/tree/tree/src/TTreeSQL.cxx @@ -74,7 +74,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"); @@ -85,7 +85,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; @@ -93,7 +93,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"); @@ -103,7 +103,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; @@ -112,7 +112,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"); @@ -123,7 +123,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; @@ -133,7 +133,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; @@ -143,7 +143,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; @@ -153,7 +153,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;