Skip to content

Commit

Permalink
Fix GCC warning: forbidden conversion to char*
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
plexoos committed Sep 9, 2022
1 parent 258e62e commit f3f8ff2
Show file tree
Hide file tree
Showing 86 changed files with 180 additions and 178 deletions.
14 changes: 7 additions & 7 deletions OnlTools/Jevp/StJevpBuilders/fcsMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -347,7 +347,7 @@ int jacketColor(int ehp, int dep, int ch){
}

void getName(Int_t det, Int_t id, char name[]){
char* nameDET[6]={"EN","ES","HN","HS","PN","PS"};
const char* nameDET[6]={"EN","ES","HN","HS","PN","PS"};
int ehp,ns,crt,slt,dep,ch;
int c=getColumnNumber(det,id);
int r=getRowNumber(det,id);
Expand All @@ -359,7 +359,7 @@ void getName(Int_t det, Int_t id, char name[]){
}

void getName(Int_t ehp, Int_t ns, Int_t dep, Int_t ch, char name[]){
char* nameDET[6]={"EN","ES","HN","HS","PN","PS"};
const char* nameDET[6]={"EN","ES","HN","HS","PN","PS"};
int det,id,crt,slt;
getIdfromDep(ehp,ns,dep,ch,det,id,crt,slt);
// printf("%1d %1d %2d %2d : %1d %3d\n",ehp,ns,dep,ch,det,id);
Expand Down Expand Up @@ -743,9 +743,9 @@ void printMap(){
FILE *f7 = fopen("fcsEpdMap.txt","w");
FILE *fpp = fopen("fcsPPMap.txt","w");

char* EHP[3]={"Ecal","Hcal","Pres"};
char* CRT[5]={"EN","MN","MA","MS","ES"};
char* DET[6]={"EN","ES","HN","HS","PN","PS"};
const char* EHP[3]={"Ecal","Hcal","Pres"};
const char* CRT[5]={"EN","MN","MA","MS","ES"};
const char* DET[6]={"EN","ES","HN","HS","PN","PS"};

//Ecal
for(ns=0; ns<2; ns++){
Expand Down
2 changes: 1 addition & 1 deletion OnlTools/Jevp/StJevpPlot/CanvasImageBuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void CanvasImageBuilder::writeIndexFiles(FILE *f, DisplayNode *node, int page, i
}
}

int CanvasImageBuilder::writeIndexFromNode(FILE *f, DisplayNode *node, char *currdir, int page, int tabs) {
int CanvasImageBuilder::writeIndexFromNode(FILE *f, DisplayNode *node, const char *currdir, int page, int tabs) {
int npages = 0;
if(node->leaf) {
fprintf(f,"%s : %d\n", currdir, page);
Expand Down
2 changes: 1 addition & 1 deletion OnlTools/Jevp/StJevpPlot/CanvasImageBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CanvasImageBuilder {
private:
void writeIndexFiles(FILE *f, DisplayNode *node, int page, int tabs);
// Does above recursively...
int writeIndexFromNode(FILE *f, DisplayNode *node, char *dir, int page, int tabs);
int writeIndexFromNode(FILE *f, DisplayNode *node, const char *dir, int page, int tabs);

int writeImageFile(char *dir, DisplayNode *node, double ymax=-999);
// Does above recursively...
Expand Down
6 changes: 3 additions & 3 deletions OnlTools/Jevp/StJevpPlot/JevpPlotSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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, const char *my_plotsetname, const char *my_clientdatadir) {
char fn[256];
sprintf(fn, "%s/%s", my_clientdatadir, "dbVariable.tosend");

Expand Down Expand Up @@ -959,7 +959,7 @@ void JevpPlotSet::writePdfFile()
}

// ugly, but threadsafe if parent->addServerTags() is threadsafe!
void JevpPlotSet::addServerTags(char *tags)
void JevpPlotSet::addServerTags(const char *tags)
{
char *tmp = (char *)malloc(strlen(tags) + 3);
if(!tmp) {
Expand Down
6 changes: 3 additions & 3 deletions OnlTools/Jevp/StJevpPlot/JevpPlotSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class JevpPlotSet : public TObject {
int minEvts;
int maxEvts;

void addServerTags(char *tags);
void addServerTags(const char *tags);
//char *getServerTags();

RtsTimer_root *processingTimer;
Expand All @@ -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, const char *my_plotsetname, const char *my_clientdatadir);

JevpServer *parent;

Expand Down
4 changes: 2 additions & 2 deletions OnlTools/Jevp/StJevpServer/JevpServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void sigHandler(int arg, siginfo_t *sig, void *v)
l4sourceline = l4BuilderSourceLine;
}

char *line_builder = "";
const char *line_builder = "";
int plotSetLine = 0;
int plotSetCallParam = 0;
int builderLine = 0;
Expand Down Expand Up @@ -1341,7 +1341,7 @@ void JevpServer::performStartRun()
mem /= 1024.0;
LOG("JEFF", "Start run #%d (mem: %.1lfMB)",runStatus.run, mem);

char *servername = "JevpServer";
const char *servername = "JevpServer";
if(isL4) {
servername = "L4JevpServer";
}
Expand Down
4 changes: 2 additions & 2 deletions OnlTools/OnlinePlots/Infrastructure/EvpServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ void EvpServer::LaunchEndOfRunAction(long run) {
}

//------------------------------------------
void EvpServer::SetNewTarget(char *lTarget) {
void EvpServer::SetNewTarget(const char *lTarget) {
sprintf(mTarget,"%s",lTarget);
if(mDebugLevel) {
cout<<"New Target: "<< mTarget<<endl;
Expand Down Expand Up @@ -527,7 +527,7 @@ void EvpServer::SetDefaults()
mHistoSaved = 0; // initially histograms are not saved

// Starting directory for "FILE" mode
char *startingDirectory;
const char *startingDirectory;

startingDirectory ="/a";

Expand Down
2 changes: 1 addition & 1 deletion OnlTools/OnlinePlots/Infrastructure/EvpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class EvpServer {
void UpdateInfo();

void SetEnabled(bool b=true);
void SetNewTarget(char *);
void SetNewTarget(const char *);
void SetLive();
void SetStopFlag(void);
void SetGoFlag(void);
Expand Down
5 changes: 3 additions & 2 deletions OnlTools/OnlinePlots/Infrastructure/ServerGui.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ void ServerGui::DoFileButton()


static TGFileInfo* fi = new TGFileInfo();
fi->fIniDir = "/a";
static const char* inidir = "/a";
fi->fIniDir = const_cast<char*>(inidir);
fi->fFileTypes = (const char **)filetypes;
//At this point target is set

Expand Down Expand Up @@ -889,7 +890,7 @@ void ServerGui::ShowFileRun(bool run) {
ShowLiveRun( !run );
}
//--------------------------------------------------
void ServerGui::ShowStatus(char *lstatus) {
void ServerGui::ShowStatus(const char *lstatus) {

mRunStatusName->Clear();
mRunStatusName->AddText(0,lstatus);
Expand Down
2 changes: 1 addition & 1 deletion OnlTools/OnlinePlots/Infrastructure/ServerGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class ServerGui : public TObject
void ShowFileRun(bool run = true);
void ShowButton(TGButton* b, Pixel_t color);

void ShowStatus(char *);
void ShowStatus(const char *);

void SetEnabled(bool b = true);

Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/EventTracker/gl3Histo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
//####################################################################################
gl3Histo::gl3Histo ( char iId[10], char iTitle[100],
gl3Histo::gl3Histo (const char iId[10], const char iTitle[100],
int iNBins, double iXMin, double iXMax ) {
info = 0 ;
if ( iNBins < 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/EventTracker/gl3Histo.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class gl3Histo {
double* info ;

public:
gl3Histo ( char iId[10]="id", char iTitle[100]="name",
gl3Histo (const char iId[10]="id", const char iTitle[100]="name",
int iNBins=100, double iXMin=0., double iXMax=100. ) ;
~gl3Histo ( ) ;
int Fill (double x, double weight=1) ;
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/EventTracker/l3CoordinateTransformer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ l3CoordinateTransformer::~l3CoordinateTransformer()

#include "mapbin.h"

int l3CoordinateTransformer::LoadTPCLookupTable(char *)
int l3CoordinateTransformer::LoadTPCLookupTable(const char *)
{
// if (TPCmap) free(TPCmap);
// TPCmap = NULL;
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/EventTracker/l3CoordinateTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class l3CoordinateTransformer{
l3CoordinateTransformer() ; // Init parameters and variables
virtual ~l3CoordinateTransformer() ; // Delete variables

int LoadTPCLookupTable(char * filename = "/L3/etc/map.bin");
int LoadTPCLookupTable(const char * filename = "/L3/etc/map.bin");

// Memberfunctions
// raw -> global
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/include/fcfClass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public:
int compare(u_int *p1[3], u_int *p2[3]) ;

void decode(u_int *data, fcfHit *h, u_int *sim = 0) ; // utility: from FCF to local
void print_hit(char *, fcfHit *hit) ; // utility
void print_hit(const char *, fcfHit *hit) ; // utility

u_int do_swap ; // 0=no, 1=yes => set by "burn"
u_int do_merge ; // merge broken rows
Expand Down
4 changes: 2 additions & 2 deletions StRoot/RTS/src/DAQ_BSMD/bsmdPed.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions StRoot/RTS/src/DAQ_BTOW/daq_btow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ daq_dta *daq_btow::handle_raw()
char *from, *st ;
int bytes ;
char str[256] ;
char *full_name = "?" ; // just a dummy...
const char *full_name = "?" ; // just a dummy...

from = 0 ;
full_name = "?" ;

assert(caller) ;

Expand Down
10 changes: 5 additions & 5 deletions StRoot/RTS/src/DAQ_EMC/emc_reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ static char *inst2char(int inst)
static struct emc_describe_t {
int id ;

char *p ;
char *secp ;
char *rbp ;
char *adcr ;
char *adcd ;
const char *p ;
const char *secp ;
const char *rbp ;
const char *adcr ;
const char *adcd ;
int trg_index ;
int type ; // 0 Barrel, 1 Endcap
int sub ; // 0 tower, 1 SMD
Expand Down
8 changes: 4 additions & 4 deletions StRoot/RTS/src/DAQ_EMC/emc_single_reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include <DAQ_READER/daq_det.h>

const struct hdrs {
char *emcp ;
char *secp ;
char *rbp ;
char *adc ;
const char *emcp ;
const char *secp ;
const char *rbp ;
const char *adc ;
} hdrs[2] = {
{ CHAR_EMCP, CHAR_EMCSECP, CHAR_EMCRBP, CHAR_EMCADCR },
{ CHAR_EECP, CHAR_EECSECP, CHAR_EECRBP, CHAR_EECADCR }
Expand Down
8 changes: 4 additions & 4 deletions StRoot/RTS/src/DAQ_READER/daqReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ daqReader::daqReader(char *mem, int size)

}

daqReader::daqReader(char *name)
daqReader::daqReader(const char *name)
{
struct stat64 stat_buf ;

Expand Down Expand Up @@ -1141,7 +1141,7 @@ char *daqReader::skip_then_get(int numToSkip, int num, int type)
}


char *daqReader::getInputType()
const char *daqReader::getInputType()
{
switch(input_type) {
case none:
Expand Down Expand Up @@ -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 ;

Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions StRoot/RTS/src/DAQ_READER/daqReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -246,7 +246,7 @@ class daqReader {
u_int L3summary[4];

int fixDatapSummary(DATAP *datap);
char *getInputType();
const char *getInputType();
int getNextEventFilename(int num, int type);
int getNextEventFilenameFromLive(int type);
int getNextEventFilenameFromDir(int eventNum);
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/DAQ_READER/daq_det.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ daq_dta *daq_det::put(const char *bank,int c1, int c2, int c3, void *p1, void *


// helpers
int checkBank(char *in, char *expect)
int checkBank(char *in, const char *expect)
{
char buff[12] ;

Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/DAQ_READER/daq_det.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class daqReader ;
class daq_det ;

// helpers
extern int checkBank(char *in, char *expect) ;
extern int checkBank(char *in, const char *expect) ;
extern int *legacyDetp(int rts_id, char *datap) ;


Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/DAQ_TPX/tpxGain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/DAQ_TPX/tpxGain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/FCF/fcfAfterburner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fcfAfterburner::fcfAfterburner()
If "str" is non-NULL it prepends it to the line
as a label.
*/
void fcfAfterburner::print_hit(char *str, struct fcfHit *h)
void fcfAfterburner::print_hit(const char *str, struct fcfHit *h)
{
if(str) {
fprintf(stdout,"%s: ",str) ;
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/FCF/fcfClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <rtsSystems.h>
#include <fcfClass.hh>

static char *fcf_cvs_revision = "$Revision: 1.5 $" ;
static const char *fcf_cvs_revision = "$Revision: 1.5 $" ;

#ifdef __ROOT__ // STAR Offline

Expand Down
Loading

0 comments on commit f3f8ff2

Please sign in to comment.