From c134038b0f13eb33b1e36d2e8d4b054148803b10 Mon Sep 17 00:00:00 2001 From: Dylan Tuttle Date: Mon, 6 Nov 2023 08:24:14 -0800 Subject: [PATCH] Fix string literal conversion warnings in compiler/ras Fix string literal conversion warnings in compiler/ras Signed-off-by: Dylan Tuttle --- compiler/ras/Debug.cpp | 18 +++++++++--------- compiler/ras/Debug.hpp | 10 +++++----- compiler/ras/ILValidationRules.cpp | 2 +- compiler/ras/LimitFile.cpp | 30 +++++++++++++++--------------- compiler/ras/OptionsDebug.cpp | 28 ++++++++++++++-------------- compiler/ras/Tree.cpp | 2 +- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/compiler/ras/Debug.cpp b/compiler/ras/Debug.cpp index 891be089d15..5a932bbb5c3 100644 --- a/compiler/ras/Debug.cpp +++ b/compiler/ras/Debug.cpp @@ -764,7 +764,7 @@ TR_Debug::printPrefix(TR::FILE *pOutFile, TR::Instruction *instr, uint8_t *curso } else if (_registerAssignmentTraceFlags & TRACERA_IN_PROGRESS) { - char *spaces = " "; + const char *spaces = " "; int16_t padding = 30 - _registerAssignmentTraceCursor; if (padding < 0) @@ -1803,7 +1803,7 @@ TR_Debug::getAutoName(TR::SymbolReference * symRef) else if (slot < getOwningMethodSymbol(symRef)->getFirstJitTempIndex()) { int debugNameLen; - char *debugName = getOwningMethod(symRef)->localName(slot, 0, debugNameLen, comp()->trMemory()); // TODO: Proper bcIndex somehow; TODO: proper length + const char *debugName = getOwningMethod(symRef)->localName(slot, 0, debugNameLen, comp()->trMemory()); // TODO: Proper bcIndex somehow; TODO: proper length if (!debugName) { debugName = ""; @@ -1850,8 +1850,8 @@ TR_Debug::getParmName(TR::SymbolReference * symRef) int32_t debugNameLen, signatureLen; int32_t slot = symRef->getCPIndex(); const char * s = symRef->getSymbol()->castToParmSymbol()->getTypeSignature(signatureLen); - char *debugName = getOwningMethod(symRef)->localName(slot, 0, debugNameLen, comp()->trMemory()); // TODO: Proper bcIndex somehow; TODO: proper length - char * buf; + const char *debugName = getOwningMethod(symRef)->localName(slot, 0, debugNameLen, comp()->trMemory()); // TODO: Proper bcIndex somehow; TODO: proper length + char *buf; if (!debugName) { @@ -1937,7 +1937,7 @@ TR_Debug::getStaticName(TR::SymbolReference * symRef) TR::StackMemoryRegion stackMemoryRegion(*comp()->trMemory()); char *contents = NULL; intptr_t length = 0, prefixLength = 0, suffixOffset = 0; - char *etc = ""; + const char *etc = ""; const intptr_t LENGTH_LIMIT=80; const intptr_t PIECE_LIMIT=20; @@ -4949,18 +4949,18 @@ void TR_Debug::setupDebugger(void *addr) char cfname[20]; FILE *cf; char pp[20]; - char * Argv[20]; + char *Argv[20]; yield(); sprintf(cfname, "_%" OMR_PRId64 "_", (int64_t)getpid()); sprintf(pp, "%" OMR_PRId64, (int64_t)ppid); - Argv[1] = "-a"; + Argv[1] = (char *)"-a"; Argv[2] = pp; Argv[3] = NULL; if ((Argv[0] = ::feGetEnv("TR_DEBUGGER")) == NULL) { - Argv[0] = "/usr/bin/dbx"; + Argv[0] = (char *)"/usr/bin/dbx"; if ((cf = fopen(cfname, "wb+")) == 0) cfname[0] = '\0'; else @@ -4972,7 +4972,7 @@ void TR_Debug::setupDebugger(void *addr) fprintf(cf, "cont SIGCONT\n"); fclose(cf); - Argv[3] = "-c"; + Argv[3] = (char *)"-c"; Argv[4] = cfname; Argv[5] = NULL; } diff --git a/compiler/ras/Debug.hpp b/compiler/ras/Debug.hpp index 3d8b2efe138..7f0fd013610 100644 --- a/compiler/ras/Debug.hpp +++ b/compiler/ras/Debug.hpp @@ -463,11 +463,11 @@ class TR_Debug virtual int32_t findLogFile(const char *logFileName, TR::Options *aotCmdLineOptions, TR::Options *jitCmdLineOptions, TR::Options **optionsArray, int32_t arraySize); virtual void dumpOptionHelp(TR::OptionTable *jitOptions, TR::OptionTable *feOptions, TR::SimpleRegex *nameFilter); - static void dumpOptions(char *optionsType, char *options, char *envOptions, TR::Options *cmdLineOptions, TR::OptionTable *jitOptions, TR::OptionTable *feOptions, void *, TR_FrontEnd *); - virtual char * limitfileOption(char *, void *, TR::OptionTable *, TR::Options *, bool loadLimit, TR_PseudoRandomNumbersListElement **pseudoRandomListHeadPtr = 0); - virtual char * inlinefileOption(char *, void *, TR::OptionTable *, TR::Options *); - virtual char * limitOption(char *, void *, TR::OptionTable *, TR::Options *, bool loadLimit); - char * limitOption(char *, void *, TR::OptionTable *, TR::Options *, TR::CompilationFilters * &); + static void dumpOptions(const char *optionsType, const char *options, const char *envOptions, TR::Options *cmdLineOptions, TR::OptionTable *jitOptions, TR::OptionTable *feOptions, void *, TR_FrontEnd *); + virtual const char * limitfileOption(const char *, void *, TR::OptionTable *, TR::Options *, bool loadLimit, TR_PseudoRandomNumbersListElement **pseudoRandomListHeadPtr = 0); + virtual const char * inlinefileOption(const char *, void *, TR::OptionTable *, TR::Options *); + virtual const char * limitOption(const char *, void *, TR::OptionTable *, TR::Options *, bool loadLimit); + const char * limitOption(const char *, void *, TR::OptionTable *, TR::Options *, TR::CompilationFilters * &); virtual int32_t * loadCustomStrategy(char *optFileName); virtual bool methodCanBeCompiled(TR_Memory *mem, TR_ResolvedMethod *, TR_FilterBST * &); virtual bool methodCanBeRelocated(TR_Memory *mem, TR_ResolvedMethod *, TR_FilterBST * &); diff --git a/compiler/ras/ILValidationRules.cpp b/compiler/ras/ILValidationRules.cpp index 960e507b27b..7cc92873eab 100644 --- a/compiler/ras/ILValidationRules.cpp +++ b/compiler/ras/ILValidationRules.cpp @@ -269,7 +269,7 @@ void TR::ValidateLivenessBoundaries::updateNodeState(TR::Node *node, if (!liveNodes.isEmpty()) { traceMsg(comp(), " -- Live nodes: {"); - char *separator = ""; + const char *separator = ""; for (TR::LiveNodeWindow::Iterator lnwi(liveNodes); lnwi.currentNode(); ++lnwi) { traceMsg(comp(), "%sn%dn", separator, diff --git a/compiler/ras/LimitFile.cpp b/compiler/ras/LimitFile.cpp index 291c71852ce..b864459eb38 100644 --- a/compiler/ras/LimitFile.cpp +++ b/compiler/ras/LimitFile.cpp @@ -322,12 +322,12 @@ TR_Debug::scanInlineFilters(FILE * inlineFile, int32_t & lineNumber, TR::Compila * The unmodified parameter option if there is a problem with the file, aborting JIT initialization. * Otherwise a pointer to the next comma or NULL. */ -char * -TR_Debug::inlinefileOption(char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions) +const char * +TR_Debug::inlinefileOption(const char *option, void *base, TR::OptionTable *entry, TR::Options *cmdLineOptions) { - char *endOpt = option; - char *name = option; - char *fail = option; + char *endOpt = (char *)option; + const char *name = option; + const char *fail = option; // move to the end of this option for (; *endOpt && *endOpt != ','; endOpt++) @@ -406,12 +406,12 @@ TR_Debug::inlinefileOption(char *option, void *base, TR::OptionTable *entry, TR: * The unmodified parameter option if there is a problem with the file, aborting JIT initialization. * Otherwise a pointer to the next comma or NULL. */ -char * -TR_Debug::limitfileOption(char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, bool loadLimit, TR_PseudoRandomNumbersListElement **pseudoRandomListHeadPtr) +const char * +TR_Debug::limitfileOption(const char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, bool loadLimit, TR_PseudoRandomNumbersListElement **pseudoRandomListHeadPtr) { - char *endOpt = option; - char *name = option; - char *fail = option; + char *endOpt = (char *)option; + const char *name = option; + const char *fail = option; bool range = false; if (*endOpt == '(') @@ -611,10 +611,10 @@ TR_Debug::limitfileOption(char *option, void *base, TR::OptionTable *entry, TR:: return endOpt; } -char * -TR_Debug::limitOption(char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, TR::CompilationFilters *&filters) +const char * +TR_Debug::limitOption(const char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, TR::CompilationFilters *&filters) { - char *p = option; + char *p = (char *)option; filters = findOrCreateFilters(filters); TR_FilterBST *filter = addFilter(p, static_cast(entry->parm1), 0, 0, filters); @@ -682,8 +682,8 @@ TR_Debug::limitOption(char *option, void *base, TR::OptionTable *entry, TR::Opti return p; } -char * -TR_Debug::limitOption(char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, bool loadLimit) +const char * +TR_Debug::limitOption(const char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, bool loadLimit) { if (loadLimit) { diff --git a/compiler/ras/OptionsDebug.cpp b/compiler/ras/OptionsDebug.cpp index 5fb5ac39e55..ac7fab3a1ab 100644 --- a/compiler/ras/OptionsDebug.cpp +++ b/compiler/ras/OptionsDebug.cpp @@ -50,16 +50,16 @@ #define DEFAULT_OPTION_LINE_WIDTH 80 static char optionCategories[] = {' ','C','O','L','D','R','I','M',0}; // Must match categories[] in codegen.dev/Options.cpp -static char *optionCategoryNames[] = {"\nGeneral options:\n", - "\nCode generation options:\n", - "\nOptimization options:\n", - "\nLogging and display options:\n", - "\nDebugging options:\n", - "\nRecompilation and profiling options:\n", - "\nInternal options:\n", - "\nOther options:\n", - 0 // Fail quickly if we run past the end of this array - }; +static const char *optionCategoryNames[] = {"\nGeneral options:\n", + "\nCode generation options:\n", + "\nOptimization options:\n", + "\nLogging and display options:\n", + "\nDebugging options:\n", + "\nRecompilation and profiling options:\n", + "\nInternal options:\n", + "\nOther options:\n", + 0 // Fail quickly if we run past the end of this array + }; @@ -280,9 +280,9 @@ void TR_Debug::dumpOptionHelp(TR::OptionTable * firstOjit, TR::OptionTable * fir void TR_Debug::dumpOptions( - char *optionsType, - char *options, - char *envOptions, + const char *optionsType, + const char *options, + const char *envOptions, TR::Options *cmdLineOptions, TR::OptionTable *ojit, TR::OptionTable *ofe, @@ -493,7 +493,7 @@ TR_Debug::dumpOptions( //since java uses different function, we need to check for that to get our verbose options printed TR_VerboseLog::write("{"); base = (char*)cmdLineOptions; - char *sep = ""; + const char *sep = ""; for (int i=0; i < TR_NumVerboseOptions; i++) { TR_VerboseFlags flag = (TR_VerboseFlags)i; diff --git a/compiler/ras/Tree.cpp b/compiler/ras/Tree.cpp index e7a4273187d..96c250a9be4 100644 --- a/compiler/ras/Tree.cpp +++ b/compiler/ras/Tree.cpp @@ -1729,7 +1729,7 @@ TR_Debug::printNodeInfo(TR::Node * node, TR_PrettyPrinterString& output, bool pr { output.appends(" ; array type is "); - char *typeStr; + const char *typeStr; switch (node->getInt()) { case 4: