From 0b31427cf2e3823640fa3012c467d0ceb1783597 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Thu, 25 Aug 2022 17:12:10 -0400 Subject: [PATCH] Fix GCC warning: forbidden conversion to char* GCC 11 warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] GCC 485 warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] --- OnlTools/Jevp/StJevpBuilders/fcsMap.h | 4 ++-- OnlTools/Jevp/StJevpPlot/JevpPlotSet.cxx | 4 ++-- OnlTools/Jevp/StJevpPlot/JevpPlotSet.h | 4 ++-- StRoot/RTS/src/DAQ_BSMD/bsmdPed.cxx | 4 ++-- StRoot/RTS/src/DAQ_READER/daqReader.cxx | 6 +++--- StRoot/RTS/src/DAQ_READER/daqReader.h | 4 ++-- StRoot/RTS/src/DAQ_TPX/tpxGain.cxx | 2 +- StRoot/RTS/src/DAQ_TPX/tpxGain.h | 2 +- StRoot/RTS/src/FCF/fcfClass.cxx | 2 +- StRoot/RTS/src/RTS_EXAMPLE/rts_example.trg.C | 2 +- .../StStrangeMuDstMaker/StStrangeMuDstPlayer.cxx | 14 ++++++++------ StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.h | 8 ++++---- StRoot/StSvtClusterMaker/StSvtHitMaker.cxx | 2 +- StRoot/StSvtClusterMaker/StSvtHitMaker.h | 6 +++--- StRoot/StSvtDaqMaker/StSvtDaqMaker.cxx | 2 +- StRoot/StSvtDaqMaker/StSvtDaqMaker.h | 10 +++++----- 16 files changed, 39 insertions(+), 37 deletions(-) diff --git a/OnlTools/Jevp/StJevpBuilders/fcsMap.h b/OnlTools/Jevp/StJevpBuilders/fcsMap.h index f52d20b3c87..34abae9f704 100644 --- a/OnlTools/Jevp/StJevpBuilders/fcsMap.h +++ b/OnlTools/Jevp/StJevpBuilders/fcsMap.h @@ -128,8 +128,8 @@ Short_t HMapSCBRA[10]; Short_t HMapSCPP[10]; Short_t HMapSCJ[10]; -char* colW[4]={"Green ","Brown ","Orange","Blue "}; -char* colJ[8]={"Blue ","Orange","Violet","Black ", +const char* colW[4]={"Green ","Brown ","Orange","Blue "}; +const char* colJ[8]={"Blue ","Orange","Violet","Black ", "Yellow","Red ","Grey ","Blue "}; float leng[8]={ 6.5, 6.5, 5.0, 5.0, 3.5, 3.5, 8.0, 8.0}; diff --git a/OnlTools/Jevp/StJevpPlot/JevpPlotSet.cxx b/OnlTools/Jevp/StJevpPlot/JevpPlotSet.cxx index 71a4410b4e6..c222d3e253f 100644 --- a/OnlTools/Jevp/StJevpPlot/JevpPlotSet.cxx +++ b/OnlTools/Jevp/StJevpPlot/JevpPlotSet.cxx @@ -92,11 +92,11 @@ JevpPlotSet::JevpPlotSet(JevpServer *server) PCP; } -void JevpPlotSet::logDbVariable(char *name, double value) { +void JevpPlotSet::logDbVariable(const char *name, double value) { JevpPlotSet::staticLogDbVariable(name, value, run, lastevttm, plotsetname, clientdatadir); } -void JevpPlotSet::staticLogDbVariable(char *name, double value, int my_run, int my_time, char *my_plotsetname, char *my_clientdatadir) { +void JevpPlotSet::staticLogDbVariable(const char *name, double value, int my_run, int my_time, char *my_plotsetname, char *my_clientdatadir) { char fn[256]; sprintf(fn, "%s/%s", my_clientdatadir, "dbVariable.tosend"); diff --git a/OnlTools/Jevp/StJevpPlot/JevpPlotSet.h b/OnlTools/Jevp/StJevpPlot/JevpPlotSet.h index b610424b69a..0ac7ce625c8 100644 --- a/OnlTools/Jevp/StJevpPlot/JevpPlotSet.h +++ b/OnlTools/Jevp/StJevpPlot/JevpPlotSet.h @@ -124,8 +124,8 @@ class JevpPlotSet : public TObject { //StTriggerData *getStTriggerData(daqReader *rdr); - void logDbVariable(char *variable_name, double value); - static void staticLogDbVariable(char *name, double value, int my_run, int my_time, char *my_plotsetname, char *my_clientdatadir); + void logDbVariable(const char *variable_name, double value); + static void staticLogDbVariable(const char *name, double value, int my_run, int my_time, char *my_plotsetname, char *my_clientdatadir); JevpServer *parent; diff --git a/StRoot/RTS/src/DAQ_BSMD/bsmdPed.cxx b/StRoot/RTS/src/DAQ_BSMD/bsmdPed.cxx index 61b505aefb4..570b46b1fb4 100644 --- a/StRoot/RTS/src/DAQ_BSMD/bsmdPed.cxx +++ b/StRoot/RTS/src/DAQ_BSMD/bsmdPed.cxx @@ -342,7 +342,7 @@ int bsmdPed::to_evb(char *buff) int bsmdPed::from_cache(char *fname) { FILE *f ; - char *fn ; + const char *fn ; init(0x3F) ; // to clear ped storage for all 6 RDOs @@ -395,7 +395,7 @@ int bsmdPed::to_cache(char *fname, u_int run) { FILE *f ; int r, p, t ; - char *fn ; + const char *fn ; if(!valid) { diff --git a/StRoot/RTS/src/DAQ_READER/daqReader.cxx b/StRoot/RTS/src/DAQ_READER/daqReader.cxx index 244527c3c84..846dcec8c7a 100644 --- a/StRoot/RTS/src/DAQ_READER/daqReader.cxx +++ b/StRoot/RTS/src/DAQ_READER/daqReader.cxx @@ -82,7 +82,7 @@ daqReader::daqReader(char *mem, int size) } -daqReader::daqReader(char *name) +daqReader::daqReader(const char *name) { struct stat64 stat_buf ; @@ -1665,7 +1665,7 @@ int daqReader::fillSummaryInfo_v02(SummaryInfo *info, gbPayload_0x02 *pay) { /////// Tonko - char *daqReader::get_sfs_name(char *right) + char *daqReader::get_sfs_name(const char *right) { if(sfs == 0) return 0 ; @@ -2024,7 +2024,7 @@ int daqReader::fillSummaryInfo_v02(SummaryInfo *info, gbPayload_0x02 *pay) { msg.head.status = 0 ; msg.ld.dword[0] = htonl(getpid()) ; - char *user ; + const char *user ; struct passwd *passwd = getpwuid(getuid()) ; if(passwd == NULL) { diff --git a/StRoot/RTS/src/DAQ_READER/daqReader.h b/StRoot/RTS/src/DAQ_READER/daqReader.h index 7a072bc20ba..fb91efd2ce5 100644 --- a/StRoot/RTS/src/DAQ_READER/daqReader.h +++ b/StRoot/RTS/src/DAQ_READER/daqReader.h @@ -94,7 +94,7 @@ class daqReader { // space separated files --> read from each file in turn // daqReader(char *buffer, int size); - daqReader(char *fname) ; + daqReader(const char *fname) ; ~daqReader(void) ; void init(); @@ -111,7 +111,7 @@ class daqReader { void insert(daq_det *which, int rts_id) ; void de_insert(int rts_id) ; void Make() ; - char *get_sfs_name(char *snippet=0) ; // returns the full name of the SFS + char *get_sfs_name(const char *snippet=0) ; // returns the full name of the SFS char *get(int which, int type=EVP_TYPE_ANY) ; char *skip_then_get(int numToSkip, int num, int type=EVP_TYPE_ANY); // The following are the descriptors and pointers defining the event diff --git a/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx b/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx index 504d62785f6..5923f6244e4 100644 --- a/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx +++ b/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx @@ -842,7 +842,7 @@ void tpxGain::do_default(int sec) return ; } -int tpxGain::from_file(char *fname, int sec) +int tpxGain::from_file(const char *fname, int sec) { FILE *f ; int s, r, p ; diff --git a/StRoot/RTS/src/DAQ_TPX/tpxGain.h b/StRoot/RTS/src/DAQ_TPX/tpxGain.h index 1e45e83537e..79d0734942c 100644 --- a/StRoot/RTS/src/DAQ_TPX/tpxGain.h +++ b/StRoot/RTS/src/DAQ_TPX/tpxGain.h @@ -152,7 +152,7 @@ class tpxGain return (gains[s-1] + r*TPX_MAX_PAD + (p-1)) ; } - int from_file(char *fname, int sector = 0) ; + int from_file(const char *fname, int sector = 0) ; // [sector 1-24][RDO 1-6][fee-index 0-35] diff --git a/StRoot/RTS/src/FCF/fcfClass.cxx b/StRoot/RTS/src/FCF/fcfClass.cxx index f78509bff87..2603c0e27e4 100755 --- a/StRoot/RTS/src/FCF/fcfClass.cxx +++ b/StRoot/RTS/src/FCF/fcfClass.cxx @@ -42,7 +42,7 @@ #include #include -static char *fcf_cvs_revision = "$Revision: 1.5 $" ; +static const char *fcf_cvs_revision = "$Revision: 1.5 $" ; #ifdef __ROOT__ // STAR Offline diff --git a/StRoot/RTS/src/RTS_EXAMPLE/rts_example.trg.C b/StRoot/RTS/src/RTS_EXAMPLE/rts_example.trg.C index 89f745fc598..a6ca863ede0 100644 --- a/StRoot/RTS/src/RTS_EXAMPLE/rts_example.trg.C +++ b/StRoot/RTS/src/RTS_EXAMPLE/rts_example.trg.C @@ -1115,7 +1115,7 @@ static int fgt_doer(daqReader *rdr, const char *do_print, int which) char s_found[128] ; daq_dta *dd ; - char *d_name = 0 ; + const char *d_name = 0 ; switch(which) { diff --git a/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.cxx b/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.cxx index 4baa79811ee..936ade2006d 100755 --- a/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.cxx +++ b/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.cxx @@ -1,3 +1,5 @@ +#include + #include "StChain.h" #include "StIOMaker/StIOMaker.h" #include "StEventMaker/StEventMaker.h" @@ -17,8 +19,8 @@ ClassImp(StrangeMuDstPlayer) char empty = '\0'; char slash = '/'; -void ParseFileName(Char_t *output, Char_t **file, Char_t **dir) { - if ((*file = strrchr(output,slash))) { +void ParseFileName(const Char_t *output, Char_t **file, Char_t **dir) { + if ((*file = std::strrchr(output,slash))) { (*file)++; *dir = new char[strlen(output)+5]; strncpy(*dir,output,(strlen(output)-strlen(*file))); @@ -53,7 +55,7 @@ StrangeMuDstPlayer::StrangeMuDstPlayer() { xiDcaBachelorToPrimVertex = 0.; } -void StrangeMuDstPlayer::Make(Int_t NEvents, StFile* input, Char_t* output) { +void StrangeMuDstPlayer::Make(Int_t NEvents, StFile* input, const Char_t* output) { StStrangeMuDstMaker *muDstMakers[3]; StStrangeMuDstMaker *v0MuDstMaker, *xiMuDstMaker, *kinkMuDstMaker; @@ -166,7 +168,7 @@ void StrangeMuDstPlayer::Make(Int_t NEvents, StFile* input, Char_t* output) { } } -void StrangeMuDstPlayer::Filter(Int_t NEvents, StFile* input, Char_t* output) { +void StrangeMuDstPlayer::Filter(Int_t NEvents, StFile* input, const Char_t* output) { StStrangeMuDstMaker *oldMuDstMaker=0; StStrangeMuDstMaker *newMuDstMakers[3]; @@ -366,7 +368,7 @@ void StrangeMuDstPlayer::Filter(Int_t NEvents, StFile* input, Char_t* output) { } } -void StrangeMuDstPlayer::Play(Int_t NEvents, StFile* input, Char_t* output) { +void StrangeMuDstPlayer::Play(Int_t NEvents, StFile* input, const Char_t* output) { StStrangeMuDstMaker *oldMuDstMaker=0; StStrangeMuDstMaker *newMuDstMakers[3]; @@ -592,7 +594,7 @@ void StrangeMuDstPlayer::Play(Int_t NEvents, StFile* input, Char_t* output) { } } -void StrangeMuDstPlayer::Copy(Int_t NEvents, StFile* input, Char_t* output) { +void StrangeMuDstPlayer::Copy(Int_t NEvents, StFile* input, const Char_t* output) { StStrangeMuDstMaker *oldMuDstMaker=0; StStrangeMuDstMaker *newMuDstMakers[3]; diff --git a/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.h b/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.h index 18344c8e27f..0f1a0ac55ff 100644 --- a/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.h +++ b/StRoot/StStrangeMuDstMaker/StStrangeMuDstPlayer.h @@ -7,10 +7,10 @@ class StrangeMuDstPlayer { public: StrangeMuDstPlayer(); virtual ~StrangeMuDstPlayer() {} - void Make(Int_t NEvents, StFile* input, Char_t *output="evMuDst.root"); - void Filter(Int_t NEvents, StFile* input, Char_t *output="evMuDst.root"); - void Play(Int_t NEvents, StFile* input, Char_t *output="evMuDst.root"); - void Copy(Int_t NEvents, StFile* input, Char_t *output="evMuDst.root"); + void Make(Int_t NEvents, StFile* input, const Char_t *output="evMuDst.root"); + void Filter(Int_t NEvents, StFile* input, const Char_t *output="evMuDst.root"); + void Play(Int_t NEvents, StFile* input, const Char_t *output="evMuDst.root"); + void Copy(Int_t NEvents, StFile* input, const Char_t *output="evMuDst.root"); void DoFileSplit(Bool_t val = kTRUE); void DoMC(Bool_t val = kTRUE); void DoT0Abort(Bool_t val = kTRUE); diff --git a/StRoot/StSvtClusterMaker/StSvtHitMaker.cxx b/StRoot/StSvtClusterMaker/StSvtHitMaker.cxx index 523913ef3a0..1dcde3c182e 100644 --- a/StRoot/StSvtClusterMaker/StSvtHitMaker.cxx +++ b/StRoot/StSvtClusterMaker/StSvtHitMaker.cxx @@ -742,7 +742,7 @@ Int_t StSvtHitMaker::Finish(){ } //________________________________________________________________________ -void StSvtHitMaker::SetFileNames(char* filen, char* filec){ +void StSvtHitMaker::SetFileNames(const char* filen, const char* filec){ filenameN = filen; filenameC = filec; } diff --git a/StRoot/StSvtClusterMaker/StSvtHitMaker.h b/StRoot/StSvtClusterMaker/StSvtHitMaker.h index 5a243cd6fbd..baae901b548 100644 --- a/StRoot/StSvtClusterMaker/StSvtHitMaker.h +++ b/StRoot/StSvtClusterMaker/StSvtHitMaker.h @@ -106,7 +106,7 @@ class StSvtHitMaker : public StMaker void TransformIntoSpacePoint(); void SaveIntoNtuple(int numOfCluster, int index); void SetWriteNtuple(int iwrite){iWrite = iwrite;}; - void SetFileNames(char* name1="/dev/null", char* name2="/dev/null"); + void SetFileNames(const char* name1="/dev/null", const char* name2="/dev/null"); Int_t Eval(); double LaserTemperatureCorrection(); @@ -145,8 +145,8 @@ class StSvtHitMaker : public StMaker TH1F *mZHitResolution; //! TH2F *mHitResolution; //! - char* filenameN; - char* filenameC; + const char* filenameN; + const char* filenameC; ClassDef(StSvtHitMaker,0) //virtual base class for Makers diff --git a/StRoot/StSvtDaqMaker/StSvtDaqMaker.cxx b/StRoot/StSvtDaqMaker/StSvtDaqMaker.cxx index 0fc5b087ac2..6d08885bb14 100644 --- a/StRoot/StSvtDaqMaker/StSvtDaqMaker.cxx +++ b/StRoot/StSvtDaqMaker/StSvtDaqMaker.cxx @@ -83,7 +83,7 @@ ClassImp(StSvtDaqMaker) //_____________________________________________________________________________ - StSvtDaqMaker::StSvtDaqMaker(const char *name, char* config, char* data):StMaker(name) + StSvtDaqMaker::StSvtDaqMaker(const char *name, const char* config, const char* data):StMaker(name) { fConfig = config; fDataType = data; diff --git a/StRoot/StSvtDaqMaker/StSvtDaqMaker.h b/StRoot/StSvtDaqMaker/StSvtDaqMaker.h index bff98c3daf2..cbe9fcb60f3 100644 --- a/StRoot/StSvtDaqMaker/StSvtDaqMaker.h +++ b/StRoot/StSvtDaqMaker/StSvtDaqMaker.h @@ -60,8 +60,8 @@ class TObjectSet; class StSvtDaqMaker : public StMaker { private: - char *fConfig; //! - char *fDataType; //! + const char *fConfig; //! + const char *fDataType; //! StSvtHybridDaqData *fData; //! StSvtDaqData *fSvtData; //! @@ -79,10 +79,10 @@ class StSvtDaqMaker : public StMaker { protected: public: - StSvtDaqMaker(const char *name="SvtDaq", char* config="FULL", char* data="ZS"); + StSvtDaqMaker(const char *name="SvtDaq", const char* config="FULL", const char* data="ZS"); virtual ~StSvtDaqMaker(); - void SetConfiguration(char* config){fConfig = config;} - void SetDataType(char* data){fDataType = data;} + void SetConfiguration(const char* config){fConfig = config;} + void SetDataType(const char* data){fDataType = data;} Int_t SetSvtData(); Int_t SetSvtPed(); Int_t SetSvtRMSPed();