Skip to content

Avoid sprintf deprecation warning in test #18495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions roottest/root/io/bigevent/IoBigEventGeneration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void Event::SetHeader(Int_t i, Int_t run, Int_t date, Float_t random)
if (i > 10000) nch += 3;
if (fEventName) delete [] fEventName;
fEventName = new char[nch];
sprintf(fEventName,"Event%d_Run%d",i,200);
snprintf(fEventName, nch, "Event%d_Run%d", i, 200);
fNtrack = 0;
fEvtHdr.Set(i, run, date);
if (!fgHist) fgHist = new TH1F("hstat","Event Histogram",100,0,1);
Expand All @@ -299,7 +299,7 @@ void Event::SetHeader(Int_t i, Int_t run, Int_t date, Float_t random)
char lachaud[64];
string lac;
for (Int_t j=0;j<nch;j++) {
sprintf(lachaud,"run%d event%d j%d",run,i,j);
snprintf(lachaud, 64, "run%d event%d j%d", run, i, j);
lac = lachaud;
fLachaud.push_back(lac);
}
Expand Down Expand Up @@ -440,7 +440,7 @@ Track::Track(Float_t random) : TObject()
if (trackNumber > 10000) nch += 3;
// if (fTrackName) delete [] fTrackName;
fTrackName = new char[nch];
sprintf(fTrackName,"Track%d",trackNumber);
snprintf(fTrackName, nch, "Track%d", trackNumber);
//Int_t i;
//fHits.clear();
//for (i=0;i<12;i++) fHits.push_back(i);
Expand Down
2 changes: 1 addition & 1 deletion roottest/root/io/bigevent/IoBigEventGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ int main(int argc, char **argv)
Int_t ntrack = Int_t(arg5 +arg5*sigmat/120.);
Float_t random = gRandom->Rndm(1);

sprintf(etype,"type%d",ev%5);
snprintf(etype, 20, "type%d", ev % 5);
event->SetType(etype);
event->SetHeader(ev, 200, 960312, random);
event->SetNseg(Int_t(10*ntrack+20*sigmas));
Expand Down
Loading