replaced sprintf -> snprintf throughout.
This commit is contained in:
2
src/external/BMWtools/BMWStartupHandler.cpp
vendored
2
src/external/BMWtools/BMWStartupHandler.cpp
vendored
@@ -403,7 +403,7 @@ void BMWStartupHandler::CheckLists()
|
||||
<< "BMWStartupHandler::CheckLists: Most probably this will go wrong and should therefore be fixed in the xml-file!" << std::endl;
|
||||
char eChar[5];
|
||||
for(unsigned int i(0); i<fEnergyList.size(); i++) {
|
||||
sprintf(eChar, "%02.1f", fEnergyList[i]);
|
||||
snprintf(eChar, sizeof(eChar), "%02.1f", fEnergyList[i]);
|
||||
fEnergyLabelList.push_back(std::string(eChar));
|
||||
}
|
||||
}
|
||||
|
||||
40
src/external/TLemRunHeader/TLemRunHeader.cxx
vendored
40
src/external/TLemRunHeader/TLemRunHeader.cxx
vendored
@@ -91,7 +91,7 @@ void TLemRunHeader::SetStopTimeString(const Char_t *stop){
|
||||
void TLemRunHeader::SetModeratorHV(Float_t modHV, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s, "05 Moderator HV: %8.2f(%5.2f)", modHV, error);
|
||||
snprintf(s, sizeof(s), "05 Moderator HV: %8.2f(%5.2f)", modHV, error);
|
||||
str = s;
|
||||
fModeratorHVString.SetString(str);
|
||||
fModeratorHV = modHV;
|
||||
@@ -101,7 +101,7 @@ void TLemRunHeader::SetModeratorHV(Float_t modHV, Float_t error){
|
||||
void TLemRunHeader::SetSampleHV(Float_t value, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"06 Sample HV: %8.2f(%5.2f)", value, error);
|
||||
snprintf(s, sizeof(s), "06 Sample HV: %8.2f(%5.2f)", value, error);
|
||||
str = s;
|
||||
fSampleHVString.SetString(str);
|
||||
fSampleHV = value;
|
||||
@@ -111,7 +111,7 @@ void TLemRunHeader::SetSampleHV(Float_t value, Float_t error){
|
||||
void TLemRunHeader::SetImpEnergy(Float_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"07 Impl. Energy: %8.2f", value);
|
||||
snprintf(s, sizeof(s), "07 Impl. Energy: %8.2f", value);
|
||||
str = s;
|
||||
fImpEnergyString.SetString(str);
|
||||
fImpEnergy = value;
|
||||
@@ -120,7 +120,7 @@ void TLemRunHeader::SetImpEnergy(Float_t value){
|
||||
void TLemRunHeader::SetSampleTemperature(Float_t value, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"08 Sample T: %8.2f(%5.2f)", value, error);
|
||||
snprintf(s, sizeof(s), "08 Sample T: %8.2f(%5.2f)", value, error);
|
||||
str = s;
|
||||
fSampleTemperatureString.SetString(str);
|
||||
fSampleTemperature = value;
|
||||
@@ -130,7 +130,7 @@ void TLemRunHeader::SetSampleTemperature(Float_t value, Float_t error){
|
||||
void TLemRunHeader::SetSampleBField(Float_t value, Float_t error){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"09 Sample B: %8.2f(%5.2f)", value, error);
|
||||
snprintf(s, sizeof(s), "09 Sample B: %8.2f(%5.2f)", value, error);
|
||||
str = s;
|
||||
fSampleBFieldString.SetString(str);
|
||||
fSampleBField = value;
|
||||
@@ -140,7 +140,7 @@ void TLemRunHeader::SetSampleBField(Float_t value, Float_t error){
|
||||
void TLemRunHeader::SetTimeResolution(Float_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"10 Time Res.: %10.7f", value);
|
||||
snprintf(s, sizeof(s), "10 Time Res.: %10.7f", value);
|
||||
str = s;
|
||||
fTimeResolutionString.SetString(str);
|
||||
fTimeResolution = value;
|
||||
@@ -149,7 +149,7 @@ void TLemRunHeader::SetTimeResolution(Float_t value){
|
||||
void TLemRunHeader::SetNChannels(Int_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"11 N Channels: %8d", value);
|
||||
snprintf(s, sizeof(s), "11 N Channels: %8d", value);
|
||||
str = s;
|
||||
fNChannelsString.SetString(str);
|
||||
fNChannels = value;
|
||||
@@ -158,7 +158,7 @@ void TLemRunHeader::SetNChannels(Int_t value){
|
||||
void TLemRunHeader::SetNHist(Int_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"12 N Histograms: %6d", value);
|
||||
snprintf(s, sizeof(s), "12 N Histograms: %6d", value);
|
||||
str = s;
|
||||
fNHistString.SetString(str);
|
||||
fNHist = value;
|
||||
@@ -168,7 +168,7 @@ void TLemRunHeader::SetNHist(Int_t value){
|
||||
void TLemRunHeader::SetOffsetPPCHistograms(UInt_t value){
|
||||
TString str;
|
||||
char s[80];
|
||||
sprintf(s,"13 Offset PPC Histograms: %6d", value);
|
||||
snprintf(s, sizeof(s), "13 Offset PPC Histograms: %6d", value);
|
||||
str = s;
|
||||
fOffsetPPCHistogramsString.SetString(str);
|
||||
fOffsetPPCHistograms = value;
|
||||
@@ -364,25 +364,25 @@ void TLemRunHeader::DrawHeader() const {
|
||||
strcpy(str, "Run Stop: ");
|
||||
strcat(str, runStop);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Run Number: %10d", GetRunNumber());
|
||||
snprintf(str, sizeof(str), "Run Number: %10d", GetRunNumber());
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Moderator HV: %10.2f kV", fModeratorHV);
|
||||
snprintf(str, sizeof(str), "Moderator HV: %10.2f kV", fModeratorHV);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Sample HV: %10.2f kV", fSampleHV);
|
||||
snprintf(str, sizeof(str), "Sample HV: %10.2f kV", fSampleHV);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Impl. Energy: %10.2f keV", fImpEnergy);
|
||||
snprintf(str, sizeof(str), "Impl. Energy: %10.2f keV", fImpEnergy);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Sample T: %10.2f K", fSampleTemperature);
|
||||
snprintf(str, sizeof(str), "Sample T: %10.2f K", fSampleTemperature);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Sample B: %10.2f G", fSampleBField);
|
||||
snprintf(str, sizeof(str), "Sample B: %10.2f G", fSampleBField);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Time Res.: %10.7f ns", fTimeResolution);
|
||||
snprintf(str, sizeof(str), "Time Res.: %10.7f ns", fTimeResolution);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "N Channels: %10d", fNChannels);
|
||||
snprintf(str, sizeof(str), "N Channels: %10d", fNChannels);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "N Histograms: %10d", fNHist);
|
||||
snprintf(str, sizeof(str), "N Histograms: %10d", fNHist);
|
||||
text = pt->AddText(str);
|
||||
sprintf(str, "Offset PPC Histograms: %10d", fOffsetPPCHistograms);
|
||||
snprintf(str, sizeof(str), "Offset PPC Histograms: %10d", fOffsetPPCHistograms);
|
||||
text = pt->AddText(str);
|
||||
strcpy(str, "Cuts: ");
|
||||
strcat(str, cuts);
|
||||
@@ -393,7 +393,7 @@ void TLemRunHeader::DrawHeader() const {
|
||||
|
||||
strcpy(str,"t0: ");
|
||||
for (Int_t i=0; i<fNHist; i++){
|
||||
sprintf(helpstr, " %7.2f ", fTimeZero[i]);
|
||||
snprintf(helpstr, sizeof(helpstr), " %7.2f ", fTimeZero[i]);
|
||||
strcat(str, helpstr);
|
||||
}
|
||||
text = pt->AddText(str);
|
||||
|
||||
2
src/external/libCuba/src/common/Fork.c
vendored
2
src/external/libCuba/src/common/Fork.c
vendored
@@ -75,7 +75,7 @@ Extern void SUFFIX(cubafork)(Spin **pspin)
|
||||
}
|
||||
|
||||
if( cubaverb_ ) {
|
||||
sprintf(out, "using %d cores %d accelerators via "
|
||||
snprintf(out, sizeof(out), "using %d cores %d accelerators via "
|
||||
#ifdef HAVE_SHMGET
|
||||
"shared memory",
|
||||
#else
|
||||
|
||||
2
src/external/libCuba/src/common/Parallel.c
vendored
2
src/external/libCuba/src/common/Parallel.c
vendored
@@ -47,7 +47,7 @@ static inline void DoSampleParallel(This *t, number n, creal *x, real *f
|
||||
t->neval += n;
|
||||
|
||||
if( VERBOSE > 2 ) {
|
||||
sprintf(out, "sampling " NUMBER " points each on %d cores",
|
||||
snprintf(out, sizeof(out), "sampling " NUMBER " points each on %d cores",
|
||||
pcores, ncores);
|
||||
Print(out);
|
||||
}
|
||||
|
||||
6
src/external/libCuba/src/common/stddecl.h
vendored
6
src/external/libCuba/src/common/stddecl.h
vendored
@@ -94,7 +94,7 @@ enum { uninitialized = 0x61627563 };
|
||||
var = atoi(env); \
|
||||
if( cubaverb_ ) { \
|
||||
char out[64]; \
|
||||
sprintf(out, "env " name " = %d", (int)var); \
|
||||
snprintf(out, sizeof(out), "env " name " = %d", (int)var); \
|
||||
Print(out); \
|
||||
} \
|
||||
} \
|
||||
@@ -280,7 +280,7 @@ enum { signature = 0x41425543 };
|
||||
} \
|
||||
if( ini | statemsg ) { \
|
||||
char s[512]; \
|
||||
sprintf(s, ini ? \
|
||||
snprintf(s, sizeof(s), ini ? \
|
||||
"\nError restoring state from %s, starting from scratch." : \
|
||||
"\nRestored state from %s.", (t)->statefile); \
|
||||
Print(s); \
|
||||
@@ -307,7 +307,7 @@ enum { signature = 0x41425543 };
|
||||
} \
|
||||
if( fail | statemsg ) { \
|
||||
char s[512]; \
|
||||
sprintf(s, fail ? \
|
||||
snprintf(s, sizeof(s), fail ? \
|
||||
"\nError saving state to %s." : \
|
||||
"\nSaved state to %s.", (t)->statefile); \
|
||||
Print(s); \
|
||||
|
||||
22
src/external/libCuba/src/divonne/Integrate.c
vendored
22
src/external/libCuba/src/divonne/Integrate.c
vendored
@@ -36,7 +36,7 @@ static int Integrate(This *t, real *integral, real *error, real *prob)
|
||||
int fail;
|
||||
|
||||
if( VERBOSE > 1 ) {
|
||||
sprintf(out, "Divonne input parameters:\n"
|
||||
snprintf(out, sizeof(out), "Divonne input parameters:\n"
|
||||
" ndim " COUNT "\n ncomp " COUNT "\n"
|
||||
ML_NOT(" nvec " NUMBER "\n")
|
||||
" epsrel " REAL "\n epsabs " REAL "\n"
|
||||
@@ -189,7 +189,7 @@ if( StateWriteTest(t) ) { \
|
||||
WriteState(t);
|
||||
|
||||
if( VERBOSE ) {
|
||||
char *oe = out + sprintf(out, "\n"
|
||||
char *oe = out + snprintf(out, sizeof(out), "\n"
|
||||
"Iteration " COUNT " (pass " COUNT "): " COUNT " regions\n"
|
||||
NUMBER7 " integrand evaluations so far,\n"
|
||||
NUMBER7 " in optimizing regions,\n"
|
||||
@@ -197,7 +197,7 @@ if( StateWriteTest(t) ) { \
|
||||
state->iter, state->pass, t->nregions,
|
||||
t->neval, t->neval_opt, t->neval_cut);
|
||||
for( comp = 0; comp < t->ncomp; ++comp )
|
||||
oe += sprintf(oe, "\n[" COUNT "] "
|
||||
oe += snprintf(oe, sizeof(out), "\n[" COUNT "] "
|
||||
REAL " +- " REAL,
|
||||
comp + 1, SHOW(integral[comp]), SHOW(error[comp]));
|
||||
Print(out);
|
||||
@@ -255,7 +255,7 @@ if( StateWriteTest(t) ) { \
|
||||
SamplesAlloc(t, &t->samples[1]);
|
||||
|
||||
if( VERBOSE ) {
|
||||
sprintf(out, "\nMain integration on " COUNT
|
||||
snprintf(out, sizeof(out), "\nMain integration on " COUNT
|
||||
" regions with " NUMBER " samples per region.",
|
||||
t->nregions, t->samples[1].neff);
|
||||
Print(out);
|
||||
@@ -325,7 +325,7 @@ refine:
|
||||
can_adjust = false;
|
||||
|
||||
if( VERBOSE > 2 ) {
|
||||
sprintf(out, "Sampling remaining " COUNT
|
||||
snprintf(out, sizeof(out), "Sampling remaining " COUNT
|
||||
" regions with " NUMBER " points per region.",
|
||||
t->nregions, t->samples[1].neff);
|
||||
Print(out);
|
||||
@@ -369,7 +369,7 @@ refine:
|
||||
if( VERBOSE > 2 ) {
|
||||
cchar *msg = "\nRegion (" REALF ") - (" REALF ")";
|
||||
for( B = (b = region->bounds) + t->ndim; b < B; ++b ) {
|
||||
oe += sprintf(oe, msg, b->lower, b->upper);
|
||||
oe += snprintf(oe, sizeof(out), msg, b->lower, b->upper);
|
||||
msg = "\n (" REALF ") - (" REALF ")";
|
||||
}
|
||||
}
|
||||
@@ -408,12 +408,12 @@ refine:
|
||||
if( VERBOSE > 2 ) {
|
||||
#define Out2(f, r) SHOW((r)->avg), SHOW(res->spread/t->samples[f].neff), SHOW((r)->err)
|
||||
#define Out(f) Out2(f, &tot->phase[f])
|
||||
oe += sprintf(oe, "\n[" COUNT "] "
|
||||
oe += snprintf(oe, sizeof(out), "\n[" COUNT "] "
|
||||
REAL " +- " REAL "(" REAL ")\n "
|
||||
REAL " +- " REAL "(" REAL ")", ++comp, Out(0), Out(1));
|
||||
if( todo == 3 ) oe += sprintf(oe, "\n "
|
||||
if( todo == 3 ) oe += snprintf(oe, sizeof(out), "\n "
|
||||
REAL " +- " REAL "(" REAL ")", Out2(2, res));
|
||||
oe += sprintf(oe, " \tchisq " REAL, SHOW(chisq));
|
||||
oe += snprintf(oe, sizeof(out), " \tchisq " REAL, SHOW(chisq));
|
||||
}
|
||||
|
||||
tot->integral += avg;
|
||||
@@ -440,9 +440,9 @@ refine:
|
||||
}
|
||||
|
||||
if( VERBOSE > 2 ) {
|
||||
char *oe = out + sprintf(out, "\nTotals:");
|
||||
char *oe = out + snprintf(out, sizeof(out), "\nTotals:");
|
||||
for( tot = state->totals, comp = 0; tot < Tot; ++tot, ++comp )
|
||||
oe += sprintf(oe, "\n[" COUNT "] "
|
||||
oe += snprintf(oe, sizeof(out), "\n[" COUNT "] "
|
||||
REAL " +- " REAL " \tchisq " REAL " (" COUNT " df)",
|
||||
comp + 1, SHOW(integral[comp]), SHOW(error[comp]),
|
||||
SHOW(tot->chisq), df);
|
||||
|
||||
@@ -317,7 +317,7 @@ void TPofBCalc::Calculate(const TBofZCalc *BofZ, const TTrimSPData *dataTrimSP,
|
||||
seconds = time (NULL);
|
||||
|
||||
char debugfile[50];
|
||||
int n = sprintf (debugfile, "test_Bz_%ld_%f.dat", seconds, fBmin);
|
||||
int n = snprintf (debugfile, sizeof(debugfile), "test_Bz_%ld_%f.dat", seconds, fBmin);
|
||||
|
||||
if (n > 0) {
|
||||
ofstream of(debugfile);
|
||||
@@ -330,10 +330,10 @@ void TPofBCalc::Calculate(const TBofZCalc *BofZ, const TTrimSPData *dataTrimSP,
|
||||
}
|
||||
|
||||
char debugfile1[50];
|
||||
int n1 = sprintf (debugfile1, "test_NZ_%ld_%f.dat", seconds, para[2]);
|
||||
int n1 = snprintf (debugfile1, sizeof(debugfile1), "test_NZ_%ld_%f.dat", seconds, para[2]);
|
||||
|
||||
char debugfile2[50];
|
||||
int n2 = sprintf (debugfile2, "test_NZgss_%ld_%f.dat", seconds, para[2]);
|
||||
int n2 = snprintf (debugfile2, sizeof(debugfile2), "test_NZgss_%ld_%f.dat", seconds, para[2]);
|
||||
|
||||
if (n1 > 0) {
|
||||
ofstream of1(debugfile1);
|
||||
|
||||
@@ -357,7 +357,7 @@ void TPofTCalc::FakeData(const string &rootOutputFileName, const std::vector<dou
|
||||
// create run info folder and content
|
||||
TFolder *runInfoFolder = new TFolder("RunInfo", "Run Info");
|
||||
TLemRunHeader *runHeader = new TLemRunHeader();
|
||||
//sprintf(str, "Fake Data generated from %s", pBFileName.Data());
|
||||
//snprintf(str, sizeof(str), "Fake Data generated from %s", pBFileName.Data());
|
||||
runHeader->SetRunTitle("Fake Data");
|
||||
if (optPar && (optPar->size() > 1)) { // set energy and field if they were specified
|
||||
runHeader->SetImpEnergy((*optPar)[1]);
|
||||
|
||||
@@ -163,7 +163,7 @@ int generateRgeFln(const string prefix, const string elist, vector<string> &rgeF
|
||||
}
|
||||
ival = start;
|
||||
do {
|
||||
sprintf(istr, "%d", ival);
|
||||
snprintf(istr, sizeof(istr), "%d", ival);
|
||||
str = prefix + istr + ".rge";
|
||||
rgeFln.push_back(str);
|
||||
ival += step;
|
||||
|
||||
Reference in New Issue
Block a user