diff --git a/core/base/inc/TBuffer.h b/core/base/inc/TBuffer.h index e383bb738d672..e20ec2e741a7d 100644 --- a/core/base/inc/TBuffer.h +++ b/core/base/inc/TBuffer.h @@ -63,10 +63,10 @@ class TBuffer : public TObject { TBuffer(const TBuffer &) = delete; 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 + Long64_t Read(const char *name) override { return TObject::Read(name); } + Long64_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 + Long64_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(ULong64_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..32e4e4d1addb9 100644 --- a/core/base/inc/TDirectory.h +++ b/core/base/inc/TDirectory.h @@ -247,27 +247,27 @@ can be replaced with the simpler and exception safe: virtual void pwd() const; virtual void ReadAll(Option_t * /*option*/="") {} virtual Int_t ReadKeys(Bool_t /*forceRead*/=kTRUE) {return 0;} - virtual Int_t ReadTObject(TObject * /*obj*/, const char * /*keyname*/) {return 0;} + virtual Long64_t ReadTObject(TObject * /*obj*/, const char * /*keyname*/) {return 0;} virtual TObject *Remove(TObject*); void RecursiveRemove(TObject *obj) override; virtual void rmdir(const char *name); virtual void Save() {} - virtual Int_t SaveObjectAs(const TObject * /*obj*/, const char * /*filename*/="", Option_t * /*option*/="") const; + virtual Long64_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; virtual void SetTRefAction(TObject * /*ref*/, TObject * /*parent*/) {} 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); + Long64_t Sizeof() const override {return 0;} + Long64_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Long64_t /*bufsize*/=0) override {return 0;} + Long64_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Long64_t /*bufsize*/=0) const override {return 0;} + virtual Long64_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. + Long64_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); } @@ -293,13 +293,13 @@ can be replaced with the simpler and exception safe: /// This overload takes care of instances of classes that are derived from /// 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) + inline std::enable_if_t::value, Long64_t> + 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 Long64_t WriteObjectAny(const void *, const char * /*classname*/, const char * /*name*/, Option_t * /*option*/="", Long64_t /*bufsize*/ =0) {return 0;} + virtual Long64_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/TNamed.h b/core/base/inc/TNamed.h index e3b59f3f32bc1..dfc2b10700c4a 100644 --- a/core/base/inc/TNamed.h +++ b/core/base/inc/TNamed.h @@ -55,7 +55,7 @@ class TNamed : public TObject { virtual void SetTitle(const char *title=""); // *MENU* void ls(Option_t *option="") const override; void Print(Option_t *option="") const override; - virtual Int_t Sizeof() const; + virtual Long64_t Sizeof() const; ClassDefOverride(TNamed,1) //The basis for a named object (name, title) }; diff --git a/core/base/inc/TObject.h b/core/base/inc/TObject.h index 7aaf4f6f00cf1..ab612f6b51d42 100644 --- a/core/base/inc/TObject.h +++ b/core/base/inc/TObject.h @@ -163,15 +163,33 @@ class TObject { virtual void Paint(Option_t *option=""); virtual void Pop(); virtual void Print(Option_t *option="") const; - virtual Int_t Read(const char *name); + virtual Long64_t Read(const char *name); virtual void RecursiveRemove(TObject *obj); virtual void SaveAs(const char *filename="",Option_t *option="") const; // *MENU* virtual void SavePrimitive(std::ostream &out, Option_t *option = ""); 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 Long64_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0); + virtual Long64_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Woverloaded-virtual" +#elif __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif + /// \deprecated Please override the `Long64_t` overload instead of the `Int_t` version. + [[deprecated]] virtual Long64_t Write(const char *name, Int_t option, Int_t bufsize) final + { return Write(name, option, (Long64_t)bufsize); } + /// \deprecated Please override the `Long64_t` overload instead of the `Int_t` version. + [[deprecated]] virtual Long64_t Write(const char *name, Int_t option, Int_t bufsize) const final + { return Write(name, option, (Long64_t)bufsize); } +#ifdef __clang__ +#pragma clang diagnostic pop +#elif __GNUC__ +#pragma GCC diagnostic pop +#endif /// IsDestructed /// diff --git a/core/base/src/TBuffer.cxx b/core/base/src/TBuffer.cxx index 8a0c2b78e99e6..badcc6ddc606a 100644 --- a/core/base/src/TBuffer.cxx +++ b/core/base/src/TBuffer.cxx @@ -69,10 +69,10 @@ TBuffer::TBuffer(EMode mode) /// Create an I/O buffer object. Mode should be either TBuffer::kRead or /// TBuffer::kWrite. -TBuffer::TBuffer(EMode mode, Int_t bufsize) +TBuffer::TBuffer(EMode mode, Long64_t bufsize) { - if (bufsize < 0) - Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize); + if (bufsize > kMaxBufferSize) + Fatal("TBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", bufsize, kMaxBufferSize); if (bufsize < kMinimalSize) bufsize = kMinimalSize; fBufSize = bufsize; fMode = mode; @@ -100,10 +100,10 @@ TBuffer::TBuffer(EMode mode, Int_t bufsize) /// is provided, a Fatal error will be issued if the Buffer attempts to /// expand. -TBuffer::TBuffer(EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) +TBuffer::TBuffer(EMode mode, Long64_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) { - if (bufsize < 0) - Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize); + if (bufsize > kMaxBufferSize) + Fatal("TBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", bufsize, kMaxBufferSize); fBufSize = bufsize; fMode = mode; fVersion = 0; @@ -154,17 +154,18 @@ 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(ULong64_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) { + auto size_asked = Long64_t(size_needed); // temporary cast as long as fBufSize keeps being a signed variable + if (size_asked > fBufSize) { Long64_t doubling = 2LLU * fBufSize; if (doubling > kMaxBufferSize) doubling = kMaxBufferSize; - if (size_needed > doubling) { - Expand(size_needed); + if (size_asked > doubling) { + Expand(size_asked); } else { Expand(doubling); } @@ -183,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; @@ -219,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 9bebee0e74a1d..feb85545fcf1b 100644 --- a/core/base/src/TDirectory.cxx +++ b/core/base/src/TDirectory.cxx @@ -342,11 +342,12 @@ static TBuffer* R__CreateBuffer() if (!creator) { R__LOCKGUARD(gROOTMutex); TClass *c = TClass::GetClass("TBufferFile"); - TMethod *m = c->GetMethodWithPrototype("TBufferFile","TBuffer::EMode,Int_t",kFALSE,ROOT::kExactMatch); + TMethod *m = c->GetMethodWithPrototype("TBufferFile","TBuffer::EMode,Long64_t",kFALSE,ROOT::kExactMatch); + assert(m != nullptr); creator = (tcling_callfunc_Wrapper_t)( m->InterfaceMethod() ); } TBuffer::EMode mode = TBuffer::kWrite; - Int_t size = 10000; + Long64_t size = 10000; void *args[] = { &mode, &size }; TBuffer *result; creator(nullptr,2,args,&result); @@ -1253,12 +1254,12 @@ void TDirectory::rmdir(const char *name) /// JavaScript ROOT (https://root.cern/js/) to display object in web browser /// When creating JSON file, option string may contain compression level from 0 to 3 (default 0) -Int_t TDirectory::SaveObjectAs(const TObject *obj, const char *filename, Option_t *option) const +Long64_t TDirectory::SaveObjectAs(const TObject *obj, const char *filename, Option_t *option) const { // option can contain single letter args: "a" for append, "q" for quiet in any combinations if (!obj) return 0; - Int_t nbytes = 0; + Long64_t nbytes = 0; TString fname, opt = option, cmd; if (filename && *filename) fname = filename; @@ -1423,9 +1424,9 @@ void TDirectory::RegisterGDirectory(TDirectory::SharedGDirectory_t &gdirectory_p } //////////////////////////////////////////////////////////////////////////////// -/// \copydoc TDirectoryFile::WriteObject(const T*,const char*,Option_t*,Int_t). +/// \copydoc TDirectoryFile::WriteObject(const T*,const char*,Option_t*,Long64_t). -Int_t TDirectory::WriteTObject(const TObject *obj, const char *name, Option_t * /*option*/, Int_t /*bufsize*/) +Long64_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/TNamed.cxx b/core/base/src/TNamed.cxx index 71724c5bf74b3..dbc02b4cc0726 100644 --- a/core/base/src/TNamed.cxx +++ b/core/base/src/TNamed.cxx @@ -179,8 +179,8 @@ void TNamed::SetTitle(const char *title) //////////////////////////////////////////////////////////////////////////////// /// Return size of the TNamed part of the TObject. -Int_t TNamed::Sizeof() const +Long64_t TNamed::Sizeof() const { - Int_t nbytes = fName.Sizeof() + fTitle.Sizeof(); + Long64_t nbytes = fName.Sizeof() + fTitle.Sizeof(); return nbytes; } diff --git a/core/base/src/TObject.cxx b/core/base/src/TObject.cxx index f02db598949bb..c40f0787578ed 100644 --- a/core/base/src/TObject.cxx +++ b/core/base/src/TObject.cxx @@ -664,7 +664,7 @@ void TObject::Print(Option_t *) const /// The object must have been created before via the default constructor. /// See TObject::Write(). -Int_t TObject::Read(const char *name) +Long64_t TObject::Read(const char *name) { if (gDirectory) return gDirectory->ReadTObject(this,name); @@ -956,7 +956,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 +Long64_t TObject::Write(const char *name, Int_t option, Long64_t bufsize) const { if (R__unlikely(option & kOnlyPrepStep)) return 0; @@ -978,7 +978,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) +Long64_t TObject::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TObject*)this)->Write(name, option, bufsize); } diff --git a/core/cont/inc/TCollection.h b/core/cont/inc/TCollection.h index 5ddfe4cb511b6..72d9b87837b10 100644 --- a/core/cont/inc/TCollection.h +++ b/core/cont/inc/TCollection.h @@ -207,8 +207,8 @@ class TCollection : public TObject { void SetName(const char *name) { fName = name; } virtual void SetOwner(Bool_t enable = kTRUE); virtual bool UseRWLock(Bool_t enable = true); - Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0) override; - Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0) const override; + Long64_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0) override; + Long64_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..66578f2855d70 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; + Long64_t Write(const char *name=nullptr, Int_t option=0, Long64_t bufsize=0) override; + Long64_t Write(const char *name=nullptr, Int_t option=0, Long64_t bufsize=0) const override; ClassDefOverride(TMap,3) //A (key,value) map }; diff --git a/core/cont/src/TCollection.cxx b/core/cont/src/TCollection.cxx index 81fe664eea6fb..a31ec9da3af08 100644 --- a/core/cont/src/TCollection.cxx +++ b/core/cont/src/TCollection.cxx @@ -676,13 +676,13 @@ 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 +Long64_t TCollection::Write(const char *name, Int_t option, Long64_t bufsize) const { if ((option & kSingleKey)) { return TObject::Write(name, option, bufsize); } else { option &= ~kSingleKey; - Int_t nbytes = 0; + Long64_t nbytes = 0; TIter next(this); TObject *obj; while ((obj = next())) { @@ -700,7 +700,7 @@ Int_t TCollection::Write(const char *name, Int_t option, Int_t bufsize) const /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TCollection::Write(const char *name, Int_t option, Int_t bufsize) +Long64_t TCollection::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TCollection*)this)->Write(name,option,bufsize); } diff --git a/core/cont/src/TMap.cxx b/core/cont/src/TMap.cxx index a1af3bac25490..ee7a6d6352cf9 100644 --- a/core/cont/src/TMap.cxx +++ b/core/cont/src/TMap.cxx @@ -401,13 +401,13 @@ 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 +Long64_t TMap::Write(const char *name, Int_t option, Long64_t bufsize) const { if ((option & kSingleKey)) { return TObject::Write(name, option, bufsize); } else { option &= ~kSingleKey; - Int_t nbytes = 0; + Long64_t nbytes = 0; TIter next(fTable); TPair *a; while ((a = (TPair*) next())) { @@ -428,7 +428,7 @@ Int_t TMap::Write(const char *name, Int_t option, Int_t bufsize) const /// objects using a single key specify a name and set option to /// TObject::kSingleKey (i.e. 1). -Int_t TMap::Write(const char *name, Int_t option, Int_t bufsize) +Long64_t TMap::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TMap*)this)->Write(name,option,bufsize); } diff --git a/geom/geom/src/TGeoManager.cxx b/geom/geom/src/TGeoManager.cxx index 112040aee5899..c9d6527f12db4 100644 --- a/geom/geom/src/TGeoManager.cxx +++ b/geom/geom/src/TGeoManager.cxx @@ -4054,7 +4054,7 @@ Int_t TGeoManager::Export(const char *filename, const char *name, Option_t *opti TBufferText::SetDoubleFormat(new_format_dbl.Data()); TBufferText::SetFloatFormat(new_format_dbl.Data()); } - Int_t nbytes = Write(keyname); + Long64_t nbytes = Write(keyname); if (sfile.Contains(".xml")) { TBufferText::SetFloatFormat(precision_dbl); TBufferText::SetDoubleFormat(precision_flt); diff --git a/geom/geom/src/TGeoVolume.cxx b/geom/geom/src/TGeoVolume.cxx index 0846dddf15c29..123798055ce33 100644 --- a/geom/geom/src/TGeoVolume.cxx +++ b/geom/geom/src/TGeoVolume.cxx @@ -952,7 +952,7 @@ Int_t TGeoVolume::Export(const char *filename, const char *name, Option_t *optio TString keyname(name); if (keyname.IsNull()) keyname = GetName(); - Int_t nbytes = Write(keyname); + Long64_t nbytes = Write(keyname); delete f; return nbytes; } diff --git a/hist/hbook/inc/THbookBranch.h b/hist/hbook/inc/THbookBranch.h index ef5881462aae4..26f678578adbb 100644 --- a/hist/hbook/inc/THbookBranch.h +++ b/hist/hbook/inc/THbookBranch.h @@ -30,11 +30,11 @@ 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; + Long64_t GetEntry(Long64_t entry=0, Int_t getall=0) override; const char *GetBlockName() const {return fBlockName.Data();} void SetAddress(void *addobj) override; void SetBlockName(const char *name) {fBlockName=name;} diff --git a/hist/hbook/inc/THbookTree.h b/hist/hbook/inc/THbookTree.h index 9fcf37470e015..a6a1339cc6e61 100644 --- a/hist/hbook/inc/THbookTree.h +++ b/hist/hbook/inc/THbookTree.h @@ -40,15 +40,15 @@ class THbookTree : public TTree { THbookTree(); THbookTree(const char *name, Int_t id); ~THbookTree() override; - Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override; + Long64_t GetEntry(Long64_t entry=0, Int_t getall=0) override; THbookFile *GetHbookFile() {return fFile;} virtual Int_t GetID() {return fID;} virtual Int_t GetType() {return fType;} Float_t *GetX() {return (Float_t*)fX;} virtual void InitBranches(Long64_t entry); char *MakeX(Int_t nvars) {fX = new char[nvars]; return fX;} - void Print(Option_t *option="") const override; - Long64_t SetEntries(Long64_t n=-1) override; + void Print(Option_t *option="") const override; + Long64_t SetEntries(Long64_t n=-1) override; virtual void SetHbookFile(THbookFile *file) {fFile = file;} virtual void SetType(Int_t atype) {fType = atype;} diff --git a/hist/hbook/src/THbookBranch.cxx b/hist/hbook/src/THbookBranch.cxx index a8e8f26140ff9..cc9fac24c751e 100644 --- a/hist/hbook/src/THbookBranch.cxx +++ b/hist/hbook/src/THbookBranch.cxx @@ -21,14 +21,14 @@ //////////////////////////////////////////////////////////////////////////////// -THbookBranch::THbookBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize, Int_t compress) +THbookBranch::THbookBranch(TTree *tree, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) :TBranch(tree, name,address,leaflist,basketsize,compress) { } //////////////////////////////////////////////////////////////////////////////// -THbookBranch::THbookBranch(TBranch *branch, const char *name, void *address, const char *leaflist, Int_t basketsize, Int_t compress) +THbookBranch::THbookBranch(TBranch *branch, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) :TBranch(branch,name,address,leaflist,basketsize,compress) { } @@ -55,7 +55,7 @@ void THbookBranch::Browse(TBrowser *b) //////////////////////////////////////////////////////////////////////////////// ///get one entry from hbook ntuple -Int_t THbookBranch::GetEntry(Long64_t entry, Int_t /*getall*/) +Long64_t THbookBranch::GetEntry(Long64_t entry, Int_t /*getall*/) { THbookTree *tree = (THbookTree*)GetTree(); THbookFile *file = tree->GetHbookFile(); diff --git a/hist/hbook/src/THbookFile.cxx b/hist/hbook/src/THbookFile.cxx index f44e724f71c1a..20956391e9ea5 100644 --- a/hist/hbook/src/THbookFile.cxx +++ b/hist/hbook/src/THbookFile.cxx @@ -760,7 +760,7 @@ TObject *THbookFile::ConvertCWN(Int_t id) } - Int_t bufsize = 8000; + Long64_t bufsize = 8000; THbookBranch *branch = new THbookBranch(tree,name,(void*)&bigbuf[bufpos],fullname,bufsize); tree->GetListOfBranches()->Add(branch); branch->SetBlockName(block); diff --git a/hist/hbook/src/THbookTree.cxx b/hist/hbook/src/THbookTree.cxx index 057528f174f63..e8441a30c13ad 100644 --- a/hist/hbook/src/THbookTree.cxx +++ b/hist/hbook/src/THbookTree.cxx @@ -93,7 +93,7 @@ THbookTree::~THbookTree() //////////////////////////////////////////////////////////////////////////////// ///get one entry from the hbook ntuple -Int_t THbookTree::GetEntry(Long64_t entry, Int_t /*getall*/) +Long64_t THbookTree::GetEntry(Long64_t entry, Int_t /*getall*/) { fReadEntry = entry; return fFile->GetEntry(entry,fID,fType,GetX()); diff --git a/hist/hist/inc/TH1.h b/hist/hist/inc/TH1.h index 8cce4f6fc0261..862d4860ba973 100644 --- a/hist/hist/inc/TH1.h +++ b/hist/hist/inc/TH1.h @@ -627,13 +627,13 @@ class TH1 : public TNamed, public TAttLine, public TAttFill, public TAttMarker { const Double_t *zBins); virtual void SetBinsLength(Int_t = -1) { } //redefined in derived classes virtual void SetBinErrorOption(EBinErrorOpt type) { fBinStatErrOpt = type; } - virtual void SetBuffer(Int_t bufsize, Option_t *option=""); + virtual void SetBuffer(Long64_t bufsize, Option_t *option=""); virtual UInt_t SetCanExtend(UInt_t extendBitMask); virtual void SetContent(const Double_t *content); virtual void SetContour(Int_t nlevels, const Double_t *levels = nullptr); virtual void SetContourLevel(Int_t level, Double_t value); virtual void SetColors(Color_t linecolor = -1, Color_t markercolor = -1, Color_t fillcolor = -1); - static void SetDefaultBufferSize(Int_t bufsize=1000); + static void SetDefaultBufferSize(Long64_t bufsize=1000); static void SetDefaultSumw2(Bool_t sumw2=kTRUE); virtual void SetDirectory(TDirectory *dir); virtual void SetEntries(Double_t n) { fEntries = n; } diff --git a/hist/hist/inc/TProfile.h b/hist/hist/inc/TProfile.h index e1b00a80bd4b2..316f61f3d2eb3 100644 --- a/hist/hist/inc/TProfile.h +++ b/hist/hist/inc/TProfile.h @@ -132,7 +132,7 @@ class TProfile : public TH1D { void SetBins(Int_t nbins, Double_t xmin, Double_t xmax) override; void SetBins(Int_t nx, const Double_t *xbins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t bufsize, Option_t *option="") override; + void SetBuffer(Long64_t bufsize, Option_t *option="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; diff --git a/hist/hist/inc/TProfile2D.h b/hist/hist/inc/TProfile2D.h index 564141207c4f3..5215608e2dd30 100644 --- a/hist/hist/inc/TProfile2D.h +++ b/hist/hist/inc/TProfile2D.h @@ -146,7 +146,7 @@ class TProfile2D : public TH2D { void SetBins(Int_t nbinsx, Double_t xmin, Double_t xmax, Int_t nbinsy, Double_t ymin, Double_t ymax) override; void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t *yBins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t bufsize, Option_t *option="") override; + void SetBuffer(Long64_t bufsize, Option_t *option="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; Double_t GetNumberOfBins() { return fBinEntries.GetSize(); } diff --git a/hist/hist/inc/TProfile3D.h b/hist/hist/inc/TProfile3D.h index 93ce0f310e793..f30498444071d 100644 --- a/hist/hist/inc/TProfile3D.h +++ b/hist/hist/inc/TProfile3D.h @@ -144,7 +144,7 @@ class TProfile3D : public TH3D { void SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t * yBins, Int_t nz, const Double_t *zBins) override; void SetBinsLength(Int_t n=-1) override; - void SetBuffer(Int_t bufsize, Option_t *opt="") override; + void SetBuffer(Long64_t bufsize, Option_t *opt="") override; virtual void SetErrorOption(Option_t *option=""); // *MENU* void Sumw2(Bool_t flag = kTRUE) override; diff --git a/hist/hist/src/TH1.cxx b/hist/hist/src/TH1.cxx index bf854d65d1a7c..7f8e75ad4f81b 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -6740,8 +6740,9 @@ UInt_t TH1::GetAxisLabelStatus() const /// or equal to its upper limit, the function SetBuffer is automatically /// called with the default buffer size. -void TH1::SetDefaultBufferSize(Int_t bufsize) +void TH1::SetDefaultBufferSize(Long64_t bufsize) { + assert(bufsize <= kMaxInt); fgBufferSize = bufsize > 0 ? bufsize : 0; } @@ -8508,7 +8509,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(); @@ -8520,6 +8521,8 @@ void TH1::SetBuffer(Int_t bufsize, Option_t * /*option*/) return; } if (bufsize < 100) bufsize = 100; + if (1 + bufsize*(fDimension+1)> kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + bufsize*(fDimension+1), kMaxInt); fBufferSize = 1 + bufsize*(fDimension+1); fBuffer = new Double_t[fBufferSize]; memset(fBuffer, 0, sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TProfile.cxx b/hist/hist/src/TProfile.cxx index 021bc95c3fb1a..9f2eb71458953 100644 --- a/hist/hist/src/TProfile.cxx +++ b/hist/hist/src/TProfile.cxx @@ -1769,7 +1769,7 @@ void TProfile::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile::SetBuffer(Int_t bufsize, Option_t *) +void TProfile::SetBuffer(Long64_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); @@ -1781,6 +1781,8 @@ void TProfile::SetBuffer(Int_t bufsize, Option_t *) return; } if (bufsize < 100) bufsize = 100; + if (1 + 3*bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + 3*bufsize, kMaxInt); fBufferSize = 1 + 3*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TProfile2D.cxx b/hist/hist/src/TProfile2D.cxx index e61d826cf30d6..776b4418cc567 100644 --- a/hist/hist/src/TProfile2D.cxx +++ b/hist/hist/src/TProfile2D.cxx @@ -2022,7 +2022,7 @@ void TProfile2D::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile2D::SetBuffer(Int_t bufsize, Option_t *) +void TProfile2D::SetBuffer(Long64_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); @@ -2034,6 +2034,8 @@ void TProfile2D::SetBuffer(Int_t bufsize, Option_t *) return; } if (bufsize < 100) bufsize = 100; + if (1 + 4*bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + 4*bufsize, kMaxInt); fBufferSize = 1 + 4*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TProfile3D.cxx b/hist/hist/src/TProfile3D.cxx index 2b6569a642692..7ac5db17a4987 100644 --- a/hist/hist/src/TProfile3D.cxx +++ b/hist/hist/src/TProfile3D.cxx @@ -1391,7 +1391,7 @@ void TProfile3D::SetBinsLength(Int_t n) //////////////////////////////////////////////////////////////////////////////// /// Set the buffer size in units of 8 bytes (double). -void TProfile3D::SetBuffer(Int_t bufsize, Option_t *) +void TProfile3D::SetBuffer(Long64_t bufsize, Option_t *) { if (fBuffer) { BufferEmpty(); @@ -1403,6 +1403,8 @@ void TProfile3D::SetBuffer(Int_t bufsize, Option_t *) return; } if (bufsize < 100) bufsize = 100; + if (1 + 5*bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", 1 + 5*bufsize, kMaxInt); fBufferSize = 1 + 5*bufsize; fBuffer = new Double_t[fBufferSize]; memset(fBuffer,0,sizeof(Double_t)*fBufferSize); diff --git a/hist/hist/src/TScatter.cxx b/hist/hist/src/TScatter.cxx index e8f6e9a81ccb6..f26a78c4d5472 100644 --- a/hist/hist/src/TScatter.cxx +++ b/hist/hist/src/TScatter.cxx @@ -83,6 +83,9 @@ TScatter::TScatter(Int_t n, const Double_t *x, const Double_t *y, const Double_t fMaxSize = fGraph->GetMaxSize(); Int_t bufsize = sizeof(Double_t) * fNpoints; + if (sizeof(Double_t) * fNpoints > kMaxInt || bufsize < 0) { + Fatal("TScatter", "Negative buffer size likely due to an integer overflow: 0x%x.", bufsize); + } if (col) { fColor = new Double_t[fMaxSize]; memcpy(fColor, col, bufsize); diff --git a/hist/histpainter/src/TPainter3dAlgorithms.cxx b/hist/histpainter/src/TPainter3dAlgorithms.cxx index f0884c9aa3656..7a4f7f8fb4595 100644 --- a/hist/histpainter/src/TPainter3dAlgorithms.cxx +++ b/hist/histpainter/src/TPainter3dAlgorithms.cxx @@ -2009,7 +2009,9 @@ void TPainter3dAlgorithms::InitRaster(Double_t xmin, Double_t ymin, Double_t xma fDYrast = ymax - ymin; // Create buffer for raster - Int_t bufsize = nx*ny/30 + 1; + if (Long64_t(nx)*ny / 30 + 1 > kMaxInt) + Fatal("InitRaster", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", Long64_t(nx)*ny / 30 + 1, kMaxInt); + Int_t bufsize = Long64_t(nx)*ny/30 + 1; fRaster.resize(bufsize); // S E T M A S K S diff --git a/io/io/inc/ROOT/TBufferMerger.hxx b/io/io/inc/ROOT/TBufferMerger.hxx index d3c8ac86849a2..4829081632acf 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; + Long64_t Write(const char *name = nullptr, Int_t opt = 0, Long64_t bufsize = 0) override; ClassDefOverride(TBufferMergerFile, 0); }; diff --git a/io/io/inc/TBufferFile.h b/io/io/inc/TBufferFile.h index 5aaf5f1916f83..3d2e37141fcc4 100644 --- a/io/io/inc/TBufferFile.h +++ b/io/io/inc/TBufferFile.h @@ -59,9 +59,9 @@ class TBufferFile : public TBufferIO { TBufferFile(const TBufferFile &) = delete; ///< not implemented void operator=(const TBufferFile &) = delete; ///< not implemented - Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss, const char* classname); - void CheckCount(UInt_t offset) override; - UInt_t CheckObject(UInt_t offset, const TClass *cl, Bool_t readClass = kFALSE); + Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss, const char* classname); + void CheckCount(UInt_t offset) override; + UInt_t CheckObject(UInt_t offset, const TClass *cl, Bool_t readClass = kFALSE); void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) override; @@ -69,13 +69,13 @@ class TBufferFile : public TBufferIO { enum { kStreamedMemberWise = BIT(14) }; //added to version number to know if a collection has been stored member-wise TBufferFile(TBuffer::EMode mode); - TBufferFile(TBuffer::EMode mode, Int_t bufsize); - TBufferFile(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); + TBufferFile(TBuffer::EMode mode, Long64_t bufsize); + TBufferFile(TBuffer::EMode mode, Long64_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); ~TBufferFile() override; - Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) override; - Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname) override; - void SetByteCount(UInt_t cntpos, Bool_t packInVersion = kFALSE) override; + Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss) override; + Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const char *classname) override; + void SetByteCount(ULong64_t cntpos, Bool_t packInVersion = kFALSE) override; void SkipVersion(const TClass *cl = nullptr) override; Version_t ReadVersion(UInt_t *start = nullptr, UInt_t *bcnt = nullptr, const TClass *cl = nullptr) override; @@ -95,10 +95,10 @@ class TBufferFile : public TBufferIO { void ClassEnd(const TClass*) override {} void ClassMember(const char*, const char * = nullptr, Int_t = -1, Int_t = -1) override {} - Int_t ReadBuf(void *buf, Int_t max) override; - void WriteBuf(const void *buf, Int_t max) override; + Long64_t ReadBuf(void *buf, Long64_t max) override; + void WriteBuf(const void *buf, Long64_t max) override; - char *ReadString(char *s, Int_t max) override; + char *ReadString(char *s, Long64_t max) override; void WriteString(const char *s) override; TClass *ReadClass(const TClass *cl = nullptr, UInt_t *objTag = nullptr) override; diff --git a/io/io/inc/TBufferIO.h b/io/io/inc/TBufferIO.h index 1500beed2616e..eeec87582d007 100644 --- a/io/io/inc/TBufferIO.h +++ b/io/io/inc/TBufferIO.h @@ -25,6 +25,8 @@ #include "TString.h" +#include + class TExMap; class TBufferIO : public TBuffer { @@ -44,8 +46,8 @@ class TBufferIO : public TBuffer { TBufferIO() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300 TBufferIO(TBuffer::EMode mode); - TBufferIO(TBuffer::EMode mode, Int_t bufsize); - TBufferIO(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, + TBufferIO(TBuffer::EMode mode, Long64_t bufsize); + TBufferIO(TBuffer::EMode mode, Long64_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr); //////////////////////////////////////////////////////////////////////////////// @@ -80,7 +82,7 @@ class TBufferIO : public TBuffer { void SetPidOffset(UShort_t offset) override; Int_t GetBufferDisplacement() const override { return fDisplacement; } void SetBufferDisplacement() override { fDisplacement = 0; } - void SetBufferDisplacement(Int_t skipped) override { fDisplacement = (Int_t)(Length() - skipped); } + void SetBufferDisplacement(Long64_t skipped) override { assert(skipped <= kMaxInt); fDisplacement = (Int_t)(Length() - skipped); } // Utilities for objects map void SetReadParam(Int_t mapsize) override; @@ -89,8 +91,8 @@ class TBufferIO : public TBuffer { void ResetMap() override; void Reset() override; Int_t GetMapCount() const override { return fMapCount; } - void MapObject(const TObject *obj, UInt_t offset = 1) override; - void MapObject(const void *obj, const TClass *cl, UInt_t offset = 1) override; + void MapObject(const TObject *obj, ULong64_t offset = 1) override; + void MapObject(const void *obj, const TClass *cl, ULong64_t offset = 1) override; Bool_t CheckObject(const TObject *obj) override; Bool_t CheckObject(const void *obj, const TClass *ptrClass) override; void GetMappedObject(UInt_t tag, void *&ptr, TClass *&ClassPtr) const override; @@ -98,8 +100,8 @@ class TBufferIO : public TBuffer { // Utilities for TStreamerInfo void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override; void ForceWriteInfoClones(TClonesArray *a) override; - Int_t ReadClones(TClonesArray *a, Int_t nobjects, Version_t objvers) override; - Int_t WriteClones(TClonesArray *a, Int_t nobjects) override; + Int_t ReadClones(TClonesArray *a, Long64_t nobjects, Version_t objvers) override; + Int_t WriteClones(TClonesArray *a, Long64_t nobjects) override; void TagStreamerInfo(TVirtualStreamerInfo *info) override; // Special basic ROOT objects and collections diff --git a/io/io/inc/TBufferText.h b/io/io/inc/TBufferText.h index e19cd7ca8d0e6..a5cbffc99deb0 100644 --- a/io/io/inc/TBufferText.h +++ b/io/io/inc/TBufferText.h @@ -75,20 +75,20 @@ class TBufferText : public TBufferIO { // virtual abstract TBuffer methods, which are not used in text streaming - Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const TClass * /* clss */) final { return 0; } - Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const char * /* classname */) final { return 0; } - void SetByteCount(UInt_t /* cntpos */, Bool_t /* packInVersion */ = kFALSE) final {} + Long64_t CheckByteCount(ULong64_t /* startpos */, ULong64_t /* bcnt */, const TClass * /* clss */) final { return 0; } + Long64_t CheckByteCount(ULong64_t /* startpos */, ULong64_t /* bcnt */, const char * /* classname */) final { return 0; } + void SetByteCount(ULong64_t /* cntpos */, Bool_t /* packInVersion */ = kFALSE) final {} void SkipVersion(const TClass *cl = nullptr) final; Version_t ReadVersionNoCheckSum(UInt_t *, UInt_t *) final { return 0; } - Int_t ReadBuf(void * /*buf*/, Int_t /*max*/) final + Long64_t ReadBuf(void * /*buf*/, Long64_t /*max*/) final { Error("ReadBuf", "useless in text streamers"); return 0; } - void WriteBuf(const void * /*buf*/, Int_t /*max*/) final { Error("WriteBuf", "useless in text streamers"); } + void WriteBuf(const void * /*buf*/, Long64_t /*max*/) final { Error("WriteBuf", "useless in text streamers"); } - char *ReadString(char * /*s*/, Int_t /*max*/) final + char *ReadString(char * /*s*/, Long64_t /*max*/) final { Error("ReadString", "useless"); return nullptr; diff --git a/io/io/inc/TDirectoryFile.h b/io/io/inc/TDirectoryFile.h index 16f2d2edaa4e4..f689eb25f6ecd 100644 --- a/io/io/inc/TDirectoryFile.h +++ b/io/io/inc/TDirectoryFile.h @@ -108,23 +108,23 @@ class TDirectoryFile : public TDirectory { void Purge(Short_t nkeep=1) override; void ReadAll(Option_t *option="") override; Int_t ReadKeys(Bool_t forceRead=kTRUE) override; - Int_t ReadTObject(TObject *obj, const char *keyname) override; + Long64_t ReadTObject(TObject *obj, const char *keyname) override; virtual void ResetAfterMerge(TFileMergeInfo *); void rmdir(const char *name) override; 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; + Long64_t SaveObjectAs(const TObject *obj, const char *filename="", Option_t *option="") const 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; + Long64_t Sizeof() const override; + Long64_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) override; + Long64_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) const override; + Long64_t WriteTObject(const TObject *obj, const char *name=nullptr, Option_t *option="", Long64_t bufsize=0) override; + Long64_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Long64_t bufsize=0) override; + Long64_t WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option="", Long64_t bufsize=0) override; void WriteDirHeader() override; void WriteKeys() override; diff --git a/io/io/inc/TFile.h b/io/io/inc/TFile.h index 5460e47384a41..54fc26d506dfd 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; @@ -322,8 +322,8 @@ class TFile : public TDirectoryFile { virtual Long64_t GetBytesWritten() const; virtual Int_t GetReadCalls() const { return fReadCalls; } Int_t GetVersion() const { return fVersion; } - Int_t GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes, - Int_t &nbytes, Int_t &objlen, Int_t &keylen); + Int_t GetRecordHeader(char *buf, Long64_t first, Long64_t maxbytes, + Long64_t &nbytes, Long64_t &objlen, Int_t &keylen); virtual Int_t GetNbytesInfo() const {return fNbytesInfo;} virtual Int_t GetNbytesFree() const {return fNbytesFree;} virtual TString GetNewUrl() { return ""; } @@ -372,11 +372,11 @@ class TFile : public TDirectoryFile { virtual void SetOption(Option_t *option=">") { fOption = option; } virtual void SetReadCalls(Int_t readcalls = 0) { fReadCalls = readcalls; } virtual void ShowStreamerInfo(); - Int_t Sizeof() const override; - void SumBuffer(Int_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; + Long64_t Sizeof() const override; + void SumBuffer(Long64_t bufsize); + virtual Bool_t WriteBuffer(const char *buf, Long64_t len); + Long64_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) override; + Long64_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..4218b585d96ea 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; } @@ -94,7 +94,7 @@ class TFileCacheRead : public TObject { Int_t GetNtot() const { return fNtot; } // Return the total size of the prefetched blocks. virtual Int_t GetReadCalls() const { return fReadCalls; } virtual Int_t GetNoCacheReadCalls() const { return fNoCacheReadCalls; } - virtual Int_t GetUnzipBuffer(char ** /*buf*/, Long64_t /*pos*/, Int_t /*len*/, Bool_t * /*free*/) { return -1; } + virtual Long64_t GetUnzipBuffer(char ** /*buf*/, Long64_t /*pos*/, Long64_t /*len*/, Bool_t * /*free*/) { return -1; } Long64_t GetPrefetchedBlocks() const { return fPrefetchedBlocks; } virtual Bool_t IsAsyncReading() const { return fAsyncReading; }; virtual void SetEnablePrefetching(Bool_t setPrefetching = kFALSE); @@ -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/TFree.h b/io/io/inc/TFree.h index 0acaad50aa1e5..631257e615c50 100644 --- a/io/io/inc/TFree.h +++ b/io/io/inc/TFree.h @@ -36,10 +36,10 @@ class TFree : public TObject { ~TFree() override; TFree *AddFree(TList *lfree, Long64_t first, Long64_t last); virtual void FillBuffer(char *&buffer); - TFree *GetBestFree(TList *lfree, Int_t nbytes); - Long64_t GetFirst() const {return fFirst;} - Long64_t GetLast() const {return fLast;} - void ls(Option_t * = "") const override; + TFree *GetBestFree(TList *lfree, Long64_t nbytes); + Long64_t GetFirst() const { return fFirst; } + Long64_t GetLast() const { return fLast; } + void ls(Option_t * = "") const override; virtual void ReadBuffer(char *&buffer); void SetFirst(Long64_t first) {fFirst=first;} void SetLast(Long64_t last) {fLast=last;} diff --git a/io/io/inc/TKey.h b/io/io/inc/TKey.h index a94081326ada1..71d4f5b332a26 100644 --- a/io/io/inc/TKey.h +++ b/io/io/inc/TKey.h @@ -51,21 +51,21 @@ class TKey : public TNamed { UShort_t fPidOffset; ///(fBufCur - fBuffer) + assert( cntpos <= kMaxUInt && (sizeof(UInt_t) + cntpos) < static_cast(fBufCur - fBuffer) && (fBufCur >= fBuffer) && static_cast(fBufCur - fBuffer) <= std::numeric_limits::max() && "Byte count position is after the end of the buffer"); - const UInt_t cnt = UInt_t(fBufCur - fBuffer) - cntpos - sizeof(UInt_t); + const UInt_t cnt = UInt_t(fBufCur - fBuffer) - UInt_t(cntpos) - sizeof(UInt_t); char *buf = (char *)(fBuffer + cntpos); // if true, pack byte count in two consecutive shorts, so it can @@ -358,11 +358,11 @@ void TBufferFile::SetByteCount(UInt_t cntpos, Bool_t packInVersion) /// Returns 0 if everything is ok, otherwise the bytecount offset /// (< 0 when read too little, >0 when read too much). -Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss, const char *classname) +Long64_t TBufferFile::CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss, const char *classname) { if (!bcnt) return 0; - - Int_t offset = 0; + R__ASSERT(startpos <= kMaxUInt && bcnt <= kMaxUInt); + Long64_t offset = 0; Longptr_t endpos = Longptr_t(fBuffer) + startpos + bcnt + sizeof(UInt_t); @@ -373,11 +373,11 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl if (name) { if (offset < 0) { - Error("CheckByteCount", "object of class %s read too few bytes: %d instead of %d", + Error("CheckByteCount", "object of class %s read too few bytes: %lld instead of %llu", name,bcnt+offset,bcnt); } if (offset > 0) { - Error("CheckByteCount", "object of class %s read too many bytes: %d instead of %d", + Error("CheckByteCount", "object of class %s read too many bytes: %lld instead of %llu", name,bcnt+offset,bcnt); if (fParent) Warning("CheckByteCount","%s::Streamer() not in sync with data on file %s, fix Streamer()", @@ -390,7 +390,7 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl if ( ((char *)endpos) > fBufMax ) { offset = fBufMax-fBufCur; Error("CheckByteCount", - "Byte count probably corrupted around buffer position %d:\n\t%d for a possible maximum of %d", + "Byte count probably corrupted around buffer position %llu:\n\t%llu for a possible maximum of %lld", startpos, bcnt, offset); fBufCur = fBufMax; @@ -411,7 +411,7 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl /// Returns 0 if everything is ok, otherwise the bytecount offset /// (< 0 when read too little, >0 when read too much). -Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) +Long64_t TBufferFile::CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss) { if (!bcnt) return 0; return CheckByteCount( startpos, bcnt, clss, nullptr); @@ -425,7 +425,7 @@ Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *cl /// Returns 0 if everything is ok, otherwise the bytecount offset /// (< 0 when read too little, >0 when read too much). -Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname) +Long64_t TBufferFile::CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const char *classname) { if (!bcnt) return 0; return CheckByteCount( startpos, bcnt, nullptr, classname); @@ -3332,13 +3332,13 @@ UInt_t TBufferFile::CheckObject(UInt_t offset, const TClass *cl, Bool_t readClas /// Read max bytes from the I/O buffer into buf. The function returns /// the actual number of bytes read. -Int_t TBufferFile::ReadBuf(void *buf, Int_t max) +Long64_t TBufferFile::ReadBuf(void *buf, Long64_t max) { R__ASSERT(IsReading()); if (max == 0) return 0; - Int_t n = std::min(max, (Int_t)(fBufMax - fBufCur)); + Long64_t n = std::min(max, (Long64_t)(fBufMax - fBufCur)); memcpy(buf, fBufCur, n); fBufCur += n; @@ -3349,7 +3349,7 @@ Int_t TBufferFile::ReadBuf(void *buf, Int_t max) //////////////////////////////////////////////////////////////////////////////// /// Write max bytes from buf into the I/O buffer. -void TBufferFile::WriteBuf(const void *buf, Int_t max) +void TBufferFile::WriteBuf(const void *buf, Long64_t max) { R__ASSERT(IsWriting()); @@ -3365,14 +3365,14 @@ void TBufferFile::WriteBuf(const void *buf, Int_t max) /// Read string from I/O buffer. String is read till 0 character is /// found or till max-1 characters are read (i.e. string s has max /// bytes allocated). If max = -1 no check on number of character is -/// made, reading continues till 0 character is found. +/// made, reading continues till 0 character is found or MaxInt-1 chars are read. -char *TBufferFile::ReadString(char *s, Int_t max) +char *TBufferFile::ReadString(char *s, Long64_t max) { R__ASSERT(IsReading()); - + R__ASSERT(max <= kMaxInt); char ch; - Int_t nr = 0; + Long64_t nr = 0; if (max == -1) max = kMaxInt; diff --git a/io/io/src/TBufferIO.cxx b/io/io/src/TBufferIO.cxx index 6e84623c9a56a..30df90184fee7 100644 --- a/io/io/src/TBufferIO.cxx +++ b/io/io/src/TBufferIO.cxx @@ -47,7 +47,7 @@ TBufferIO::TBufferIO(TBuffer::EMode mode) : TBuffer(mode) //////////////////////////////////////////////////////////////////////////////// /// constructor -TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize) : TBuffer(mode, bufsize) +TBufferIO::TBufferIO(TBuffer::EMode mode, Long64_t bufsize) : TBuffer(mode, bufsize) { fMapSize = fgMapSize; } @@ -55,7 +55,7 @@ TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize) : TBuffer(mode, bufsize //////////////////////////////////////////////////////////////////////////////// /// constructor -TBufferIO::TBufferIO(TBuffer::EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) +TBufferIO::TBufferIO(TBuffer::EMode mode, Long64_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc) : TBuffer(mode, bufsize, buf, adopt, reallocfunc) { fMapSize = fgMapSize; @@ -159,8 +159,9 @@ void TBufferIO::InitMap() /// contains (via via) a pointer to itself. In that case offset must be 1 /// (default value for offset). -void TBufferIO::MapObject(const TObject *obj, UInt_t offset) +void TBufferIO::MapObject(const TObject *obj, ULong64_t offset) { + R__ASSERT(offset <= kMaxUInt); if (IsWriting()) { if (!fMap) InitMap(); @@ -192,8 +193,9 @@ void TBufferIO::MapObject(const TObject *obj, UInt_t offset) /// contains (via via) a pointer to itself. In that case offset must be 1 /// (default value for offset). -void TBufferIO::MapObject(const void *obj, const TClass *cl, UInt_t offset) +void TBufferIO::MapObject(const void *obj, const TClass *cl, ULong64_t offset) { + R__ASSERT(offset <= kMaxUInt); if (IsWriting()) { if (!fMap) InitMap(); @@ -368,8 +370,9 @@ void TBufferIO::TagStreamerInfo(TVirtualStreamerInfo *info) //////////////////////////////////////////////////////////////////////////////// /// Interface to TStreamerInfo::ReadBufferClones. -Int_t TBufferIO::ReadClones(TClonesArray *a, Int_t nobjects, Version_t objvers) +Int_t TBufferIO::ReadClones(TClonesArray *a, Long64_t nobjects, Version_t objvers) { + assert(nobjects <= kMaxInt); char **arr = (char **)a->GetObjectRef(0); char **end = arr + nobjects; // a->GetClass()->GetStreamerInfo()->ReadBufferClones(*this,a,nobjects,-1,0); @@ -381,8 +384,9 @@ Int_t TBufferIO::ReadClones(TClonesArray *a, Int_t nobjects, Version_t objvers) //////////////////////////////////////////////////////////////////////////////// /// Interface to TStreamerInfo::WriteBufferClones. -Int_t TBufferIO::WriteClones(TClonesArray *a, Int_t nobjects) +Int_t TBufferIO::WriteClones(TClonesArray *a, Long64_t nobjects) { + assert(nobjects <= kMaxInt); char **arr = reinterpret_cast(a->GetObjectRef(0)); // a->GetClass()->GetStreamerInfo()->WriteBufferClones(*this,(TClonesArray*)a,nobjects,-1,0); TStreamerInfo *info = (TStreamerInfo *)a->GetClass()->GetStreamerInfo(); diff --git a/io/io/src/TBufferMergerFile.cxx b/io/io/src/TBufferMergerFile.cxx index 951891e2a46ec..a450ca228b9f8 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) +Long64_t TBufferMergerFile::Write(const char *name, Int_t opt, Long64_t bufsize) { // Make sure the compression of the basket is done in the unlocked thread and // not in the locked section. diff --git a/io/io/src/TDirectoryFile.cxx b/io/io/src/TDirectoryFile.cxx index d4f33a9c12a6e..c37d8480d8c09 100644 --- a/io/io/src/TDirectoryFile.cxx +++ b/io/io/src/TDirectoryFile.cxx @@ -153,7 +153,7 @@ void TDirectoryFile::InitDirectoryFile(TClass *cl) } TDirectory* motherdir = GetMotherDir(); fSeekParent = motherdir->GetSeekDir(); - Int_t nbytes = TDirectoryFile::Sizeof(); + Long64_t nbytes = TDirectoryFile::Sizeof(); TKey *key = new TKey(fName,fTitle,cl,nbytes,motherdir); fNbytesName = key->GetKeylen(); fSeekDir = key->GetSeekKey(); @@ -406,7 +406,7 @@ TObject *TDirectoryFile::CloneObject(const TObject *obj, Bool_t autoadd /* = kTR // during the streaming .... TFile *filsav = gFile; gFile = nullptr; - const Int_t bufsize = 10000; + const Long64_t bufsize = 10000; TBufferFile buffer(TBuffer::kWrite,bufsize); buffer.MapObject(obj); //register obj in map to handle self reference { @@ -1406,7 +1406,7 @@ Int_t TDirectoryFile::ReadKeys(Bool_t forceRead) fKeys->Delete(); //In case directory was updated by another process, read new //position for the keys - Int_t nbytes = fNbytesName + TDirectoryFile::Sizeof(); + Long64_t nbytes = fNbytesName + TDirectoryFile::Sizeof(); char *header = new char[nbytes]; buffer = header; fFile->Seek(fSeekDir); @@ -1478,7 +1478,7 @@ Int_t TDirectoryFile::ReadKeys(Bool_t forceRead) /// The object must have been created before via the default constructor. /// See TObject::Write(). -Int_t TDirectoryFile::ReadTObject(TObject *obj, const char *keyname) +Long64_t TDirectoryFile::ReadTObject(TObject *obj, const char *keyname) { if (!fFile) { Error("ReadTObject","No file open"); return 0; } auto listOfKeys = dynamic_cast(GetListOfKeys()); @@ -1599,7 +1599,7 @@ void TDirectoryFile::Save() /// JavaScript ROOT (https://root.cern/js/) to display object in web browser /// When creating JSON file, option string may contain compression level from 0 to 3 (default 0) -Int_t TDirectoryFile::SaveObjectAs(const TObject *obj, const char *filename, Option_t *option) const +Long64_t TDirectoryFile::SaveObjectAs(const TObject *obj, const char *filename, Option_t *option) const { // option can contain single letter args: "a" for append, "q" for quiet in any combinations @@ -1611,7 +1611,7 @@ Int_t TDirectoryFile::SaveObjectAs(const TObject *obj, const char *filename, Opt fname.Form("%s.root", obj->GetName()); opt.ToLower(); - Int_t nbytes = 0; + Long64_t nbytes = 0; if (fname.Index(".json") > 0) { nbytes = TBufferJSON::ExportToFile(fname, obj, option); } else { @@ -1662,8 +1662,10 @@ void TDirectoryFile::SaveSelf(Bool_t force) /// /// See also TDirectoryFile::GetBufferSize -void TDirectoryFile::SetBufferSize(Int_t bufsize) +void TDirectoryFile::SetBufferSize(Long64_t bufsize) { + if (bufsize > kMaxInt) + Fatal("SetBufferSize", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); fBufferSize = bufsize; } @@ -1719,9 +1721,9 @@ void TDirectoryFile::SetWritable(Bool_t writable) //////////////////////////////////////////////////////////////////////////////// /// Return the size in bytes of the directory header -Int_t TDirectoryFile::Sizeof() const +Long64_t TDirectoryFile::Sizeof() const { - Int_t nbytes = 22; + Long64_t nbytes = 22; nbytes += fDatimeC.Sizeof(); nbytes += fDatimeM.Sizeof(); @@ -1850,7 +1852,7 @@ void TDirectoryFile::Streamer(TBuffer &b) /// For allowed options see TObject::Write(). /// The directory header info is rewritten on the directory header record. -Int_t TDirectoryFile::Write(const char *, Int_t opt, Int_t bufsize) +Long64_t TDirectoryFile::Write(const char *, Int_t opt, Long64_t bufsize) { if (!IsWritable()) return 0; TDirectory::TContext ctxt(this); @@ -1858,7 +1860,7 @@ Int_t TDirectoryFile::Write(const char *, Int_t opt, Int_t bufsize) // Loop on all objects (including subdirs) TIter next(fList); TObject *obj; - Int_t nbytes = 0; + Long64_t nbytes = 0; while ((obj=next())) { nbytes += obj->Write(0,opt,bufsize); } @@ -1871,7 +1873,7 @@ Int_t TDirectoryFile::Write(const char *, Int_t opt, Int_t bufsize) //////////////////////////////////////////////////////////////////////////////// /// One can not save a const TDirectory object. -Int_t TDirectoryFile::Write(const char *n, Int_t opt, Int_t bufsize) const +Long64_t TDirectoryFile::Write(const char *n, Int_t opt, Long64_t bufsize) const { Error("Write const","A const TDirectory object should not be saved. We try to proceed anyway."); return const_cast(this)->Write(n, opt, bufsize); @@ -1921,7 +1923,7 @@ Int_t TDirectoryFile::Write(const char *n, Int_t opt, Int_t bufsize) const /// WARNING: avoid special characters like '^','$','.' in the name as they /// are used by the regular expression parser (see TRegexp). -Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_t *option, Int_t bufsize) +Long64_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_t *option, Long64_t bufsize) { TDirectory::TContext ctxt(this); @@ -1948,7 +1950,11 @@ Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_ TKey *key=0, *oldkey=0; Int_t bsize = GetBufferSize(); - if (bufsize > 0) bsize = bufsize; + if (bufsize > 0) { + if (bufsize > kMaxInt) + Fatal("WriteTObject", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + bsize = bufsize; + } const char *oname; if (name && *name) @@ -1993,7 +1999,7 @@ Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_ return 0; } fFile->SumBuffer(key->GetObjlen()); - Int_t nbytes = key->WriteFile(0); + Long64_t nbytes = key->WriteFile(0); if (fFile->TestBit(TFile::kWriteError)) { if (bufsize) fFile->SetBufferSize(bufsize); return 0; @@ -2036,7 +2042,8 @@ 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) +Long64_t TDirectoryFile::WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option, + Long64_t bufsize) { TClass *cl = TClass::GetClass(classname); if (!cl) { @@ -2063,7 +2070,8 @@ 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) +Long64_t +TDirectoryFile::WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option, Long64_t bufsize) { TDirectory::TContext ctxt(this); @@ -2102,7 +2110,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(); @@ -2141,7 +2152,7 @@ Int_t TDirectoryFile::WriteObjectAny(const void *obj, const TClass *cl, const ch return 0; } fFile->SumBuffer(key->GetObjlen()); - Int_t nbytes = key->WriteFile(0); + Long64_t nbytes = key->WriteFile(0); if (fFile->TestBit(TFile::kWriteError)) return 0; if (oldkey) { @@ -2166,7 +2177,7 @@ void TDirectoryFile::WriteDirHeader() return; } - Int_t nbytes = TDirectoryFile::Sizeof(); //Warning ! TFile has a Sizeof() + Long64_t nbytes = TDirectoryFile::Sizeof(); //Warning ! TFile has a Sizeof() char *header = new char[nbytes]; char *buffer = header; fDatimeM.Set(); @@ -2202,7 +2213,7 @@ void TDirectoryFile::WriteKeys() TIter next(fKeys); TKey *key; Int_t nkeys = fKeys->GetSize(); - Int_t nbytes = sizeof nkeys; //*-* Compute size of all keys + Long64_t nbytes = sizeof nkeys; //*-* Compute size of all keys if (f->GetEND() > TFile::kStartBigFile) nbytes += 8; while ((key = (TKey*)next())) { nbytes += key->Sizeof(); diff --git a/io/io/src/TFile.cxx b/io/io/src/TFile.cxx index 35b4acddc184a..d9ef00acba7d8 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -675,7 +675,7 @@ void TFile::Init(Bool_t create) //*-* Write Directory info Int_t namelen= TNamed::Sizeof(); - Int_t nbytes = namelen + TDirectoryFile::Sizeof(); + Long64_t nbytes = namelen + TDirectoryFile::Sizeof(); TKey *key = new TKey(fName, fTitle, IsA(), nbytes, this); fNbytesName = key->GetKeylen() + namelen; fSeekDir = key->GetSeekKey(); @@ -756,7 +756,7 @@ void TFile::Init(Bool_t create) // buffer_keyloc is the start of the key record. char *buffer_keyloc = nullptr; - Int_t nbytes = fNbytesName + TDirectoryFile::Sizeof(); + Long64_t nbytes = fNbytesName + TDirectoryFile::Sizeof(); if ( (nbytes + fBEGIN) > fEND) { // humm fBEGIN is wrong .... Error("Init","file %s has an incorrect header length (%lld) or incorrect end of file length (%lld)", @@ -771,7 +771,7 @@ void TFile::Init(Bool_t create) Seek(fBEGIN); // NOLINT: silence clang-tidy warnings if (ReadBuffer(buffer,nbytes)) { // NOLINT: silence clang-tidy warnings // ReadBuffer returns kTRUE in case of failure. - Error("Init","%s failed to read the file header information at %lld (size=%d)", + Error("Init","%s failed to read the file header information at %lld (size=%lld)", GetName(),fBEGIN,nbytes); delete [] header; goto zombie; @@ -1053,7 +1053,7 @@ void TFile::Close(Option_t *option) //////////////////////////////////////////////////////////////////////////////// /// Creates key for object and converts data to buffer. -TKey* TFile::CreateKey(TDirectory* mother, const TObject* obj, const char* name, Int_t bufsize) +TKey* TFile::CreateKey(TDirectory* mother, const TObject* obj, const char* name, Long64_t bufsize) { return new TKey(obj, name, bufsize, mother); } @@ -1061,7 +1061,7 @@ TKey* TFile::CreateKey(TDirectory* mother, const TObject* obj, const char* name, //////////////////////////////////////////////////////////////////////////////// /// Creates key for object and converts data to buffer. -TKey* TFile::CreateKey(TDirectory* mother, const void* obj, const TClass* cl, const char* name, Int_t bufsize) +TKey* TFile::CreateKey(TDirectory* mother, const void* obj, const TClass* cl, const char* name, Long64_t bufsize) { return new TKey(obj, cl, name, bufsize, mother); } @@ -1288,7 +1288,8 @@ TFileCacheWrite *TFile::GetCacheWrite() const /// Note that the arguments objlen and keylen are returned only /// if maxbytes >=16 -Int_t TFile::GetRecordHeader(char *buf, Long64_t first, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen) +Int_t TFile::GetRecordHeader(char *buf, Long64_t first, Long64_t maxbytes, Long64_t &nbytes, Long64_t &objlen, + Int_t &keylen) { nbytes = 0; objlen = 0; @@ -1649,7 +1650,7 @@ std::optional ROOT::Detail::TKeyMapIterable::TIterato } char *buffer = header; - Int_t nbytes; + Long64_t nbytes; frombuf(buffer, &nbytes); if (!nbytes) { auto node = ROOT::Detail::TKeyMapNode{idcur, ROOT::Detail::TKeyMapNode::kError}; @@ -2425,7 +2426,7 @@ void TFile::SetCacheWrite(TFileCacheWrite *cache) //////////////////////////////////////////////////////////////////////////////// /// Return the size in bytes of the file header. -Int_t TFile::Sizeof() const +Long64_t TFile::Sizeof() const { return 0; } @@ -2445,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; } //////////////////////////////////////////////////////////////////////////////// @@ -2464,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) +Long64_t TFile::Write(const char *, Int_t opt, Long64_t bufsize) { if (!IsWritable()) { if (!TestBit(kWriteError)) { @@ -2482,7 +2488,7 @@ Int_t TFile::Write(const char *, Int_t opt, Int_t bufsize) } fMustFlush = kFALSE; - Int_t nbytes = TDirectoryFile::Write(0, opt, bufsize); // Write directory tree + Long64_t nbytes = TDirectoryFile::Write(0, opt, bufsize); // Write directory tree WriteStreamerInfo(); WriteFree(); // Write free segments linked list WriteHeader(); // Now write file header @@ -2494,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 +Long64_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); @@ -2504,7 +2510,7 @@ Int_t TFile::Write(const char *n, Int_t opt, Int_t bufsize) const /// Write a buffer to the file. This is the basic low level write operation. /// Returns kTRUE in case of failure. -Bool_t TFile::WriteBuffer(const char *buf, Int_t len) +Bool_t TFile::WriteBuffer(const char *buf, Long64_t len) { if (IsOpen() && fWritable) { @@ -2528,7 +2534,7 @@ Bool_t TFile::WriteBuffer(const char *buf, Int_t len) } if (siz != len) { SetBit(kWriteError); - Error("WriteBuffer", "error writing all requested bytes to file %s, wrote %ld of %d", + Error("WriteBuffer", "error writing all requested bytes to file %s, wrote %ld of %lld", GetName(), (Long_t)siz, len); return kTRUE; } @@ -2581,7 +2587,7 @@ void TFile::WriteFree() Bool_t largeFile = (fEND > TFile::kStartBigFile); auto createKey = [this]() { - Int_t nbytes = 0; + Long64_t nbytes = 0; TFree *afree; TIter next (fFree); while ((afree = (TFree*) next())) { @@ -2613,7 +2619,7 @@ void TFile::WriteFree() if (!key) return; } - Int_t nbytes = key->GetObjlen(); + Long64_t nbytes = key->GetObjlen(); char *buffer = key->GetBuffer(); char *start = buffer; @@ -2631,7 +2637,7 @@ void TFile::WriteFree() // TKey, so we had one less TFree to store than we planned. memset(buffer,0,nbytes-actualBytes); } else { - Error("WriteFree","The free block list TKey wrote more data than expected (%d vs %ld). Most likely there has been an out-of-bound write.",nbytes,(long int)actualBytes); + Error("WriteFree","The free block list TKey wrote more data than expected (%lld vs %ld). Most likely there has been an out-of-bound write.",nbytes,(long int)actualBytes); } } fNbytesFree = key->GetNbytes(); @@ -2682,7 +2688,7 @@ void TFile::WriteHeader() TUUID("00000000-0000-0000-0000-000000000000").FillBuffer(buffer); else fUUID.FillBuffer(buffer); - Int_t nbytes = buffer - psave; + Long64_t nbytes = buffer - psave; Seek(0); // NOLINT: silence clang-tidy warnings WriteBuffer(psave, nbytes); // NOLINT: silence clang-tidy warnings Flush(); // NOLINT: silence clang-tidy warnings, Intentionally not conditional on fMustFlush, this is the 'obligatory' flush. @@ -4286,16 +4292,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 +4703,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 +4758,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 +4785,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 +4811,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 +4840,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 351adbf2b7958..8b50683fc5a4a 100644 --- a/io/io/src/TFileCacheRead.cxx +++ b/io/io/src/TFileCacheRead.cxx @@ -89,9 +89,14 @@ TFileCacheRead::TFileCacheRead() : TObject() //////////////////////////////////////////////////////////////////////////////// /// Creates a TFileCacheRead data structure. -TFileCacheRead::TFileCacheRead(TFile *file, Int_t bufsize, TObject *tree) +TFileCacheRead::TFileCacheRead(TFile *file, Long64_t bufsize, TObject *tree) : TObject() { + if (bufsize < 0) + Fatal("TFileCacheRead", "Negative buffer size: 0x%llx.", bufsize); + else if (bufsize > kMaxInt) { + Fatal("TFileCacheRead", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + } if (bufsize <=10000) fBufferSize = 100000; else fBufferSize = bufsize; diff --git a/io/io/src/TFileCacheWrite.cxx b/io/io/src/TFileCacheWrite.cxx index 5aadb50ce8791..89c197ac0b1e8 100644 --- a/io/io/src/TFileCacheWrite.cxx +++ b/io/io/src/TFileCacheWrite.cxx @@ -49,9 +49,14 @@ TFileCacheWrite::TFileCacheWrite() : TObject() /// The size of the cache will be bufsize, /// if bufsize < 10000 a default size of 512 Kbytes is used -TFileCacheWrite::TFileCacheWrite(TFile *file, Int_t bufsize) +TFileCacheWrite::TFileCacheWrite(TFile *file, Long64_t bufsize) : TObject() { + if (bufsize < 0) + Fatal("TFileCacheWrite", "Negative buffer size: 0x%llx.", bufsize); + else if (bufsize > kMaxInt) { + Fatal("TFileCacheWrite", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); + } if (bufsize < 10000) bufsize = 512000; fBufferSize = bufsize; fSeekStart = 0; @@ -60,7 +65,7 @@ TFileCacheWrite::TFileCacheWrite(TFile *file, Int_t bufsize) fRecursive = kFALSE; fBuffer = new char[fBufferSize]; if (file) file->SetCacheWrite(this); - if (gDebug > 0) Info("TFileCacheWrite","Creating a write cache with buffersize=%d bytes",bufsize); + if (gDebug > 0) Info("TFileCacheWrite","Creating a write cache with buffersize=%lld bytes",bufsize); } //////////////////////////////////////////////////////////////////////////////// diff --git a/io/io/src/TFree.cxx b/io/io/src/TFree.cxx index 5001c67a45982..340a5c72779b7 100644 --- a/io/io/src/TFree.cxx +++ b/io/io/src/TFree.cxx @@ -123,7 +123,7 @@ void TFree::FillBuffer(char *&buffer) //////////////////////////////////////////////////////////////////////////////// /// Return the best free segment where to store nbytes. -TFree *TFree::GetBestFree(TList *lfree, Int_t nbytes) +TFree *TFree::GetBestFree(TList *lfree, Long64_t nbytes) { TFree *idcur = this; if (idcur == 0) return 0; diff --git a/io/io/src/TKey.cxx b/io/io/src/TKey.cxx index 2567681d839bc..ed8045dec39c0 100644 --- a/io/io/src/TKey.cxx +++ b/io/io/src/TKey.cxx @@ -171,11 +171,16 @@ TKey::TKey(TDirectory* motherDir, const TKey &orig, UShort_t pidOffset) : TNamed /// Constructor called by TDirectoryFile::ReadKeys and by TFile::TFile. /// A TKey object is created to read the keys structure itself. -TKey::TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir) : TNamed() +TKey::TKey(Long64_t pointer, Long64_t nbytes, TDirectory* motherDir) : TNamed() { Build(motherDir, "", pointer); fSeekKey = pointer; + if (nbytes > kMaxInt) { + Fatal("TKey", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("TKey", "Negative byte size: 0x%llx.", nbytes); + } fNbytes = nbytes; fBuffer = new char[nbytes]; keyAbsNumber++; SetUniqueID(keyAbsNumber); @@ -187,12 +192,17 @@ TKey::TKey(Long64_t pointer, Int_t nbytes, TDirectory* motherDir) : TNamed() /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const char *name, const char *title, const TClass *cl, Int_t nbytes, TDirectory* motherDir) +TKey::TKey(const char *name, const char *title, const TClass *cl, Long64_t nbytes, TDirectory* motherDir) : TNamed(name,title) { Build(motherDir, cl->GetName(), -1); fKeylen = Sizeof(); + if (nbytes > kMaxInt) { + Fatal("TKey", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("TKey", "Negative byte size: 0x%llx.", nbytes); + } fObjlen = nbytes; Create(nbytes); } @@ -203,12 +213,17 @@ TKey::TKey(const char *name, const char *title, const TClass *cl, Int_t nbytes, /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const TString &name, const TString &title, const TClass *cl, Int_t nbytes, TDirectory* motherDir) +TKey::TKey(const TString &name, const TString &title, const TClass *cl, Long64_t nbytes, TDirectory* motherDir) : TNamed(name,title) { Build(motherDir, cl->GetName(), -1); fKeylen = Sizeof(); + if (nbytes > kMaxInt) { + Fatal("TKey", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("TKey", "Negative byte size: 0x%llx.", nbytes); + } fObjlen = nbytes; Create(nbytes); } @@ -219,7 +234,7 @@ TKey::TKey(const TString &name, const TString &title, const TClass *cl, Int_t nb /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const TObject *obj, const char *name, Int_t bufsize, TDirectory* motherDir) +TKey::TKey(const TObject *obj, const char *name, Long64_t bufsize, TDirectory* motherDir) : TNamed(name, obj->GetTitle()) { R__ASSERT(obj); @@ -294,7 +309,7 @@ TKey::TKey(const TObject *obj, const char *name, Int_t bufsize, TDirectory* moth /// WARNING: in name avoid special characters like '^','$','.' that are used /// by the regular expression parser (see TRegexp). -TKey::TKey(const void *obj, const TClass *cl, const char *name, Int_t bufsize, TDirectory *motherDir) : TNamed(name, "") +TKey::TKey(const void *obj, const TClass *cl, const char *name, Long64_t bufsize, TDirectory *motherDir) : TNamed(name, "") { R__ASSERT(obj && cl); @@ -458,7 +473,7 @@ void TKey::Browse(TBrowser *b) /// If externFile!=0, key will be allocated in specified file, otherwise file /// of mother directory will be used. -void TKey::Create(Int_t nbytes, TFile* externFile) +void TKey::Create(Long64_t nbytes, TFile* externFile) { keyAbsNumber++; SetUniqueID(keyAbsNumber); @@ -468,7 +483,11 @@ void TKey::Create(Int_t nbytes, TFile* externFile) Error("Create","Cannot create key without file"); return; } - + if (nbytes > kMaxInt - fKeylen) { + Fatal("Create", "Integer overflow in byte size: 0x%llx for a max of 0x%x.", nbytes, kMaxInt); + } else if (nbytes < 0) { + Fatal("Create", "Negative byte size: 0x%llx.", nbytes); + } Int_t nsize = nbytes + fKeylen; TList *lfree = f->GetListOfFree(); TFree *f1 = (TFree*)lfree->First(); @@ -1342,9 +1361,9 @@ void TKey::Reset() /// | fTitle | 1+ bytes | /// | **TOTAL** | 29+ or 37+ | -Int_t TKey::Sizeof() const +Long64_t TKey::Sizeof() const { - Int_t nbytes = 22; if (fVersion > 1000) nbytes += 8; + Long64_t nbytes = 22; if (fVersion > 1000) nbytes += 8; nbytes += fDatime.Sizeof(); if (TestBit(kIsDirectoryFile)) { nbytes += 11; // strlen("TDirectory")+1 @@ -1488,7 +1507,7 @@ Int_t TKey::WriteFile(Int_t cycle, TFile* f) /// The function returns the number of bytes committed to the file. /// If a write error occurs, the number of bytes returned is -1. -Int_t TKey::WriteFileKeepBuffer(TFile *f) +Long64_t TKey::WriteFileKeepBuffer(TFile *f) { if (!f) f = GetFile(); if (!f) return -1; diff --git a/io/io/src/TMapFile.cxx b/io/io/src/TMapFile.cxx index 6dd0718b8fd42..d1df7e84bb17e 100644 --- a/io/io/src/TMapFile.cxx +++ b/io/io/src/TMapFile.cxx @@ -1124,7 +1124,7 @@ void TMapFile::ls(Option_t *) const //////////////////////////////////////////////////////////////////////////////// /// Increment statistics for buffer sizes of objects in this file. -void TMapFile::SumBuffer(Int_t bufsize) +void TMapFile::SumBuffer(Long64_t bufsize) { fWritten++; fSumBuffer += bufsize; diff --git a/io/sql/inc/TSQLFile.h b/io/sql/inc/TSQLFile.h index 6212462db8621..83316e348248b 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 {} @@ -242,11 +242,11 @@ class TSQLFile final : public TFile { void Seek(Long64_t, ERelativeTo = kBeg) final {} void SetEND(Long64_t) final {} - Int_t Sizeof() const final { return 0; } + Long64_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; } + Bool_t WriteBuffer(const char *, Long64_t) final { return kFALSE; } + Long64_t Write(const char * = nullptr, Int_t = 0, Long64_t = 0) final { return 0; } + Long64_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 5d4db4cfd34d9..52b5ea857c281 100644 --- a/io/sql/src/TSQLFile.cxx +++ b/io/sql/src/TSQLFile.cxx @@ -762,7 +762,7 @@ Int_t TSQLFile::ReOpen(Option_t *mode) //////////////////////////////////////////////////////////////////////////////// /// create SQL key, which will store object in data base -TKey *TSQLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t) +TKey *TSQLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Long64_t) { return new TKeySQL(mother, obj, name); } @@ -770,7 +770,7 @@ TKey *TSQLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *na //////////////////////////////////////////////////////////////////////////////// /// create SQL key, which will store object in data base -TKey *TSQLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t) +TKey *TSQLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Long64_t) { return new TKeySQL(mother, obj, cl, name); } diff --git a/io/xml/inc/TKeyXML.h b/io/xml/inc/TKeyXML.h index 9294990dd8400..0e0757f6a6a30 100644 --- a/io/xml/inc/TKeyXML.h +++ b/io/xml/inc/TKeyXML.h @@ -66,7 +66,7 @@ class TKeyXML final : public TKey { void UpdateAttributes(); protected: - Int_t Read(const char *name) final { return TKey::Read(name); } + Long64_t Read(const char *name) final { return TKey::Read(name); } void StoreObject(const void *obj, const TClass *cl, Bool_t check_tobj = kFALSE); void StoreKeyAttributes(); TXMLEngine *XMLEngine(); diff --git a/io/xml/inc/TXMLFile.h b/io/xml/inc/TXMLFile.h index 12cbc41de4571..4adb8628b5434 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 {} @@ -88,11 +88,11 @@ class TXMLFile final : public TFile, public TXMLSetup { void Seek(Long64_t, ERelativeTo = kBeg) final {} void SetEND(Long64_t) final {} - Int_t Sizeof() const final { return 0; } + Long64_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; } + Bool_t WriteBuffer(const char *, Long64_t) final { return kFALSE; } + Long64_t Write(const char * = nullptr, Int_t = 0, Long64_t = 0) final { return 0; } + Long64_t Write(const char * = nullptr, Int_t = 0, Long64_t = 0) const final { return 0; } void WriteFree() final {} void WriteHeader() final {} void WriteStreamerInfo() final; diff --git a/io/xml/src/TXMLFile.cxx b/io/xml/src/TXMLFile.cxx index 631f4e963ee34..658c57baa1b6e 100644 --- a/io/xml/src/TXMLFile.cxx +++ b/io/xml/src/TXMLFile.cxx @@ -404,7 +404,7 @@ Int_t TXMLFile::ReOpen(Option_t *mode) //////////////////////////////////////////////////////////////////////////////// /// create XML key, which will store object in xml structures -TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t) +TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *name, Long64_t) { return new TKeyXML(mother, ++fKeyCounter, obj, name); } @@ -412,7 +412,7 @@ TKey *TXMLFile::CreateKey(TDirectory *mother, const TObject *obj, const char *na //////////////////////////////////////////////////////////////////////////////// /// create XML key, which will store object in xml structures -TKey *TXMLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Int_t) +TKey *TXMLFile::CreateKey(TDirectory *mother, const void *obj, const TClass *cl, const char *name, Long64_t) { return new TKeyXML(mother, ++fKeyCounter, obj, cl, name); } diff --git a/main/src/h2root.cxx b/main/src/h2root.cxx index b839c9d8319b4..62076d196abee 100644 --- a/main/src/h2root.cxx +++ b/main/src/h2root.cxx @@ -252,7 +252,7 @@ extern void convert_cwn(Int_t id); extern void convert_rwn(Int_t id); Int_t golower = 1; -Int_t bufsize = 64000; +Long64_t bufsize = 64000; Int_t optcwn = 1; int main(int argc, char **argv) { @@ -280,7 +280,7 @@ int main(int argc, char **argv) optcwn = atoi(argv[7]); } if (argc > 6) { - bufsize = atoi(argv[6]); + bufsize = atol(argv[6]); } if (argc > 5) { record_size = atoi(argv[5]); diff --git a/net/davix/inc/TDavixFile.h b/net/davix/inc/TDavixFile.h index 5ab75f8e9b92e..92a3f91521593 100644 --- a/net/davix/inc/TDavixFile.h +++ b/net/davix/inc/TDavixFile.h @@ -105,7 +105,7 @@ class TDavixFile : public TFile { Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override; Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override; Bool_t ReadBufferAsync(Long64_t offs, Int_t len) override; - Bool_t WriteBuffer(const char *buffer, Int_t bufferLength) override; + Bool_t WriteBuffer(const char *buffer, Long64_t bufsiz) override; TString GetNewUrl() override; // TDavixFile options diff --git a/net/davix/src/TDavixFile.cxx b/net/davix/src/TDavixFile.cxx index 7533d77aff034..e9e27f8096c97 100644 --- a/net/davix/src/TDavixFile.cxx +++ b/net/davix/src/TDavixFile.cxx @@ -796,19 +796,19 @@ Bool_t TDavixFile::ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) //////////////////////////////////////////////////////////////////////////////// -Bool_t TDavixFile::WriteBuffer(const char *buf, Int_t len) +Bool_t TDavixFile::WriteBuffer(const char *buf, Long64_t bufsiz) { Davix_fd *fd; if ((fd = d_ptr->getDavixFileInstance()) == NULL) return kTRUE; - Long64_t ret = DavixWriteBuffer(fd, buf, len); + Long64_t ret = DavixWriteBuffer(fd, buf, bufsiz); if (ret < 0) return kTRUE; if (gDebug > 1) Info("WriteBuffer", "%lld bytes of data write" - " %d requested", ret, len); + " %lld requested", ret, bufsiz); return kFALSE; } 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/TNetFile.h b/net/net/inc/TNetFile.h index f21fb07f48107..6bd6f49e7cb54 100644 --- a/net/net/inc/TNetFile.h +++ b/net/net/inc/TNetFile.h @@ -73,7 +73,7 @@ class TNetFile : public TFile { Bool_t ReadBuffer(char *buf, Int_t len) override; Bool_t ReadBuffer(char *buf, Long64_t pos, Int_t len) override; Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override; - Bool_t WriteBuffer(const char *buf, Int_t len) override; + Bool_t WriteBuffer(const char *buf, Long64_t len) override; void Seek(Long64_t offset, ERelativeTo pos = kBeg) override; const TUrl *GetEndpointUrl() const override { return &fEndpointUrl; } diff --git a/net/net/inc/TParallelMergingFile.h b/net/net/inc/TParallelMergingFile.h index 8f15d7ccee07c..d6e017934e3d8 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; + Long64_t Write(const char *name = nullptr, Int_t opt = 0, Long64_t bufsize = 0) override; + Long64_t Write(const char *name=nullptr, Int_t opt=0, Long64_t bufsize=0) const override; void WriteStreamerInfo() override; Int_t GetServerIdx() const { return fServerIdx; } diff --git a/net/net/src/TMessage.cxx b/net/net/src/TMessage.cxx index de34e427a5a3d..d2a2a0c6c3833 100644 --- a/net/net/src/TMessage.cxx +++ b/net/net/src/TMessage.cxx @@ -42,7 +42,7 @@ Bool_t TMessage::fgEvolution = kFALSE; /// the message will be compressed in TSocket using the zip algorithm /// (only if message is > 256 bytes). -TMessage::TMessage(UInt_t what, Int_t bufsize) : +TMessage::TMessage(UInt_t what, Long64_t bufsize) : TBufferFile(TBuffer::kWrite, bufsize + 2*sizeof(UInt_t)), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal) { @@ -67,7 +67,7 @@ TMessage::TMessage(UInt_t what, Int_t bufsize) : /// Create a TMessage object for reading objects. The objects will be /// read from buf. Use the What() method to get the message type. -TMessage::TMessage(void *buf, Int_t bufsize, Bool_t adopt) : TBufferFile(TBuffer::kRead, bufsize, buf, adopt), +TMessage::TMessage(void *buf, Long64_t bufsize, Bool_t adopt) : TBufferFile(TBuffer::kRead, bufsize, buf, adopt), fCompress(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal) { // skip space at the beginning of the message reserved for the message length diff --git a/net/net/src/TNetFile.cxx b/net/net/src/TNetFile.cxx index 5ce7bbd0d77f7..6552bedb28f47 100644 --- a/net/net/src/TNetFile.cxx +++ b/net/net/src/TNetFile.cxx @@ -483,13 +483,13 @@ Bool_t TNetFile::ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) /// Write specified byte range to remote file via rootd daemon. /// Returns kTRUE in case of error. -Bool_t TNetFile::WriteBuffer(const char *buf, Int_t len) +Bool_t TNetFile::WriteBuffer(const char *buf, Long64_t len) { if (!fSocket || !fWritable) return kTRUE; Bool_t result = kFALSE; - Int_t st; + Long64_t st; if ((st = WriteBufferViaCache(buf, len))) { if (st == 2) return kTRUE; @@ -498,7 +498,7 @@ Bool_t TNetFile::WriteBuffer(const char *buf, Int_t len) gSystem->IgnoreInterrupt(); - if (fSocket->Send(Form("%lld %d", fOffset, len), kROOTD_PUT) < 0) { + if (fSocket->Send(Form("%lld %lld", fOffset, len), kROOTD_PUT) < 0) { SetBit(kWriteError); Error("WriteBuffer", "error sending kROOTD_PUT command"); result = kTRUE; diff --git a/net/net/src/TParallelMergingFile.cxx b/net/net/src/TParallelMergingFile.cxx index 894a093578611..1c5fd5f9e3c8c 100644 --- a/net/net/src/TParallelMergingFile.cxx +++ b/net/net/src/TParallelMergingFile.cxx @@ -175,9 +175,9 @@ 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) +Long64_t TParallelMergingFile::Write(const char *, Int_t opt, Long64_t bufsize) { - Int_t nbytes = TMemFile::Write(0,opt,bufsize); + Long64_t nbytes = TMemFile::Write(0,opt,bufsize); if (nbytes) { UploadAndReset(); } @@ -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 +Long64_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/net/netxng/inc/TNetXNGFile.h b/net/netxng/inc/TNetXNGFile.h index e22912085282f..dc2c28b6c68ac 100644 --- a/net/netxng/inc/TNetXNGFile.h +++ b/net/netxng/inc/TNetXNGFile.h @@ -58,7 +58,7 @@ class TNetXNGFile: public TFile { Long64_t GetSize() const override; Int_t ReOpen(Option_t *modestr) override; Bool_t IsOpen() const override; - Bool_t WriteBuffer(const char *buffer, Int_t length) override; + Bool_t WriteBuffer(const char *buffer, Long64_t length) override; void Flush() override; Bool_t ReadBuffer(char *buffer, Int_t length) override; Bool_t ReadBuffer(char *buffer, Long64_t position, Int_t length) override; diff --git a/net/netxng/src/TNetXNGFile.cxx b/net/netxng/src/TNetXNGFile.cxx index 0b832f2c7fddd..005a042a98c38 100644 --- a/net/netxng/src/TNetXNGFile.cxx +++ b/net/netxng/src/TNetXNGFile.cxx @@ -617,7 +617,7 @@ Bool_t TNetXNGFile::ReadBuffers(char *buffer, Long64_t *position, Int_t *length, /// param length: the size of the buffer /// returns: kTRUE in case of failure -Bool_t TNetXNGFile::WriteBuffer(const char *buffer, Int_t length) +Bool_t TNetXNGFile::WriteBuffer(const char *buffer, Long64_t length) { using namespace XrdCl; diff --git a/roottest/root/meta/MemberComments.ref b/roottest/root/meta/MemberComments.ref index 8400913ce23c6..274dc5914b764 100644 --- a/roottest/root/meta/MemberComments.ref +++ b/roottest/root/meta/MemberComments.ref @@ -350,7 +350,7 @@ OBJ: TList TList Doubly linked list : 0 OBJ: TMethod Print : 0 void TObject::Print(Option_t* option = "") const OBJ: TMethod Read : 0 - Int_t TObject::Read(const char* name) + Long64_t TObject::Read(const char* name) OBJ: TMethod RecursiveRemove : 0 void TObject::RecursiveRemove(TObject* obj) OBJ: TMethod ResetAttFill : 0 @@ -538,9 +538,13 @@ 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) + Long64_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 + Long64_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const + OBJ: TMethod Write : 0 + Long64_t TObject::Write(const char* name, Int_t option, Int_t bufsize) + OBJ: TMethod Write : 0 + Long64_t TObject::Write(const char* name, Int_t option, Int_t bufsize) 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..ab1b787960004 100644 --- a/roottest/root/meta/MemberComments_win32.ref +++ b/roottest/root/meta/MemberComments_win32.ref @@ -350,7 +350,7 @@ OBJ: TList TList Doubly linked list : 0 OBJ: TMethod Print : 0 void TObject::Print(Option_t* option = "") const OBJ: TMethod Read : 0 - Int_t TObject::Read(const char* name) + Long64_t TObject::Read(const char* name) OBJ: TMethod RecursiveRemove : 0 void TObject::RecursiveRemove(TObject* obj) OBJ: TMethod ResetAttFill : 0 @@ -538,9 +538,13 @@ 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) + Long64_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 + Long64_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const + OBJ: TMethod Write : 0 + Long64_t TObject::Write(const char* name, Int_t option, Int_t bufsize) + OBJ: TMethod Write : 0 + Long64_t TObject::Write(const char* name, Int_t option, Int_t bufsize) 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..ab1b787960004 100644 --- a/roottest/root/meta/MemberComments_win64.ref +++ b/roottest/root/meta/MemberComments_win64.ref @@ -350,7 +350,7 @@ OBJ: TList TList Doubly linked list : 0 OBJ: TMethod Print : 0 void TObject::Print(Option_t* option = "") const OBJ: TMethod Read : 0 - Int_t TObject::Read(const char* name) + Long64_t TObject::Read(const char* name) OBJ: TMethod RecursiveRemove : 0 void TObject::RecursiveRemove(TObject* obj) OBJ: TMethod ResetAttFill : 0 @@ -538,9 +538,13 @@ 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) + Long64_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 + Long64_t TObject::Write(const char* name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const + OBJ: TMethod Write : 0 + Long64_t TObject::Write(const char* name, Int_t option, Int_t bufsize) + OBJ: TMethod Write : 0 + Long64_t TObject::Write(const char* name, Int_t option, Int_t bufsize) 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 02f1f2e438882..2ca1ece972f1a 100644 --- a/tree/dataframe/src/RDFSnapshotHelpers.cxx +++ b/tree/dataframe/src/RDFSnapshotHelpers.cxx @@ -196,7 +196,7 @@ void CreateFundamentalTypeBranch(TTree &outputTree, RBranchData &bd, void *value { // Logic taken from // TTree::BranchImpRef( - // const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Int_t bufsize, Int_t splitlevel) + // const char *branchname, TClass *ptrClass, EDataType datatype, void *addobj, Long64_t bufsize, Int_t splitlevel) auto rootTypeChar = ROOT::Internal::RDF::TypeID2ROOTTypeName(*bd.fInputTypeID); if (rootTypeChar == ' ') { Warning("Snapshot", diff --git a/tree/ntuple/src/RFieldMeta.cxx b/tree/ntuple/src/RFieldMeta.cxx index f524169362970..90a67a2ce9fef 100644 --- a/tree/ntuple/src/RFieldMeta.cxx +++ b/tree/ntuple/src/RFieldMeta.cxx @@ -993,7 +993,7 @@ class TBufferRecStreamer : public TBufferFile { RCallbackStreamerInfo fCallbackStreamerInfo; public: - TBufferRecStreamer(TBuffer::EMode mode, Int_t bufsize, RCallbackStreamerInfo callbackStreamerInfo) + TBufferRecStreamer(TBuffer::EMode mode, Long64_t bufsize, RCallbackStreamerInfo callbackStreamerInfo) : TBufferFile(mode, bufsize), fCallbackStreamerInfo(callbackStreamerInfo) { } diff --git a/tree/tree/inc/TBasket.h b/tree/tree/inc/TBasket.h index 66a737ac2ec2c..a06f634507a94 100644 --- a/tree/tree/inc/TBasket.h +++ b/tree/tree/inc/TBasket.h @@ -131,8 +131,8 @@ friend class TBranch; Int_t GetLast() const {return fLast;} virtual void MoveEntries(Int_t dentries); virtual void PrepareBasket(Long64_t /* entry */) {}; - Int_t ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file); - Int_t ReadBasketBytes(Long64_t pos, TFile *file); + Long64_t ReadBasketBuffers(Long64_t pos, Long64_t len, TFile *file); + Long64_t ReadBasketBytes(Long64_t pos, TFile *file); virtual void WriteReset(); // Time spent reseting basket sizes (typically, at event cluster boundaries), in microseconds diff --git a/tree/tree/inc/TBranch.h b/tree/tree/inc/TBranch.h index a74cd85c01d15..82fe6292d26bb 100644 --- a/tree/tree/inc/TBranch.h +++ b/tree/tree/inc/TBranch.h @@ -184,30 +184,30 @@ class TBranch : public TNamed, public TAttFill { Int_t GetBulkEntries(Long64_t, TBuffer&); Int_t GetEntriesSerialized(Long64_t N, TBuffer& user_buf) {return GetEntriesSerialized(N, user_buf, nullptr);} Int_t GetEntriesSerialized(Long64_t, TBuffer&, TBuffer*); - Int_t FillEntryBuffer(TBasket* basket,TBuffer* buf, Int_t& lnew); + Long64_t FillEntryBuffer(TBasket *basket, TBuffer *buf, Int_t &lnew); Int_t WriteBasketImpl(TBasket* basket, Int_t where, ROOT::Internal::TBranchIMTHelper *); TBranch(const TBranch&) = delete; // not implemented TBranch& operator=(const TBranch&) = delete; // not implemented 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); virtual void AddLastBasket(Long64_t startEntry); - Int_t BackFill(); + Long64_t BackFill(); void Browse(TBrowser *b) override; virtual void DeleteBaskets(Option_t* option=""); virtual void DropBaskets(Option_t *option = ""); void ExpandBasketArrays(); - Int_t Fill() { return FillImpl(nullptr); } - virtual Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *); + Long64_t Fill() { return FillImpl(nullptr); } + virtual Long64_t FillImpl(ROOT::Internal::TBranchIMTHelper *); virtual TBranch *FindBranch(const char *name); virtual TLeaf *FindLeaf(const char *name); - Int_t FlushBaskets(); - Int_t FlushOneBasket(UInt_t which); + Long64_t FlushBaskets(); + Long64_t FlushOneBasket(UInt_t which); virtual char *GetAddress() const {return fAddress;} TBasket *GetBasket(Int_t basket) {return GetBasketImpl(basket, nullptr);} @@ -222,10 +222,10 @@ class TBranch : public TNamed, public TAttFill { Int_t GetCompressionLevel() const; Int_t GetCompressionSettings() const; TDirectory *GetDirectory() const {return fDirectory;} - virtual Int_t GetEntry(Long64_t entry=0, Int_t getall = 0); - virtual Int_t GetEntryExport(Long64_t entry, Int_t getall, TClonesArray *list, Int_t n); - Int_t GetEntryOffsetLen() const { return fEntryOffsetLen; } - Int_t GetEvent(Long64_t entry=0) {return GetEntry(entry);} + virtual Long64_t GetEntry(Long64_t entry=0, Int_t getall = 0); + virtual Long64_t GetEntryExport(Long64_t entry, Int_t getall, TClonesArray *list, Long64_t n); + Int_t GetEntryOffsetLen() const { return fEntryOffsetLen; } + Int_t GetEvent(Long64_t entry = 0) { return GetEntry(entry); } virtual TString GetFullName() const; const char *GetIconName() const override; virtual Int_t GetExpectedType(TClass *&clptr,EDataType &type); @@ -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..5009d23d37b9f 100644 --- a/tree/tree/inc/TBranchClones.h +++ b/tree/tree/inc/TBranchClones.h @@ -38,18 +38,18 @@ 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); - Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; + void Init(TTree *tree, TBranch *parent, const char *name, void *clonesaddress, Long64_t basketsize=32000,Int_t compress=-1, Int_t splitlevel=1); + Long64_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; const char* GetClassName() const override { return fClassName; } - Int_t GetEntry(Long64_t entry=0, Int_t getall = 0) override; + Long64_t GetEntry(Long64_t entry = 0, Int_t getall = 0) override; virtual Int_t GetN() const {return fN;} TClonesArray *GetList() const {return fList;} bool IsFolder() const override {return true;} @@ -57,7 +57,7 @@ class TBranchClones : public TBranch { void Reset(Option_t *option="") override; void ResetAfterMerge(TFileMergeInfo *) override; void SetAddress(void *add) override; - void SetBasketSize(Int_t bufsize) override; + void SetBasketSize(Long64_t bufsize) override; void SetTree(TTree *tree) override { fTree = tree; fBranchCount->SetTree(tree); } void UpdateFile() override; diff --git a/tree/tree/inc/TBranchElement.h b/tree/tree/inc/TBranchElement.h index 39c762041c414..faea8ed2fa914 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; @@ -188,15 +188,15 @@ class TBranchElement : public TBranch { virtual const char *GetClonesName() const { return fClonesName.Data(); } TVirtualCollectionProxy *GetCollectionProxy(); TClass *GetCurrentClass(); // Class referenced by transient description - Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0) override; - Int_t GetExpectedType(TClass *&clptr,EDataType &type) override; - TString GetFullName() const override; - const char *GetIconName() const override; - Int_t GetID() const { return fID; } - TStreamerInfo *GetInfo() const; - bool GetMakeClass() const override; - char *GetObject() const; - TVirtualArray *GetOnfileObject() const { return fOnfileObject; } + Long64_t GetEntry(Long64_t entry = 0, Int_t getall = 0) override; + Int_t GetExpectedType(TClass *&clptr, EDataType &type) override; + TString GetFullName() const override; + const char *GetIconName() const override; + Int_t GetID() const { return fID; } + TStreamerInfo *GetInfo() const; + bool GetMakeClass() const override; + char *GetObject() const; + TVirtualArray *GetOnfileObject() const { return fOnfileObject; } virtual const char *GetParentName() const { return fParentName.Data(); } virtual Int_t GetMaximum() const; Int_t GetNdata() const { return fNdata; } @@ -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, @@ -250,7 +250,7 @@ class TBranchElement : public TBranch { }; private: - Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; + Long64_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; ClassDefOverride(TBranchElement,10) // Branch in case of an object }; diff --git a/tree/tree/inc/TBranchObject.h b/tree/tree/inc/TBranchObject.h index 75dbbf96e5cf2..5fc2062f7ba4f 100644 --- a/tree/tree/inc/TBranchObject.h +++ b/tree/tree/inc/TBranchObject.h @@ -42,18 +42,18 @@ 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; const char* GetClassName() const override { return fClassName.Data(); }; virtual const char* GetObjClassName() { return fClassName.Data(); }; - Int_t GetEntry(Long64_t entry=0, Int_t getall = 0) override; + Long64_t GetEntry(Long64_t entry=0, Int_t getall = 0) override; Int_t GetExpectedType(TClass *&clptr,EDataType &type) override; bool IsFolder() const override; void Print(Option_t *option="") const override; @@ -61,12 +61,12 @@ 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; private: - Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; + Long64_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; ClassDefOverride(TBranchObject,1); //Branch in case of an object }; diff --git a/tree/tree/inc/TBranchRef.h b/tree/tree/inc/TBranchRef.h index f0f9eb83a3cf9..77e71295da9a7 100644 --- a/tree/tree/inc/TBranchRef.h +++ b/tree/tree/inc/TBranchRef.h @@ -55,7 +55,7 @@ class TBranchRef : public TBranch { virtual void SetRequestedEntry(Long64_t entry) {fRequestedEntry = entry;} private: - Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; + Long64_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; ClassDefOverride(TBranchRef,1); //to support referenced objects on other branches }; diff --git a/tree/tree/inc/TBranchSTL.h b/tree/tree/inc/TBranchSTL.h index 9afff67341619..82a2ee6ab72da 100644 --- a/tree/tree/inc/TBranchSTL.h +++ b/tree/tree/inc/TBranchSTL.h @@ -24,17 +24,17 @@ 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; bool IsFolder() const override; const char *GetClassName() const override { return fClassName.Data(); } Int_t GetExpectedType(TClass *&clptr,EDataType &type) override; - Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0) override; + Long64_t GetEntry(Long64_t entry = 0, Int_t getall = 0) override; virtual TStreamerInfo *GetInfo() const; void Print(Option_t* = "") const override; void SetAddress(void* addr) override; @@ -45,7 +45,7 @@ class TBranchSTL: public TBranch { void ReadLeavesImpl( TBuffer& b ); void FillLeavesImpl( TBuffer& b ); - Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; + Long64_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override; struct ElementBranchHelper_t { diff --git a/tree/tree/inc/TBufferSQL.h b/tree/tree/inc/TBufferSQL.h index eff029fa978b8..628c6f337e051 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 bufsize, std::vector *vc, TString *insert_query, TSQLRow **rowPtr); + TBufferSQL(TBuffer::EMode mode, Long64_t bufsize, std::vector *vc, TString *insert_query, TSQLRow **rowPtr,void *buf, bool adopt = true); ~TBufferSQL() override; void ResetOffset(); diff --git a/tree/tree/inc/TChain.h b/tree/tree/inc/TChain.h index 8d362124ec261..67305b4f2ec74 100644 --- a/tree/tree/inc/TChain.h +++ b/tree/tree/inc/TChain.h @@ -91,7 +91,7 @@ class TChain : public TTree { Long64_t Draw(const char* varexp, const TCut& selection, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) override; Long64_t Draw(const char* varexp, const char* selection, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) override; // *MENU* void Draw(Option_t* opt) override { Draw(opt, "", "", kMaxEntries, 0); } - Int_t Fill() override { MayNotUse("Fill()"); return -1; } + Long64_t Fill() override { MayNotUse("Fill()"); return -1; } TBranch *FindBranch(const char* name) override; TLeaf *FindLeaf(const char* name) override; TBranch *GetBranch(const char* name) override; @@ -102,27 +102,27 @@ class TChain : public TTree { Int_t GetNtrees() const { return fNtrees; } Long64_t GetEntries() const override; Long64_t GetEntries(const char *sel) override { return TTree::GetEntries(sel); } - Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override; + Long64_t GetEntry(Long64_t entry=0, Int_t getall=0) override; Long64_t GetEntryNumber(Long64_t entry) const override; - Int_t GetEntryWithIndex(Long64_t major, Long64_t minor=0) override; - TFile *GetFile() const; + Long64_t GetEntryWithIndex(Long64_t major, Long64_t minor=0) override; + TFile *GetFile() const; TLeaf *GetLeaf(const char* branchname, const char* leafname) override; TLeaf *GetLeaf(const char* name) override; TObjArray *GetListOfBranches() override; // Warning, GetListOfFiles returns the list of TChainElements (not the list of files) // see TChain::AddFile to see how to get the corresponding TFile objects - TObjArray *GetListOfFiles() const {return fFiles;} + TObjArray *GetListOfFiles() const {return fFiles;} TObjArray *GetListOfLeaves() override; const char *GetAlias(const char *aliasName) const override; Double_t GetMaximum(const char *columname) override; Double_t GetMinimum(const char *columname) override; Int_t GetNbranches() override; Long64_t GetReadEntry() const override; - TList *GetStatus() const { return fStatus; } + TList *GetStatus() const { return fStatus; } TTree *GetTree() const override { return fTree; } Int_t GetTreeNumber() const override { return fTreeNumber; } - Long64_t *GetTreeOffset() const { return fTreeOffset; } - Int_t GetTreeOffsetLen() const { return fTreeOffsetLen; } + Long64_t *GetTreeOffset() const { return fTreeOffset; } + Int_t GetTreeOffsetLen() const { return fTreeOffsetLen; } Double_t GetWeight() const override; bool InPlaceClone(TDirectory *newdirectory, const char *options = "") override; Int_t LoadBaskets(Long64_t maxmemory) override; @@ -132,7 +132,7 @@ class TChain : public TTree { virtual Long64_t Merge(const char *name, Option_t *option = ""); Long64_t Merge(TCollection *list, Option_t *option = "") override; Long64_t Merge(TCollection *list, TFileMergeInfo *info) override; - virtual Long64_t Merge(TFile *file, Int_t basketsize, Option_t *option=""); + virtual Long64_t Merge(TFile *file, Long64_t basketsize, Option_t *option=""); void Print(Option_t *option="") const override; Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0) override; // *MENU* Long64_t Process(TSelector* selector, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) override; diff --git a/tree/tree/inc/TNtuple.h b/tree/tree/inc/TNtuple.h index 3794097b6bb04..f49c950e5a4c9 100644 --- a/tree/tree/inc/TNtuple.h +++ b/tree/tree/inc/TNtuple.h @@ -31,7 +31,7 @@ class TNtuple : public TTree { Int_t fNvar; ///< Number of columns Float_t *fArgs; /// 0, the members of the object are serialised as separate branches. /// \return Pointer to the TBranch that was created. The branch is owned by the tree. - template TBranch *Branch(const char* name, T* obj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, T* obj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { return BranchImpRef(name, TClass::GetClass(), TDataType::GetType(typeid(T)), obj, bufsize, splitlevel); } @@ -403,42 +403,42 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker /// A small value for bufsize is beneficial if entries in the Tree are accessed randomly and the Tree is in split mode. /// \param[in] splitlevel If T is a class or struct and splitlevel > 0, the members of the object are serialised as separate branches. /// \return Pointer to the TBranch that was created. The branch is owned by the tree. - template TBranch *Branch(const char* name, T** addobj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, T** addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { return BranchImp(name, TClass::GetClass(), addobj, bufsize, splitlevel); } - virtual Int_t Branch(TCollection* list, Int_t bufsize = 32000, Int_t splitlevel = 99, const char* name = ""); - virtual Int_t Branch(TList* list, Int_t bufsize = 32000, Int_t splitlevel = 99); - virtual Int_t Branch(const char* folder, Int_t bufsize = 32000, Int_t splitlevel = 99); - virtual TBranch *Branch(const char* name, void* address, const char* leaflist, Int_t bufsize = 32000); - TBranch *Branch(const char* name, char* address, const char* leaflist, Int_t bufsize = 32000) + virtual Int_t Branch(TCollection* list, Long64_t bufsize = 32000, Int_t splitlevel = 99, const char* name = ""); + virtual Int_t Branch(TList* list, Long64_t bufsize = 32000, Int_t splitlevel = 99); + virtual Int_t Branch(const char* folder, Long64_t bufsize = 32000, Int_t splitlevel = 99); + virtual TBranch *Branch(const char* name, void* address, const char* leaflist, Long64_t bufsize = 32000); + TBranch *Branch(const char* name, char* address, const char* leaflist, Long64_t bufsize = 32000) { // Overload to avoid confusion between this signature and the template instance. return Branch(name,(void*)address,leaflist,bufsize); } - TBranch *Branch(const char* name, Longptr_t address, const char* leaflist, Int_t bufsize = 32000) + TBranch *Branch(const char* name, Longptr_t address, const char* leaflist, Long64_t bufsize = 32000) { // Overload to avoid confusion between this signature and the template instance. return Branch(name,(void*)address,leaflist,bufsize); } - TBranch *Branch(const char* name, int address, const char* leaflist, Int_t bufsize = 32000) + TBranch *Branch(const char* name, int address, const char* leaflist, Long64_t bufsize = 32000) { // Overload to avoid confusion between this signature and the template instance. return Branch(name,(void*)(Longptr_t)address,leaflist,bufsize); } - virtual TBranch *Branch(const char* name, const char* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 99); - template TBranch *Branch(const char* name, const char* classname, T* obj, Int_t bufsize = 32000, Int_t splitlevel = 99) + virtual TBranch *Branch(const char* name, const char* classname, void* addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99); + template TBranch *Branch(const char* name, const char* classname, T* obj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { // See BranchImpRed for details. Here we __ignore return BranchImpRef(name, classname, TClass::GetClass(), obj, bufsize, splitlevel); } - template TBranch *Branch(const char* name, const char* classname, T** addobj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, const char* classname, T** addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { // See BranchImp for details return BranchImp(name, classname, TClass::GetClass(), addobj, bufsize, splitlevel); } - template TBranch *Branch(const char* name, std::array *obj, Int_t bufsize = 32000, Int_t splitlevel = 99) + template TBranch *Branch(const char* name, std::array *obj, Long64_t bufsize = 32000, Int_t splitlevel = 99) { TClass *cl = TClass::GetClass(); if (cl) { @@ -449,8 +449,8 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker } return BranchImpArr(name, TDataType::GetType(typeid(T)), N, obj, bufsize, splitlevel); } - virtual TBranch *Bronch(const char* name, const char* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 99); - virtual TBranch *BranchOld(const char* name, const char* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 1); + virtual TBranch *Bronch(const char* name, const char* classname, void* addobj, Long64_t bufsize = 32000, Int_t splitlevel = 99); + virtual TBranch *BranchOld(const char* name, const char* classname, void* addobj, Long64_t bufsize = 32000, Int_t splitlevel = 1); virtual TBranch *BranchRef(); void Browse(TBrowser*) override; virtual Int_t BuildIndex(const char *majorname, const char *minorname = "0", bool long64major = false, bool long64minor = false); @@ -473,12 +473,14 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker virtual void DropBaskets(); virtual void DropBuffers(Int_t nbytes); bool EnableCache(); - virtual Int_t Fill(); - virtual TBranch *FindBranch(const char* name); - virtual TLeaf *FindLeaf(const char* name); - virtual Int_t Fit(const char* funcname, const char* varexp, const char* selection = "", Option_t* option = "", Option_t* goption = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0); // *MENU* - virtual Int_t FlushBaskets(bool create_cluster = true) const; - virtual const char *GetAlias(const char* aliasName) const; + virtual Long64_t Fill(); + virtual TBranch *FindBranch(const char *name); + virtual TLeaf *FindLeaf(const char *name); + virtual Int_t Fit(const char *funcname, const char *varexp, const char *selection = "", + Option_t *option = "", Option_t *goption = "", Long64_t nentries = kMaxEntries, + Long64_t firstentry = 0); // *MENU* + virtual Int_t FlushBaskets(bool create_cluster = true) const; + virtual const char *GetAlias(const char *aliasName) const; UInt_t GetAllocationCount() const { return fAllocationCount; } #ifdef R__TRACK_BASKET_ALLOC_TIME ULong64_t GetAllocationTime() const { return fAllocationTime; } @@ -544,9 +546,9 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker virtual Long64_t GetEntriesFast() const { return fEntries; } virtual Long64_t GetEntriesFriend() const; virtual Long64_t GetEstimate() const { return fEstimate; } - virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0); - Int_t GetEvent(Long64_t entry, Int_t getall = 0) { return GetEntry(entry, getall); } - virtual Int_t GetEntryWithIndex(Long64_t major, Long64_t minor = 0); + virtual Long64_t GetEntry(Long64_t entry, Int_t getall = 0); + Int_t GetEvent(Long64_t entry, Int_t getall = 0) { return GetEntry(entry, getall); } + virtual Long64_t GetEntryWithIndex(Long64_t major, Long64_t minor = 0); virtual Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor = 0) const; virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor = 0) const; TEventList *GetEventList() const { return fEventList; } @@ -632,7 +634,7 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker virtual Int_t MakeCode(const char *filename = nullptr); virtual Int_t MakeProxy(const char* classname, const char* macrofilename = nullptr, const char* cutfilename = nullptr, const char* option = nullptr, Int_t maxUnrolling = 3); virtual Int_t MakeSelector(const char *selector = nullptr, Option_t *option = ""); - bool MemoryFull(Int_t nbytes); + bool MemoryFull(Long64_t nbytes); virtual Long64_t Merge(TCollection* list, Option_t* option = ""); virtual Long64_t Merge(TCollection* list, TFileMergeInfo *info); static TTree *MergeTrees(TList* list, Option_t* option = ""); @@ -660,7 +662,7 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker virtual bool SetAlias(const char* aliasName, const char* aliasFormula); virtual void SetAutoSave(Long64_t autos = -300000000); virtual void SetAutoFlush(Long64_t autof = -30000000); - virtual void SetBasketSize(const char* bname, Int_t buffsize = 16000); + virtual void SetBasketSize(const char* bname, Long64_t bufsize = 16000); virtual Int_t SetBranchAddress(const char *bname,void *add, TBranch **ptr = nullptr); virtual Int_t SetBranchAddress(const char *bname,void *add, TClass *realClass, EDataType datatype, bool isptr); virtual Int_t SetBranchAddress(const char *bname,void *add, TBranch **ptr, TClass *realClass, EDataType datatype, bool isptr); @@ -743,8 +745,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; + Long64_t Write(const char *name=nullptr, Int_t option=0, Long64_t bufsize=0) override; + Long64_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..ba5cfe9833525 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; @@ -137,16 +137,16 @@ class TTreeCacheUnzip : public TTreeCache { #ifdef R__USE_IMT Int_t CreateTasks(); #endif - Int_t GetRecordHeader(char *buf, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen); - Int_t GetUnzipBuffer(char **buf, Long64_t pos, Int_t len, bool *free) override; + Long64_t GetRecordHeader(char *buf, Int_t maxbytes, Long64_t &nbytes, Long64_t &objlen, Long64_t &keylen); + Long64_t GetUnzipBuffer(char **buf, Long64_t pos, Long64_t len, bool *free) override; Int_t GetUnzipGroupSize() { return fUnzipGroupSize; } void ResetCache() override; Int_t SetBufferSize(Long64_t buffersize) override; void SetUnzipBufferSize(Long64_t bufferSize); void SetUnzipGroupSize(Int_t groupSize) { fUnzipGroupSize = groupSize; } static void SetUnzipRelBufferSize(Float_t relbufferSize); - Int_t UnzipBuffer(char **dest, char *src); - Int_t UnzipCache(Int_t index); + Long64_t UnzipBuffer(char **dest, char *src); + Long64_t UnzipCache(Int_t index); // Methods to get stats Int_t GetNUnzip() { return fNUnzip; } diff --git a/tree/tree/inc/TTreeSQL.h b/tree/tree/inc/TTreeSQL.h index 5fedf6d5d64bb..53b3a59169feb 100644 --- a/tree/tree/inc/TTreeSQL.h +++ b/tree/tree/inc/TTreeSQL.h @@ -65,29 +65,29 @@ 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; - Long64_t GetEntries() const override; + Long64_t Fill() override; + Long64_t GetEntry(Long64_t entry=0, Int_t getall=0) override; + Long64_t GetEntries() const override; Long64_t GetEntries(const char *sel) override { return TTree::GetEntries(sel); } Long64_t GetEntriesFast()const override; TString GetTableName(){ return fTable; } - Long64_t LoadTree(Long64_t entry) override; + Long64_t LoadTree(Long64_t entry) override; virtual Long64_t PrepEntry(Long64_t entry); void Refresh() override; diff --git a/tree/tree/src/TBasket.cxx b/tree/tree/src/TBasket.cxx index e86e1de93b8c6..9e9462d27ed72 100644 --- a/tree/tree/src/TBasket.cxx +++ b/tree/tree/src/TBasket.cxx @@ -460,7 +460,7 @@ void TBasket::ResetEntryOffset() /// There is a lot of code duplication but it was necessary to assure /// the expected behavior when there is no cache. -Int_t TBasket::ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file) +Long64_t TBasket::ReadBasketBuffers(Long64_t pos, Long64_t len, TFile *file) { if(!fBranch->GetDirectory()) { return -1; @@ -468,7 +468,7 @@ Int_t TBasket::ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file) bool oldCase; char *rawUncompressedBuffer, *rawCompressedBuffer; - Int_t uncompressedBufferLen; + Long64_t uncompressedBufferLen; // See if the cache has already unzipped the buffer for us. TFileCacheRead *pf = nullptr; @@ -662,7 +662,7 @@ Int_t TBasket::ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file) if (R__unlikely(!fEntryOffset)) { fEntryOffset = new Int_t[fNevBuf+1]; fEntryOffset[0] = fKeylen; - Warning("ReadBasketBuffers","basket:%s has fNevBuf=%d but fEntryOffset=0, pos=%lld, len=%d, fNbytes=%d, fObjlen=%d, trying to repair",GetName(),fNevBuf,pos,len,fNbytes,fObjlen); + Warning("ReadBasketBuffers","basket:%s has fNevBuf=%d but fEntryOffset=0, pos=%lld, len=%lld, fNbytes=%d, fObjlen=%d, trying to repair",GetName(),fNevBuf,pos,len,fNbytes,fObjlen); return 0; } if (fIOBits & static_cast(TBasket::EIOBits::kGenerateOffsetMap)) { @@ -694,13 +694,17 @@ Int_t TBasket::ReadBasketBuffers(Long64_t pos, Int_t len, TFile *file) /// Read first bytes of a logical record starting at position pos /// return record length (first 4 bytes of record). -Int_t TBasket::ReadBasketBytes(Long64_t pos, TFile *file) +Long64_t TBasket::ReadBasketBytes(Long64_t pos, TFile *file) { const Int_t len = 128; char buffer[len]; Int_t keylen; - file->GetRecordHeader(buffer, pos,len, fNbytes, fObjlen, keylen); + Long64_t nbytes = fNbytes; + Long64_t objlen = fObjlen; + file->GetRecordHeader(buffer, pos,len, nbytes, objlen, keylen); + fNbytes = nbytes; fKeylen = keylen; + fObjlen = objlen; return fNbytes; } diff --git a/tree/tree/src/TBranch.cxx b/tree/tree/src/TBranch.cxx index a44cf713d1916..85e4003d34f02 100644 --- a/tree/tree/src/TBranch.cxx +++ b/tree/tree/src/TBranch.cxx @@ -195,7 +195,7 @@ TBranch::TBranch() /// /// Note that this function is invoked by TTree::Branch -TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Int_t basketsize, Int_t compress) +TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) : TNamed(name, leaflist) , TAttFill(0, 1001) , fCompress(compress) @@ -239,6 +239,8 @@ TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leafl , fReadLeaves(&TBranch::ReadLeavesImpl) , fFillLeaves(&TBranch::FillLeavesImpl) { + if (basketsize > kMaxInt) + Fatal("TBranch", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); Init(name,leaflist,compress); } @@ -248,7 +250,7 @@ TBranch::TBranch(TTree *tree, const char *name, void *address, const char *leafl /// See documentation for /// TBranch::TBranch(TTree *, const char *, void *, const char *, Int_t, Int_t) -TBranch::TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Int_t basketsize, +TBranch::TBranch(TBranch *parent, const char *name, void *address, const char *leaflist, Long64_t basketsize, Int_t compress) : TNamed(name, leaflist) , TAttFill(0, 1001) @@ -293,6 +295,8 @@ TBranch::TBranch(TBranch *parent, const char *name, void *address, const char *l , fReadLeaves(&TBranch::ReadLeavesImpl) , fFillLeaves(&TBranch::FillLeavesImpl) { + if (basketsize > kMaxInt) + Fatal("TBranch", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); Init(name,leaflist,compress); } @@ -676,7 +680,8 @@ void TBranch::AddLastBasket(Long64_t startEntry) /// // all the baskets for that branch are consecutive. /// ~~~ -Int_t TBranch::BackFill() { +Long64_t TBranch::BackFill() +{ // Get the end of the next cluster. auto cluster = GetTree()->GetClusterIterator( GetEntries() ); @@ -852,7 +857,7 @@ void TBranch::ExpandBasketArrays() /// If no data are written, because e.g. the branch is disabled, /// the number of bytes returned is 0. -Int_t TBranch::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) +Long64_t TBranch::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) { if (TestBit(kDoNotProcess)) { return 0; @@ -880,7 +885,7 @@ Int_t TBranch::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) } Int_t lnew = 0; - Int_t nbytes = 0; + Long64_t nbytes = 0; if (fEntryBuffer) { nbytes = FillEntryBuffer(basket,buf,lnew); @@ -931,9 +936,9 @@ Int_t TBranch::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) //////////////////////////////////////////////////////////////////////////////// /// Copy the data from fEntryBuffer into the current basket. -Int_t TBranch::FillEntryBuffer(TBasket* basket, TBuffer* buf, Int_t& lnew) +Long64_t TBranch::FillEntryBuffer(TBasket* basket, TBuffer* buf, Int_t& lnew) { - Int_t nbytes = 0; + Long64_t nbytes = 0; Int_t objectStart = 0; Int_t last = 0; Int_t lold = buf->Length(); @@ -1132,10 +1137,10 @@ TLeaf* TBranch::FindLeaf(const char* searchname) /// Flush to disk all the baskets of this branch and any of subbranches. /// Return the number of bytes written or -1 in case of write error. -Int_t TBranch::FlushBaskets() +Long64_t TBranch::FlushBaskets() { UInt_t nerror = 0; - Int_t nbytes = 0; + Long64_t nbytes = 0; Int_t maxbasket = fWriteBasket + 1; // The following protection is not necessary since we should always @@ -1178,9 +1183,9 @@ Int_t TBranch::FlushBaskets() /// has not yet been written to disk, we write it and delete it from memory. /// Return the number of bytes written; -Int_t TBranch::FlushOneBasket(UInt_t ibasket) +Long64_t TBranch::FlushOneBasket(UInt_t ibasket) { - Int_t nbytes = 0; + Long64_t nbytes = 0; if (fDirectory && fBaskets.GetEntriesFast()) { TBasket *basket = (TBasket*)fBaskets.UncheckedAt(ibasket); @@ -1702,7 +1707,7 @@ Int_t TBranch::GetEntriesSerialized(Long64_t entry, TBuffer &user_buf, TBuffer * /// /// See IMPORTANT REMARKS in TTree::GetEntry. -Int_t TBranch::GetEntry(Long64_t entry, Int_t getall) +Long64_t TBranch::GetEntry(Long64_t entry, Int_t getall) { // Remember which entry we are reading. fReadEntry = entry; @@ -1712,7 +1717,7 @@ Int_t TBranch::GetEntry(Long64_t entry, Int_t getall) TBasket *basket; // will be initialized in the if/then clauses. Long64_t first; - Int_t result = GetBasketAndFirst(basket, first, nullptr); + Long64_t result = GetBasketAndFirst(basket, first, nullptr); if (R__unlikely(result < 0)) { return result + 1; } basket->PrepareBasket(entry); @@ -1735,7 +1740,7 @@ Int_t TBranch::GetEntry(Long64_t entry, Int_t getall) } Int_t* entryOffset = basket->GetEntryOffset(); - Int_t bufbegin = 0; + Long64_t bufbegin = 0; if (entryOffset) { bufbegin = entryOffset[entry-first]; buf->SetBufferOffset(bufbegin); @@ -1758,7 +1763,7 @@ Int_t TBranch::GetEntry(Long64_t entry, Int_t getall) /// /// Returns total number of bytes read. -Int_t TBranch::GetEntryExport(Long64_t entry, Int_t /*getall*/, TClonesArray* li, Int_t nentries) +Long64_t TBranch::GetEntryExport(Long64_t entry, Int_t /*getall*/, TClonesArray *li, Long64_t nentries) { // Remember which entry we are reading. fReadEntry = entry; @@ -1769,7 +1774,7 @@ Int_t TBranch::GetEntryExport(Long64_t entry, Int_t /*getall*/, TClonesArray* li if ((entry < 0) || (entry >= fEntryNumber)) { return 0; } - Int_t nbytes = 0; + Long64_t nbytes = 0; Long64_t first = fFirstBasketEntry; Long64_t last = fNextBasketEntry - 1; // Are we still in the same ReadBasket? @@ -2738,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 13c51dbc03278..fc1515ab9f474 100644 --- a/tree/tree/src/TBranchClones.cxx +++ b/tree/tree/src/TBranchClones.cxx @@ -49,7 +49,7 @@ TBranchClones::TBranchClones() //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBranchClones::TBranchClones(TTree *tree, const char* name, void* pointer, Int_t basketsize, Int_t compress, Int_t splitlevel) +TBranchClones::TBranchClones(TTree *tree, const char* name, void* pointer, Long64_t basketsize, Int_t compress, Int_t splitlevel) : TBranch() , fList(nullptr) , fRead(0) @@ -63,7 +63,7 @@ TBranchClones::TBranchClones(TTree *tree, const char* name, void* pointer, Int_t //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBranchClones::TBranchClones(TBranch *parent, const char* name, void* pointer, Int_t basketsize, Int_t compress, Int_t splitlevel) +TBranchClones::TBranchClones(TBranch *parent, const char* name, void* pointer, Long64_t basketsize, Int_t compress, Int_t splitlevel) : TBranch() , fList(nullptr) , fRead(0) @@ -77,7 +77,7 @@ TBranchClones::TBranchClones(TBranch *parent, const char* name, void* pointer, I //////////////////////////////////////////////////////////////////////////////// /// Initialization (non-virtual, to be called from constructor). -void TBranchClones::Init(TTree *tree, TBranch *parent, const char* name, void* pointer, Int_t basketsize, Int_t compress, Int_t splitlevel) +void TBranchClones::Init(TTree *tree, TBranch *parent, const char* name, void* pointer, Long64_t basketsize, Int_t compress, Int_t splitlevel) { if (tree==nullptr && parent!=nullptr) tree = parent->GetTree(); fTree = tree; @@ -110,6 +110,8 @@ void TBranchClones::Init(TTree *tree, TBranch *parent, const char* name, void* p fSplitLevel = splitlevel; // Create a branch to store the array count. + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); if (basketsize < 100) { basketsize = 100; } @@ -221,10 +223,10 @@ void TBranchClones::Browse(TBrowser* b) //////////////////////////////////////////////////////////////////////////////// /// Loop on all branches and fill Basket buffer. -Int_t TBranchClones::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) +Long64_t TBranchClones::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) { Int_t i = 0; - Int_t nbytes = 0; + Long64_t nbytes = 0; Int_t nbranches = fBranches.GetEntriesFast(); char** ppointer = (char**) fAddress; if (!ppointer) { @@ -260,12 +262,12 @@ Int_t TBranchClones::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) //////////////////////////////////////////////////////////////////////////////// /// Read all branches and return total number of bytes read. -Int_t TBranchClones::GetEntry(Long64_t entry, Int_t getall) +Long64_t TBranchClones::GetEntry(Long64_t entry, Int_t getall) { if (TestBit(kDoNotProcess) && !getall) { return 0; } - Int_t nbytes = fBranchCount->GetEntry(entry, getall); + Long64_t nbytes = fBranchCount->GetEntry(entry, getall); TLeaf* leafcount = (TLeaf*) fBranchCount->GetListOfLeaves()->UncheckedAt(0); fN = Int_t(leafcount->GetValue()); if (fN <= 0) { @@ -369,7 +371,7 @@ void TBranchClones::SetAddress(void* addr) //////////////////////////////////////////////////////////////////////////////// /// Reset basket size for all sub-branches. -void TBranchClones::SetBasketSize(Int_t bufsize) +void TBranchClones::SetBasketSize(Long64_t bufsize) { TBranch::SetBasketSize(bufsize); diff --git a/tree/tree/src/TBranchElement.cxx b/tree/tree/src/TBranchElement.cxx index a8227be2e1bac..6c4d4c7a23bc8 100644 --- a/tree/tree/src/TBranchElement.cxx +++ b/tree/tree/src/TBranchElement.cxx @@ -209,7 +209,7 @@ TBranchElement::TBranchElement() /// /// If splitlevel > 0 this branch in turn is split into sub-branches. -TBranchElement::TBranchElement(TTree *tree, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype) +TBranchElement::TBranchElement(TTree *tree, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize, Int_t splitlevel, Int_t btype) : TBranch() , fClassName(sinfo->GetName()) , fParentName() @@ -256,7 +256,7 @@ TBranchElement::TBranchElement(TTree *tree, const char* bname, TStreamerInfo* si /// /// If splitlevel > 0 this branch in turn is split into sub-branches. -TBranchElement::TBranchElement(TBranch *parent, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype) +TBranchElement::TBranchElement(TBranch *parent, const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize, Int_t splitlevel, Int_t btype) : TBranch() , fClassName(sinfo->GetName()) , fParentName() @@ -301,7 +301,7 @@ TBranchElement::TBranchElement(TBranch *parent, const char* bname, TStreamerInfo /// /// If splitlevel > 0 this branch in turn is split into sub-branches. -void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize, Int_t splitlevel, Int_t btype) +void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStreamerInfo* sinfo, Int_t id, char* pointer, Long64_t basketsize, Int_t splitlevel, Int_t btype) { TString name(bname); @@ -367,7 +367,8 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea // Make sure the basket is big enough to contain the // entry offset array plus 100 bytes of data. // - + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); if (basketsize < (100 + fEntryOffsetLen)) { basketsize = 100 + fEntryOffsetLen; } @@ -693,7 +694,7 @@ void TBranchElement::Init(TTree *tree, TBranch *parent,const char* bname, TStrea /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TTree *tree, const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TTree *tree, const char* bname, TClonesArray* clones, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName("TClonesArray") , fParentName() @@ -720,7 +721,7 @@ TBranchElement::TBranchElement(TTree *tree, const char* bname, TClonesArray* clo /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TBranch *parent, const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TBranch *parent, const char* bname, TClonesArray* clones, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName("TClonesArray") , fParentName() @@ -747,7 +748,7 @@ TBranchElement::TBranchElement(TBranch *parent, const char* bname, TClonesArray* /// /// If splitlevel > 0 this branch in turn is split into sub branches. -void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TClonesArray* clones, Int_t basketsize, Int_t splitlevel, Int_t compress) +void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TClonesArray* clones, Long64_t basketsize, Int_t splitlevel, Int_t compress) { fCollProxy = nullptr; fSplitLevel = splitlevel; @@ -848,7 +849,7 @@ void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TClon /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TTree *tree, const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TTree *tree, const char* bname, TVirtualCollectionProxy* cont, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName(cont->GetCollectionClass()->GetName()) , fParentName() @@ -874,7 +875,7 @@ TBranchElement::TBranchElement(TTree *tree, const char* bname, TVirtualCollectio /// /// If splitlevel > 0 this branch in turn is split into sub branches. -TBranchElement::TBranchElement(TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress) +TBranchElement::TBranchElement(TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Long64_t basketsize, Int_t splitlevel, Int_t compress) : TBranch() , fClassName(cont->GetCollectionClass()->GetName()) , fParentName() @@ -900,7 +901,7 @@ TBranchElement::TBranchElement(TBranch *parent, const char* bname, TVirtualColle /// /// If splitlevel > 0 this branch in turn is split into sub branches. -void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Int_t basketsize, Int_t splitlevel, Int_t compress) +void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TVirtualCollectionProxy* cont, Long64_t basketsize, Int_t splitlevel, Int_t compress) { fCollProxy = cont->Generate(); TString name( bname ); @@ -945,7 +946,8 @@ void TBranchElement::Init(TTree *tree, TBranch *parent, const char* bname, TVirt fCompress = bfile->GetCompressionSettings(); } } - + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); if (basketsize < 100) { basketsize = 100; } @@ -1261,9 +1263,9 @@ void TBranchElement::BuildTitle(const char* name) /// /// Note: We not not use any member functions from TLeafElement! -Int_t TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) +Long64_t TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) { - Int_t nbytes = 0; + Long64_t nbytes = 0; Int_t nwrite = 0; Int_t nerror = 0; Int_t nbranches = fBranches.GetEntriesFast(); @@ -1337,7 +1339,7 @@ Int_t TBranchElement::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) // Debugging. Long64_t entry = fEntries; if ((entry >= fTree->GetDebugMin()) && (entry <= fTree->GetDebugMax())) { - printf("Fill: %lld, branch=%s, nbytes=%d\n", entry, GetName(), nbytes); + printf("Fill: %lld, branch=%s, nbytes=%lld\n", entry, GetName(), nbytes); } } @@ -2710,7 +2712,7 @@ TClass* TBranchElement::GetCurrentClass() /// /// See IMPORTANT REMARKS in TTree::GetEntry. -Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) +Long64_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) { // Remember which entry we are reading. auto prevEntry = fReadEntry; @@ -2728,7 +2730,7 @@ Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) bref->SetRequestedEntry(entry); } - Int_t nbytes = 0; + Long64_t nbytes = 0; if (R__unlikely(IsAutoDelete())) { SetBit(kDeleteObject); @@ -2833,7 +2835,7 @@ Int_t TBranchElement::GetEntry(Long64_t entry, Int_t getall) if (R__unlikely(fTree->Debug() > 0)) { if ((entry >= fTree->GetDebugMin()) && (entry <= fTree->GetDebugMax())) { - Info("GetEntry", "%lld, branch=%s, nbytes=%d", entry, GetName(), nbytes); + Info("GetEntry", "%lld, branch=%s, nbytes=%lld", entry, GetName(), nbytes); } } return nbytes; @@ -5574,7 +5576,7 @@ void TBranchElement::SetAddressImpl(void* addr, bool implied, Int_t offset) //////////////////////////////////////////////////////////////////////////////// /// Reset the basket size for all sub-branches of this branch element. -void TBranchElement::SetBasketSize(Int_t bufsize) +void TBranchElement::SetBasketSize(Long64_t bufsize) { TBranch::SetBasketSize(bufsize); Int_t nbranches = fBranches.GetEntriesFast(); @@ -6136,7 +6138,7 @@ void TBranchElement::Streamer(TBuffer& R__b) /// This version of Unroll was formerly embedded in TTree::BronchExec /// It is moved here so we can make sure to call SetReadActionSequence. -void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, char* objptr, Int_t bufsize, Int_t splitlevel) +void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, char* objptr, Long64_t bufsize, Int_t splitlevel) { // // Do we have a final dot in our name? @@ -6270,7 +6272,7 @@ void TBranchElement::Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, /// except for a TObject base class of a class which has the /// can ignore tobject streamer flag set. -Int_t TBranchElement::Unroll(const char* name, TClass* clParent, TClass* cl, char* ptr, Int_t basketsize, Int_t splitlevel, Int_t btype) +Int_t TBranchElement::Unroll(const char* name, TClass* clParent, TClass* cl, char* ptr, Long64_t basketsize, Int_t splitlevel, Int_t btype) { //---------------------------------------------------------------------------- // Handling the case of STL collections of pointers diff --git a/tree/tree/src/TBranchObject.cxx b/tree/tree/src/TBranchObject.cxx index 7f77edee333ee..6b9fc81059f29 100644 --- a/tree/tree/src/TBranchObject.cxx +++ b/tree/tree/src/TBranchObject.cxx @@ -46,7 +46,7 @@ TBranchObject::TBranchObject() //////////////////////////////////////////////////////////////////////////////// /// Create a BranchObject. -TBranchObject::TBranchObject(TTree *tree, const char* name, const char* classname, void* addobj, Int_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) +TBranchObject::TBranchObject(TTree *tree, const char* name, const char* classname, void* addobj, Long64_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) : TBranch() { Init(tree,nullptr,name,classname,addobj,basketsize,splitlevel,compress,isptrptr); @@ -55,7 +55,7 @@ TBranchObject::TBranchObject(TTree *tree, const char* name, const char* classnam //////////////////////////////////////////////////////////////////////////////// /// Create a BranchObject. -TBranchObject::TBranchObject(TBranch *parent, const char* name, const char* classname, void* addobj, Int_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) +TBranchObject::TBranchObject(TBranch *parent, const char* name, const char* classname, void* addobj, Long64_t basketsize, Int_t splitlevel, Int_t compress, bool isptrptr /* = true */) : TBranch() { Init(nullptr,parent,name,classname,addobj,basketsize,splitlevel,compress,isptrptr); @@ -64,7 +64,7 @@ TBranchObject::TBranchObject(TBranch *parent, const char* name, const char* clas //////////////////////////////////////////////////////////////////////////////// /// Initialization routine (run from the constructor so do not make this function virtual) -void TBranchObject::Init(TTree *tree, TBranch *parent, const char* name, const char* classname, void* addobj, Int_t basketsize, Int_t /*splitlevel*/, Int_t compress, bool isptrptr) +void TBranchObject::Init(TTree *tree, TBranch *parent, const char* name, const char* classname, void* addobj, Long64_t basketsize, Int_t /*splitlevel*/, Int_t compress, bool isptrptr) { if (tree==nullptr && parent!=nullptr) tree = parent->GetTree(); fTree = tree; @@ -113,6 +113,8 @@ void TBranchObject::Init(TTree *tree, TBranch *parent, const char* name, const c if (basketsize < 100) { basketsize = 100; } + if (basketsize > kMaxInt) + Fatal("Init", "Integer overflow in basket size: 0x%llx for a max of 0x%x.", basketsize, kMaxInt); fBasketSize = basketsize; fAddress = (char*) addobj; fClassName = classname; @@ -168,9 +170,9 @@ void TBranchObject::Browse(TBrowser* b) //////////////////////////////////////////////////////////////////////////////// /// Loop on all leaves of this branch to fill Basket buffer. -Int_t TBranchObject::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) +Long64_t TBranchObject::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) { - Int_t nbytes = 0; + Long64_t nbytes = 0; Int_t nbranches = fBranches.GetEntriesFast(); if (nbranches) { ++fEntries; @@ -202,12 +204,12 @@ Int_t TBranchObject::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) /// - If entry does not exist the function returns 0. /// - If an I/O error occurs, the function returns -1. -Int_t TBranchObject::GetEntry(Long64_t entry, Int_t getall) +Long64_t TBranchObject::GetEntry(Long64_t entry, Int_t getall) { if (TestBit(kDoNotProcess) && !getall) { return 0; } - Int_t nbytes; + Long64_t nbytes; Int_t nbranches = fBranches.GetEntriesFast(); if (nbranches) { @@ -527,7 +529,7 @@ void TBranchObject::SetAutoDelete(bool autodel) //////////////////////////////////////////////////////////////////////////////// /// Reset basket size for all subbranches of this branch. -void TBranchObject::SetBasketSize(Int_t bufsize) +void TBranchObject::SetBasketSize(Long64_t bufsize) { TBranch::SetBasketSize(bufsize); diff --git a/tree/tree/src/TBranchRef.cxx b/tree/tree/src/TBranchRef.cxx index f53223130ddcd..c227d90d84cd6 100644 --- a/tree/tree/src/TBranchRef.cxx +++ b/tree/tree/src/TBranchRef.cxx @@ -99,9 +99,9 @@ void TBranchRef::Clear(Option_t *option) //////////////////////////////////////////////////////////////////////////////// /// Fill the branch basket with the referenced objects parent numbers. -Int_t TBranchRef::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) +Long64_t TBranchRef::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) { - Int_t nbytes = TBranch::FillImpl(imtHelper); + Long64_t nbytes = TBranch::FillImpl(imtHelper); return nbytes; } diff --git a/tree/tree/src/TBranchSTL.cxx b/tree/tree/src/TBranchSTL.cxx index 7e69b3ba0422b..14f166a6b9931 100644 --- a/tree/tree/src/TBranchSTL.cxx +++ b/tree/tree/src/TBranchSTL.cxx @@ -46,10 +46,12 @@ TBranchSTL::TBranchSTL(): TBranchSTL::TBranchSTL(TTree *tree, const char *name, TVirtualCollectionProxy *collProxy, - Int_t bufsize, Int_t splitlevel ) + Long64_t bufsize, Int_t splitlevel ) { fTree = tree; fCollProxy = collProxy; + if (bufsize > kMaxInt) + Fatal("TBranchSTL", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); fBasketSize = bufsize; fSplitLevel = splitlevel; fContName = collProxy->GetCollectionClass()->GetName(); @@ -88,11 +90,13 @@ TBranchSTL::TBranchSTL(TTree *tree, const char *name, TBranchSTL::TBranchSTL(TBranch* parent, const char* name, TVirtualCollectionProxy* collProxy, - Int_t bufsize, Int_t splitlevel, + Long64_t bufsize, Int_t splitlevel, TStreamerInfo* info, Int_t id ) { fTree = parent->GetTree(); fCollProxy = collProxy; + if (bufsize > kMaxInt) + Fatal("TBranchSTL", "Integer overflow in buffer size: 0x%llx for a max of 0x%x.", bufsize, kMaxInt); fBasketSize = bufsize; fSplitLevel = splitlevel; fContName = collProxy->GetCollectionClass()->GetName(); @@ -159,7 +163,7 @@ void TBranchSTL::Browse( TBrowser *b ) //////////////////////////////////////////////////////////////////////////////// /// Fill an STL branch. -Int_t TBranchSTL::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) +Long64_t TBranchSTL::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) { //--------------------------------------------------------------------------- // Cleanup after previous fill @@ -342,7 +346,7 @@ Int_t TBranchSTL::FillImpl(ROOT::Internal::TBranchIMTHelper *imtHelper) //////////////////////////////////////////////////////////////////////////////// /// Get entry. -Int_t TBranchSTL::GetEntry( Long64_t entry, Int_t getall ) +Long64_t TBranchSTL::GetEntry( Long64_t entry, Int_t getall ) { //--------------------------------------------------------------------------- // Check if we should be doing this at all diff --git a/tree/tree/src/TBufferSQL.cxx b/tree/tree/src/TBufferSQL.cxx index 2e93a05253040..ba4d09306ef5c 100644 --- a/tree/tree/src/TBufferSQL.cxx +++ b/tree/tree/src/TBufferSQL.cxx @@ -41,7 +41,7 @@ TBufferSQL::TBufferSQL(TBuffer::EMode mode, std::vector *vc, //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *vc, +TBufferSQL::TBufferSQL(TBuffer::EMode mode, Long64_t bufsize, std::vector *vc, TString *insert_query, TSQLRow ** r) : TBufferFile(mode,bufsize), fColumnVec(vc), fInsertQuery(insert_query), fRowPtr(r) @@ -52,7 +52,7 @@ TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *v //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsize, std::vector *vc, +TBufferSQL::TBufferSQL(TBuffer::EMode mode, Long64_t bufsize, std::vector *vc, TString *insert_query, TSQLRow ** r, void *buf, bool adopt) : TBufferFile(mode,bufsize,buf,adopt), diff --git a/tree/tree/src/TChain.cxx b/tree/tree/src/TChain.cxx index b9079f6c92c54..158868f576d3c 100644 --- a/tree/tree/src/TChain.cxx +++ b/tree/tree/src/TChain.cxx @@ -975,7 +975,7 @@ Long64_t TChain::GetEntries() const /// Return the total number of bytes read, /// 0 bytes read indicates a failure. -Int_t TChain::GetEntry(Long64_t entry, Int_t getall) +Long64_t TChain::GetEntry(Long64_t entry, Int_t getall) { Long64_t treeReadEntry = LoadTree(entry); if (treeReadEntry < 0) { @@ -1028,7 +1028,7 @@ Long64_t TChain::GetEntryNumber(Long64_t entry) const /// to (major,minor). /// \note See TTreeIndex::GetEntryNumberWithIndex for information about the maximum values accepted for major and minor -Int_t TChain::GetEntryWithIndex(Long64_t major, Long64_t minor) +Long64_t TChain::GetEntryWithIndex(Long64_t major, Long64_t minor) { Long64_t serial = GetEntryNumberWithIndex(major, minor); if (serial < 0) return -1; @@ -2016,7 +2016,7 @@ Long64_t TChain::Merge(TCollection* /* list */, TFileMergeInfo *) /// } /// ~~~ -Long64_t TChain::Merge(TFile* file, Int_t basketsize, Option_t* option) +Long64_t TChain::Merge(TFile* file, Long64_t basketsize, Option_t* option) { // We must have been passed a file, we will use it // later to reset the compression level of the branches. diff --git a/tree/tree/src/TNtuple.cxx b/tree/tree/src/TNtuple.cxx index 69dbc12efd682..a954f72c13dee 100644 --- a/tree/tree/src/TNtuple.cxx +++ b/tree/tree/src/TNtuple.cxx @@ -62,7 +62,7 @@ TNtuple::TNtuple(): TTree() /// - Use TTree to create branches with variables of different data types. /// - Use TTree when the number of branches is large (> 100). -TNtuple::TNtuple(const char *name, const char *title, const char *varlist, Int_t bufsize) +TNtuple::TNtuple(const char *name, const char *title, const char *varlist, Long64_t bufsize) :TTree(name,title) { Int_t i; @@ -165,7 +165,7 @@ void TNtuple::Browse(TBrowser *b) /// Note that this function is protected. /// Currently called only by TChain::Merge -Int_t TNtuple::Fill() +Long64_t TNtuple::Fill() { return TTree::Fill(); } diff --git a/tree/tree/src/TNtupleD.cxx b/tree/tree/src/TNtupleD.cxx index 1aa334611895c..11b3e58a7b0fa 100644 --- a/tree/tree/src/TNtupleD.cxx +++ b/tree/tree/src/TNtupleD.cxx @@ -61,7 +61,7 @@ TNtupleD::TNtupleD(): TTree() /// - Use TTree to create branches with variables of different data types. /// - Use TTree when the number of branches is large (> 100). -TNtupleD::TNtupleD(const char *name, const char *title, const char *varlist, Int_t bufsize) +TNtupleD::TNtupleD(const char *name, const char *title, const char *varlist, Long64_t bufsize) :TTree(name,title) { Int_t i; @@ -146,7 +146,7 @@ void TNtupleD::Browse(TBrowser *b) /// Note that this function is protected. /// Currently called only by TChain::Merge -Int_t TNtupleD::Fill() +Long64_t TNtupleD::Fill() { return TTree::Fill(); } @@ -154,7 +154,7 @@ Int_t TNtupleD::Fill() //////////////////////////////////////////////////////////////////////////////// /// Fill a Ntuple with an array of floats. -Int_t TNtupleD::Fill(const Double_t *x) +Long64_t TNtupleD::Fill(const Double_t *x) { //*-*- Store array x into buffer for (Int_t i=0;iFindObjectAny(foldername); if (!ob) { @@ -2014,7 +2014,7 @@ Int_t TTree::Branch(const char* foldername, Int_t bufsize /* = 32000 */, Int_t s /// A small value for bufsize is optimum if you intend to access /// the entries in the Tree randomly and your Tree is in split mode. -TBranch* TTree::Branch(const char* name, void* address, const char* leaflist, Int_t bufsize /* = 32000 */) +TBranch* TTree::Branch(const char* name, void* address, const char* leaflist, Long64_t bufsize /* = 32000 */) { TBranch* branch = new TBranch(this, name, address, leaflist, bufsize); if (branch->IsZombie()) { @@ -2049,7 +2049,7 @@ TBranch* TTree::Branch(const char* name, void* address, const char* leaflist, In /// Note: if the split level is set to the default (99), TTree::Branch will /// not issue a warning if the class can not be split. -TBranch* TTree::Branch(const char* name, const char* classname, void* addobj, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) +TBranch* TTree::Branch(const char* name, const char* classname, void* addobj, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) { if (fgBranchStyle == 1) { return Bronch(name, classname, addobj, bufsize, splitlevel); @@ -2102,7 +2102,7 @@ TBranch* TTree::Branch(const char* name, const char* classname, void* addobj, In /// A small value for bufsize is optimum if you intend to access /// the entries in the Tree randomly and your Tree is in split mode. -TBranch* TTree::BranchOld(const char* name, const char* classname, void* addobj, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 1 */) +TBranch* TTree::BranchOld(const char* name, const char* classname, void* addobj, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 1 */) { TClass* cl = TClass::GetClass(classname); if (!cl) { @@ -2432,7 +2432,7 @@ TBranch* TTree::BranchRef() /// Note: if the split level is set to the default (99), TTree::Branch will /// not issue a warning if the class can not be split. -TBranch* TTree::Bronch(const char* name, const char* classname, void* addr, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) +TBranch* TTree::Bronch(const char* name, const char* classname, void* addr, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) { return BronchExec(name, classname, addr, true, bufsize, splitlevel); } @@ -2440,7 +2440,7 @@ TBranch* TTree::Bronch(const char* name, const char* classname, void* addr, Int_ //////////////////////////////////////////////////////////////////////////////// /// Helper function implementing TTree::Bronch and TTree::Branch(const char *name, T &obj); -TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, bool isptrptr, Int_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) +TBranch* TTree::BronchExec(const char* name, const char* classname, void* addr, bool isptrptr, Long64_t bufsize /* = 32000 */, Int_t splitlevel /* = 99 */) { TClass* cl = TClass::GetClass(classname); if (!cl) { @@ -3809,7 +3809,8 @@ void TTree::Delete(Option_t* option /* = "" */) char header[16]; Int_t ntot = 0; Int_t nbask = 0; - Int_t nbytes,objlen,keylen; + Long64_t nbytes,objlen; + Int_t keylen; while ((leaf = (TLeaf*)next())) { TBranch *branch = leaf->GetBranch(); Int_t nbaskets = branch->GetMaxBaskets(); @@ -4651,10 +4652,10 @@ void TTree::DropBuffers(Int_t) /// greater than `TTree::fgMaxTreeSize`. This doesn't happen if the tree is /// attached to a `TMemFile` or derivate. -Int_t TTree::Fill() +Long64_t TTree::Fill() { - Int_t nbytes = 0; - Int_t nwrite = 0; + Long64_t nbytes = 0; + Long64_t nwrite = 0; Int_t nerror = 0; Int_t nbranches = fBranches.GetEntriesFast(); @@ -4690,7 +4691,7 @@ Int_t TTree::Fill() #endif if (nwrite < 0) { if (nerror < 2) { - Error("Fill", "Failed filling branch:%s.%s, nbytes=%d, entry=%lld\n" + Error("Fill", "Failed filling branch:%s.%s, nbytes=%lld, entry=%lld\n" " This error is symptomatic of a Tree created as a memory-resident Tree\n" " Instead of doing:\n" " TTree *T = new TTree(...)\n" @@ -4700,7 +4701,7 @@ Int_t TTree::Fill() " TTree *T = new TTree(...)\n\n", GetName(), branch->GetName(), nwrite, fEntries + 1); } else { - Error("Fill", "Failed filling branch:%s.%s, nbytes=%d, entry=%lld", GetName(), branch->GetName(), nwrite, + Error("Fill", "Failed filling branch:%s.%s, nbytes=%lld, entry=%lld", GetName(), branch->GetName(), nwrite, fEntries + 1); } ++nerror; @@ -4729,7 +4730,7 @@ Int_t TTree::Fill() KeepCircular(); if (gDebug > 0) - Info("TTree::Fill", " - A: %d %lld %lld %lld %lld %lld %lld \n", nbytes, fEntries, fAutoFlush, fAutoSave, + Info("TTree::Fill", " - A: %lld %lld %lld %lld %lld %lld %lld \n", nbytes, fEntries, fAutoFlush, fAutoSave, GetZipBytes(), fFlushedBytes, fSavedBytes); bool autoFlush = false; @@ -5193,10 +5194,10 @@ Int_t TTree::FlushBaskets(bool create_cluster) const /// /// Otherwise, the comments for FlushBaskets applies. /// -Int_t TTree::FlushBasketsImpl() const +Long64_t TTree::FlushBasketsImpl() const { if (!fDirectory) return 0; - Int_t nbytes = 0; + Long64_t nbytes = 0; Int_t nerror = 0; TObjArray *lb = const_cast(this)->GetListOfBranches(); Int_t nb = lb->GetEntriesFast(); @@ -5716,7 +5717,7 @@ Long64_t TTree::GetEntriesFriend() const /// Note: See the comments in TBranchElement::SetAddress() for the /// object ownership policy of the underlying (user) data. -Int_t TTree::GetEntry(Long64_t entry, Int_t getall) +Long64_t TTree::GetEntry(Long64_t entry, Int_t getall) { // We already have been visited while recursively looking // through the friends tree, let return @@ -5724,7 +5725,7 @@ Int_t TTree::GetEntry(Long64_t entry, Int_t getall) if (entry < 0 || entry >= fEntries) return 0; Int_t i; - Int_t nbytes = 0; + Long64_t nbytes = 0; fReadEntry = entry; // create cache if wanted @@ -6006,7 +6007,7 @@ Long64_t TTree::GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const /// to (major,minor). /// \note See TTreeIndex::GetEntryNumberWithIndex for information about the maximum values accepted for major and minor -Int_t TTree::GetEntryWithIndex(Long64_t major, Long64_t minor) +Long64_t TTree::GetEntryWithIndex(Long64_t major, Long64_t minor) { // We already have been visited while recursively looking // through the friends tree, let's return. @@ -6022,11 +6023,11 @@ Int_t TTree::GetEntryWithIndex(Long64_t major, Long64_t minor) SetCacheSizeAux(); Int_t i; - Int_t nbytes = 0; + Long64_t nbytes = 0; fReadEntry = serial; TBranch *branch; Int_t nbranches = fBranches.GetEntriesFast(); - Int_t nb; + Long64_t nb; for (i = 0; i < nbranches; ++i) { branch = (TBranch*)fBranches.UncheckedAt(i); nb = branch->GetEntry(serial); @@ -6954,7 +6955,7 @@ Int_t TTree::MakeSelector(const char* selector, Option_t* option) //////////////////////////////////////////////////////////////////////////////// /// Check if adding nbytes to memory we are still below MaxVirtualsize. -bool TTree::MemoryFull(Int_t nbytes) +bool TTree::MemoryFull(Long64_t nbytes) { if ((fTotalBuffers + nbytes) < fMaxVirtualSize) { return false; @@ -8563,7 +8564,7 @@ void TTree::SetAutoSave(Long64_t autos) /// see TRegexp for wildcarding options /// bufsize = branch basket size -void TTree::SetBasketSize(const char* bname, Int_t bufsize) +void TTree::SetBasketSize(const char* bname, Long64_t bufsize) { Int_t nleaves = fLeaves.GetEntriesFast(); TRegexp re(bname, true); @@ -10006,7 +10007,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 +Long64_t TTree::Write(const char *name, Int_t option, Long64_t bufsize) const { FlushBasketsImpl(); if (R__unlikely(option & kOnlyPrepStep)) @@ -10018,7 +10019,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) +Long64_t TTree::Write(const char *name, Int_t option, Long64_t bufsize) { return ((const TTree*)this)->Write(name, option, bufsize); } @@ -10125,13 +10126,13 @@ Option_t* TTreeFriendLeafIter::GetOption() const } TBranch *ROOT::Internal::TreeUtils::CallBranchImpRef(TTree &tree, const char *branchname, TClass *ptrClass, - EDataType datatype, void *addobj, Int_t bufsize, Int_t splitlevel) + EDataType datatype, void *addobj, Long64_t bufsize, Int_t splitlevel) { return tree.BranchImpRef(branchname, ptrClass, datatype, addobj, bufsize, splitlevel); } TBranch *ROOT::Internal::TreeUtils::CallBranchImp(TTree &tree, const char *branchname, TClass *ptrClass, void *addobj, - Int_t bufsize, Int_t splitlevel) + Long64_t bufsize, Int_t splitlevel) { return tree.BranchImp(branchname, ptrClass, addobj, bufsize, splitlevel); } diff --git a/tree/tree/src/TTreeCache.cxx b/tree/tree/src/TTreeCache.cxx index 285cbc6b47c3d..45720e634b115 100644 --- a/tree/tree/src/TTreeCache.cxx +++ b/tree/tree/src/TTreeCache.cxx @@ -316,7 +316,7 @@ TTreeCache::TTreeCache() : TFileCacheRead(), fPrefillType(GetConfiguredPrefillTy //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TTreeCache::TTreeCache(TTree *tree, Int_t bufsize) +TTreeCache::TTreeCache(TTree *tree, Long64_t bufsize) : TFileCacheRead(tree->GetCurrentFile(), bufsize, tree), fEntryMax(tree->GetEntriesFast()), fEntryNext(0), fBrNames(new TList), fTree(tree), fPrefillType(GetConfiguredPrefillType()) { @@ -2069,15 +2069,15 @@ void TTreeCache::ResetCache() /// - 1 if some or all of the buffer content has been made unavailable /// - -1 on error -Int_t TTreeCache::SetBufferSize(Long64_t buffersize) +Int_t TTreeCache::SetBufferSize(Long64_t bufsize) { Int_t prevsize = GetBufferSize(); - Int_t res = TFileCacheRead::SetBufferSize(buffersize); + Int_t res = TFileCacheRead::SetBufferSize(bufsize); if (res < 0) { return res; } - if (res == 0 && buffersize <= prevsize) { + if (res == 0 && bufsize <= prevsize) { return res; } diff --git a/tree/tree/src/TTreeCacheUnzip.cxx b/tree/tree/src/TTreeCacheUnzip.cxx index 507a23d0e218c..4239516c20d6e 100644 --- a/tree/tree/src/TTreeCacheUnzip.cxx +++ b/tree/tree/src/TTreeCacheUnzip.cxx @@ -174,7 +174,7 @@ TTreeCacheUnzip::TTreeCacheUnzip() : TTreeCache(), //////////////////////////////////////////////////////////////////////////////// /// Constructor. -TTreeCacheUnzip::TTreeCacheUnzip(TTree *tree, Int_t bufsize) : TTreeCache(tree,bufsize), +TTreeCacheUnzip::TTreeCacheUnzip(TTree *tree, Long64_t bufsize) : TTreeCache(tree,bufsize), fAsyncReading(false), fEmpty(true), fCycle(0), @@ -356,9 +356,9 @@ bool TTreeCacheUnzip::FillBuffer() /// - 1 if some or all of the buffer content has been made unavailable /// - -1 on error -Int_t TTreeCacheUnzip::SetBufferSize(Long64_t buffersize) +Int_t TTreeCacheUnzip::SetBufferSize(Long64_t bufsize) { - Int_t res = TTreeCache::SetBufferSize(buffersize); + Int_t res = TTreeCache::SetBufferSize(bufsize); if (res < 0) { return res; } @@ -466,13 +466,13 @@ Int_t TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::EParUnzipMode option) /// if maxbytes >=16 /// Note: This was adapted from TFile... so some things dont apply -Int_t TTreeCacheUnzip::GetRecordHeader(char *buf, Int_t maxbytes, Int_t &nbytes, Int_t &objlen, Int_t &keylen) +Long64_t TTreeCacheUnzip::GetRecordHeader(char *buf, Int_t maxbytes, Long64_t &nbytes, Long64_t &objlen, Long64_t &keylen) { Version_t versionkey; Short_t klen; UInt_t datime; - Int_t nb = 0, olen; - Int_t nread = maxbytes; + Long64_t nb = 0, olen; + Long64_t nread = maxbytes; frombuf(buf, &nb); nbytes = nb; if (nb < 0) return nread; @@ -523,16 +523,16 @@ void TTreeCacheUnzip::ResetCache() /// fUnzipStatus after fUnzipChunks and fUnzipLen and make sure fUnzipChunks /// and fUnzipLen are ready before main thread fetch the data. -Int_t TTreeCacheUnzip::UnzipCache(Int_t index) +Long64_t TTreeCacheUnzip::UnzipCache(Int_t index) { Int_t myCycle; const Int_t hlen = 128; - Int_t objlen = 0, keylen = 0; - Int_t nbytes = 0; - Int_t readbuf = 0; + Long64_t objlen = 0, keylen = 0; + Long64_t nbytes = 0; + Long64_t readbuf = 0; Long64_t rdoffs = 0; - Int_t rdlen = 0; + Long64_t rdlen = 0; // To synchronize with the 'paging' myCycle = fCycle; @@ -665,7 +665,7 @@ Int_t TTreeCacheUnzip::CreateTasks() /// responsibility of the caller to free it... it is useful for example /// to pass it to the creator of TBuffer -Int_t TTreeCacheUnzip::GetUnzipBuffer(char **buf, Long64_t pos, Int_t len, bool *free) +Long64_t TTreeCacheUnzip::GetUnzipBuffer(char **buf, Long64_t pos, Long64_t len, bool *free) { Int_t res = 0; Int_t loc = -1; @@ -850,14 +850,14 @@ void TTreeCacheUnzip::SetUnzipBufferSize(Long64_t bufferSize) /// src is the original buffer with the record (header+compressed data) /// *dest is the inflated buffer (including the header) -Int_t TTreeCacheUnzip::UnzipBuffer(char **dest, char *src) +Long64_t TTreeCacheUnzip::UnzipBuffer(char **dest, char *src) { Int_t uzlen = 0; bool alloc = false; // Here we read the header of the buffer const Int_t hlen = 128; - Int_t nbytes = 0, objlen = 0, keylen = 0; + Long64_t nbytes = 0, objlen = 0, keylen = 0; GetRecordHeader(src, hlen, nbytes, objlen, keylen); if (!(*dest)) { @@ -903,7 +903,7 @@ Int_t TTreeCacheUnzip::UnzipBuffer(char **dest, char *src) nin, nbuf, bufcur[3], bufcur[4], bufcur[5]); if (oldCase && (nin > objlen || nbuf > objlen)) { if (gDebug > 2) - Info("UnzipBuffer", "oldcase objlen :%d ", objlen); + Info("UnzipBuffer", "oldcase objlen :%lld ", objlen); //buffer was very likely not compressed in an old version memcpy(*dest + keylen, src + keylen, objlen); @@ -925,7 +925,7 @@ Int_t TTreeCacheUnzip::UnzipBuffer(char **dest, char *src) } if (noutot != objlen) { - Error("UnzipBuffer", "nbytes = %d, keylen = %d, objlen = %d, noutot = %d, nout=%d, nin=%d, nbuf=%d", + Error("UnzipBuffer", "nbytes = %lld, keylen = %lld, objlen = %lld, noutot = %d, nout=%d, nin=%d, nbuf=%d", nbytes,keylen,objlen, noutot,nout,nin,nbuf); uzlen = -1; if(alloc) delete [] *dest; diff --git a/tree/tree/src/TTreeSQL.cxx b/tree/tree/src/TTreeSQL.cxx index 6e7106d35f96c..4229246b0a85d 100644 --- a/tree/tree/src/TTreeSQL.cxx +++ b/tree/tree/src/TTreeSQL.cxx @@ -73,7 +73,7 @@ TTreeSQL::TTreeSQL(TSQLServer *server, TString DB, const TString& table) : /// Not implemented yet TBranch* TTreeSQL::BranchImp(const char *, const char *, - TClass *, void *, Int_t , + TClass *, void *, Long64_t , Int_t ) { Fatal("BranchImp","Not implemented yet"); @@ -84,7 +84,7 @@ TBranch* TTreeSQL::BranchImp(const char *, const char *, /// Not implemented yet TBranch* TTreeSQL::BranchImp(const char *, TClass *, - void *, Int_t , Int_t ) + void *, Long64_t , Int_t ) { Fatal("BranchImp","Not implemented yet"); return nullptr; @@ -92,7 +92,7 @@ TBranch* TTreeSQL::BranchImp(const char *, TClass *, //////////////////////////////////////////////////////////////////////////////// /// Not implemented yet -Int_t TTreeSQL::Branch(TCollection *, Int_t, +Int_t TTreeSQL::Branch(TCollection *, Long64_t, Int_t, const char *) { Fatal("Branch","Not implemented yet"); @@ -102,7 +102,7 @@ Int_t TTreeSQL::Branch(TCollection *, Int_t, //////////////////////////////////////////////////////////////////////////////// /// Not implemented yet -Int_t TTreeSQL::Branch(TList *, Int_t, Int_t) +Int_t TTreeSQL::Branch(TList *, Long64_t, Int_t) { Fatal("Branch","Not implemented yet"); return 0; @@ -111,7 +111,7 @@ Int_t TTreeSQL::Branch(TList *, Int_t, Int_t) //////////////////////////////////////////////////////////////////////////////// /// Not implemented yet -Int_t TTreeSQL::Branch(const char *, Int_t , +Int_t TTreeSQL::Branch(const char *, Long64_t , Int_t) { Fatal("Branch","Not implemented yet"); @@ -122,7 +122,7 @@ Int_t TTreeSQL::Branch(const char *, Int_t , /// Not implemented yet TBranch* TTreeSQL::Bronch(const char *, const char *, void *, - Int_t, Int_t) + Long64_t, Int_t) { Fatal("Bronch","Not implemented yet"); return nullptr; @@ -132,7 +132,7 @@ TBranch* TTreeSQL::Bronch(const char *, const char *, void *, /// Not implemented yet TBranch* TTreeSQL::BranchOld(const char *, const char *, - void *, Int_t, Int_t) + void *, Long64_t, Int_t) { Fatal("BranchOld","Not implemented yet"); return nullptr; @@ -142,7 +142,7 @@ TBranch* TTreeSQL::BranchOld(const char *, const char *, /// Not implemented yet TBranch *TTreeSQL::Branch(const char *, const char *, void *, - Int_t, Int_t) + Long64_t, Int_t) { Fatal("Branch","Not implemented yet"); return nullptr; @@ -152,7 +152,7 @@ TBranch *TTreeSQL::Branch(const char *, const char *, void *, /// Create a branch TBranch * TTreeSQL::Branch(const char *name, void *address, - const char *leaflist, Int_t bufsize) + const char *leaflist, Long64_t bufsize) { Int_t nb = fBranches.GetEntriesFast(); TBranch *branch; @@ -566,7 +566,7 @@ void TTreeSQL::Init() //////////////////////////////////////////////////////////////////////////////// /// Copy the information from the user object to the TTree -Int_t TTreeSQL::Fill() +Long64_t TTreeSQL::Fill() { Int_t nb = fBranches.GetEntriesFast(); TString typeName; @@ -725,7 +725,7 @@ Long64_t TTreeSQL::GetEntriesFast() const //////////////////////////////////////////////////////////////////////////////// /// Load the data for the entry from the database. -Int_t TTreeSQL::GetEntry(Long64_t entry, Int_t getall) +Long64_t TTreeSQL::GetEntry(Long64_t entry, Int_t getall) { if (PrepEntry(entry)>=0) return TTree::GetEntry(entry,getall); else return -1; diff --git a/tree/treeplayer/inc/TFileDrawMap.h b/tree/treeplayer/inc/TFileDrawMap.h index 5696d11304b3d..b79ae6d134cbf 100644 --- a/tree/treeplayer/inc/TFileDrawMap.h +++ b/tree/treeplayer/inc/TFileDrawMap.h @@ -43,7 +43,7 @@ class TFileDrawMap : public TNamed { virtual void DrawMarker(Int_t marker, Long64_t eseek); virtual bool GetObjectInfoDir(TDirectory *dir, Int_t px, Int_t py, TString &info) const; - virtual void PaintBox(TBox &box, Long64_t bseek, Int_t nbytes); + virtual void PaintBox(TBox &box, Long64_t bseek, Long64_t nbytes); virtual void PaintDir(TDirectory *dir, const char *keys); virtual TObject *GetObject(); diff --git a/tree/treeplayer/src/TFileDrawMap.cxx b/tree/treeplayer/src/TFileDrawMap.cxx index 6c7ec1d88e4ba..b1d30bdd3a6d2 100644 --- a/tree/treeplayer/src/TFileDrawMap.cxx +++ b/tree/treeplayer/src/TFileDrawMap.cxx @@ -227,11 +227,11 @@ void TFileDrawMap::AnimateTree(const char *branches) branch = (TBranch*)list.At(ib); Int_t nbaskets = branch->GetListOfBaskets()->GetSize(); Int_t basket = TMath::BinarySearch(nbaskets,branch->GetBasketEntry(), (Long64_t) entry); - Int_t nbytes = branch->GetBasketBytes()[basket]; - Int_t bseek = branch->GetBasketSeek(basket); - Int_t entry0 = branch->GetBasketEntry()[basket]; - Int_t entryn = branch->GetBasketEntry()[basket+1]; - Int_t eseek = (Int_t)(bseek + nbytes*Double_t(entry-entry0)/Double_t(entryn-entry0)); + Long64_t nbytes = branch->GetBasketBytes()[basket]; + Long64_t bseek = branch->GetBasketSeek(basket); + Long64_t entry0 = branch->GetBasketEntry()[basket]; + Long64_t entryn = branch->GetBasketEntry()[basket+1]; + Long64_t eseek = (Int_t)(bseek + nbytes*Double_t(entry-entry0)/Double_t(entryn-entry0)); DrawMarker(ib,branch->GetUniqueID()); DrawMarker(ib,eseek); branch->SetUniqueID(eseek); @@ -414,7 +414,7 @@ bool TFileDrawMap::GetObjectInfoDir(TDirectory *dir, Int_t px, Int_t py, TString Double_t y = gPad->AbsPixeltoY(py); Int_t iy = (Int_t)y; Long64_t pbyte = (Long64_t)(fXsize*iy+x); - Int_t nbytes; + Long64_t nbytes; Long64_t bseek; TDirectory *dirsav = gDirectory; dir->cd(); @@ -467,9 +467,9 @@ bool TFileDrawMap::GetObjectInfoDir(TDirectory *dir, Int_t px, Int_t py, TString bseek = key->GetSeekKey(); if (pbyte >= bseek && pbyte < bseek+nbytes) { if (curdir == (TDirectory*)fFile) { - info.Form("%s%s ::%s, nbytes=%d",curdir->GetPath(),key->GetName(),key->GetClassName(),nbytes); + info.Form("%s%s ::%s, nbytes=%lld",curdir->GetPath(),key->GetName(),key->GetClassName(),nbytes); } else { - info.Form("%s/%s ::%s, nbytes=%d",curdir->GetPath(),key->GetName(),key->GetClassName(),nbytes); + info.Form("%s/%s ::%s, nbytes=%lld",curdir->GetPath(),key->GetName(),key->GetClassName(),nbytes); } dirsav->cd(); return true; @@ -521,7 +521,7 @@ void TFileDrawMap::Paint(Option_t *) //////////////////////////////////////////////////////////////////////////////// /// Paint the object at bseek with nbytes using the box object. -void TFileDrawMap::PaintBox(TBox &box, Long64_t bseek, Int_t nbytes) +void TFileDrawMap::PaintBox(TBox &box, Long64_t bseek, Long64_t nbytes) { Int_t iy = bseek/fXsize; Int_t ix = bseek%fXsize; @@ -560,7 +560,7 @@ void TFileDrawMap::PaintDir(TDirectory *dir, const char *keys) TBox box; TRegexp re(keys,true); while ((key = (TKey*)next())) { - Int_t nbytes = key->GetNbytes(); + Long64_t nbytes = key->GetNbytes(); Long64_t bseek = key->GetSeekKey(); TClass *cl = TClass::GetClass(key->GetClassName()); if (cl) {