Skip to content

Commit

Permalink
Fix string literal conversion warnings in compiler/infra
Browse files Browse the repository at this point in the history
Fix string literal conversion warnings in compiler/infra
and related functions

Signed-off-by: Dylan Tuttle <jdylantuttle@gmail.com>
  • Loading branch information
dylanjtuttle committed Dec 11, 2023
1 parent 573e419 commit f148db8
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion compiler/il/OMRResolvedMethodSymbol.cpp
Expand Up @@ -268,7 +268,7 @@ bcIndexForFakeInduce(TR::Compilation* comp, int16_t* callSiteInsertionPoint,
if (!p) break;
strncpy(signatureRegex, p, temp - p);
signatureRegex[temp-p] = '\0';
char* tempRegex = signatureRegex;
const char *tempRegex = (const char *)signatureRegex;
TR::SimpleRegex* regex = TR::SimpleRegex::create(tempRegex);
if (regex)
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/infra/InterferenceGraph.cpp
Expand Up @@ -503,7 +503,7 @@ bool TR_InterferenceGraph::select()


#ifdef DEBUG
void TR_InterferenceGraph::dumpIG(char *msg)
void TR_InterferenceGraph::dumpIG(const char *msg)
{
if (msg)
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/infra/InterferenceGraph.hpp
Expand Up @@ -144,9 +144,9 @@ class TR_InterferenceGraph : public TR_IGBase
IGNodeColour findMinimumChromaticNumber();

#ifdef DEBUG
void dumpIG(char *msg = NULL);
void dumpIG(const char *msg = NULL);
#else
void dumpIG(char *msg = NULL) {}
void dumpIG(const char *msg = NULL) {}
#endif
};
#endif
10 changes: 5 additions & 5 deletions compiler/infra/SimpleRegex.cpp
Expand Up @@ -55,11 +55,11 @@
namespace TR
{

SimpleRegex *SimpleRegex::create(char *&s)
SimpleRegex *SimpleRegex::create(const char *& s)
{
if (s == NULL || s[0] != '{')
return NULL;
char *origStr = s;
const char *origStr = s;
++s;
bool negate = (s[0] == '^');
if (negate)
Expand All @@ -78,7 +78,7 @@ SimpleRegex *SimpleRegex::create(char *&s)
}


SimpleRegex::Regex *SimpleRegex::processRegex(char *&s, bool &foundError)
SimpleRegex::Regex *SimpleRegex::processRegex(const char *&s, bool &foundError)
{
// First get rid of all + and |
//
Expand Down Expand Up @@ -108,10 +108,10 @@ void *SimpleRegex::Component::operator new (size_t size, PERSISTENT_NEW_DECLARE,

// Process a simple_pattern: a sequence of components
//
SimpleRegex::Simple *SimpleRegex::processSimple(char *&s, TR_YesNoMaybe allowAlternates, bool &foundError)
SimpleRegex::Simple *SimpleRegex::processSimple(const char *&s, TR_YesNoMaybe allowAlternates, bool &foundError)
{
int32_t i,lo,hi;
char *startSimple = s;
const char *startSimple = s;

if (s[0] == '\0' || s[0] == ',' || s[0] == '|' || s[0] == '}')
return NULL;
Expand Down
8 changes: 4 additions & 4 deletions compiler/infra/SimpleRegex.hpp
Expand Up @@ -50,7 +50,7 @@ class SimpleRegex

// Create a new regular expression
//
static SimpleRegex *create(char *&s);
static SimpleRegex *create(const char *& s);

// Check whether a string matches this regular expression
//
Expand Down Expand Up @@ -139,15 +139,15 @@ class SimpleRegex

private:

static Regex *processRegex(char *&s, bool &foundError);
static Simple *processSimple(char *&s, TR_YesNoMaybe allowAlternates, bool &foundError);
static Regex *processRegex(const char *&s, bool &foundError);
static Simple *processSimple(const char *&s, TR_YesNoMaybe allowAlternates, bool &foundError);

Regex *_regex;
bool _negate;

// Length and pointer to the original string that the regex was parsed from
size_t _regexStrLen;
char *_regexStr;
const char *_regexStr;
};

}
Expand Down
16 changes: 8 additions & 8 deletions compiler/infra/Statistics.hpp
Expand Up @@ -272,13 +272,13 @@ class TR_StatsEvents
public:
enum {NAME_LEN=31};
TR_StatsEvents() {}
TR_StatsEvents(const char *name, char **binNames, int minEventId)
TR_StatsEvents(const char *name, const char **binNames, int minEventId)
{
init(name, binNames, minEventId);
}
// the init method can be used if we want to declare an array of stats
// that are initialized later (in a for loop)
void init(const char *name, char **binNames, int minEventId)
void init(const char *name, const char **binNames, int minEventId)
{
strncpy(_name, name, NAME_LEN);
_name[NAME_LEN] = 0; // just in case name is longer than _name
Expand Down Expand Up @@ -341,12 +341,12 @@ class TR_StatsEvents
}
unsigned samples() const {return _numSamples;}
protected:
char _name[NAME_LEN+1];
int _bins[N];
char** _binNames;
int _minEventId; // value of smallest bin
int _numSamples;
int _numInvalidSamples;
char _name[NAME_LEN+1];
int _bins[N];
const char **_binNames;
int _minEventId; // value of smallest bin
int _numSamples;
int _numInvalidSamples;
};

#endif
4 changes: 2 additions & 2 deletions compiler/optimizer/Inliner.cpp
Expand Up @@ -4258,11 +4258,11 @@ void TR_InlinerBase::applyPolicyToTargets(TR_CallStack *callStack, TR_CallSite *

static bool traceIfMatchesPattern(TR::Compilation* comp)
{
static char* cRegex = feGetEnv ("TR_printIfRegex");
static const char *cRegex = feGetEnv ("TR_printIfRegex");

if (cRegex && comp->getOptions() && comp->getOptions()->getDebug())
{
static TR::SimpleRegex * regex = TR::SimpleRegex::create(cRegex);
static TR::SimpleRegex *regex = TR::SimpleRegex::create(cRegex);
if (TR::SimpleRegex::match(regex, comp->signature(), false))
{
return true;
Expand Down
6 changes: 3 additions & 3 deletions compiler/ras/Debug.hpp
Expand Up @@ -481,10 +481,10 @@ class TR_Debug
virtual void clearFilters(TR::CompilationFilters *);
void clearFilters(bool loadLimit);
virtual bool scanInlineFilters(FILE *, int32_t &, TR::CompilationFilters *);
virtual TR_FilterBST * addFilter(char * &, int32_t, int32_t, int32_t, TR::CompilationFilters *);
virtual TR_FilterBST * addFilter(char * &, int32_t, int32_t, int32_t, bool loadLimit);
virtual TR_FilterBST * addFilter(const char *&, int32_t, int32_t, int32_t, TR::CompilationFilters *);
virtual TR_FilterBST * addFilter(const char *&, int32_t, int32_t, int32_t, bool loadLimit);
virtual TR_FilterBST * addExcludedMethodFilter(bool loadLimit);
virtual int32_t scanFilterName(char *, TR_FilterBST *);
virtual int32_t scanFilterName(const char *, TR_FilterBST *);
virtual void printFilters(TR::CompilationFilters *);
virtual void printFilters();
virtual void print(TR_FilterBST * filter);
Expand Down
30 changes: 15 additions & 15 deletions compiler/ras/LimitFile.cpp
Expand Up @@ -102,7 +102,7 @@ TR_Debug::findOrCreateFilters(bool loadLimit)
}

TR_FilterBST *
TR_Debug::addFilter(char * & filterString, int32_t scanningExclude, int32_t optionSetIndex, int32_t lineNum, TR::CompilationFilters * anyFilters)
TR_Debug::addFilter(const char *& filterString, int32_t scanningExclude, int32_t optionSetIndex, int32_t lineNum, TR::CompilationFilters * anyFilters)
{
uint32_t filterType = scanningExclude ? TR_FILTER_EXCLUDE_NAME_ONLY : TR_FILTER_NAME_ONLY;

Expand All @@ -115,7 +115,7 @@ TR_Debug::addFilter(char * & filterString, int32_t scanningExclude, int32_t opti
int32_t nameLength;
if (*filterString == '{')
{
char *filterCursor = filterString;
const char *filterCursor = filterString;
filterType = scanningExclude ? TR_FILTER_EXCLUDE_REGEX : TR_FILTER_REGEX;
filterBST->setFilterType(filterType);

Expand Down Expand Up @@ -184,7 +184,7 @@ TR_Debug::addFilter(char * & filterString, int32_t scanningExclude, int32_t opti
}

TR_FilterBST *
TR_Debug::addFilter(char * & filterString, int32_t scanningExclude, int32_t optionSetIndex, int32_t lineNum, bool loadLimit)
TR_Debug::addFilter(const char *& filterString, int32_t scanningExclude, int32_t optionSetIndex, int32_t lineNum, bool loadLimit)
{
if (loadLimit)
{
Expand Down Expand Up @@ -254,7 +254,7 @@ TR_Debug::scanInlineFilters(FILE * inlineFile, int32_t & lineNumber, TR::Compila
}
else if (includeFlag == '+' || includeFlag == '-')
{
char *p = limitReadBuffer+1;
const char *p = limitReadBuffer + 1;
int32_t optionSet;
if (*p >= '0' && *p <= '9')
optionSet = *(p++) - '0';
Expand Down Expand Up @@ -409,7 +409,7 @@ TR_Debug::inlinefileOption(const char *option, void *base, TR::OptionTable *entr
const char *
TR_Debug::limitfileOption(const char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, bool loadLimit, TR_PseudoRandomNumbersListElement **pseudoRandomListHeadPtr)
{
char *endOpt = (char *)option;
const char *endOpt = option;
const char *name = option;
const char *fail = option;

Expand Down Expand Up @@ -470,7 +470,7 @@ TR_Debug::limitfileOption(const char *option, void *base, TR::OptionTable *entry
char includeFlag = limitReadBuffer[0];
if (strncmp(limitReadBuffer,"-precompileMethod",17) == 0)
{
char *p = limitReadBuffer+18;
const char *p = limitReadBuffer + 18;
if (!addFilter(p, 0, 0, lineNumber, loadLimit))
{
limitFileError = true;
Expand All @@ -479,7 +479,7 @@ TR_Debug::limitfileOption(const char *option, void *base, TR::OptionTable *entry
}
else if (strncmp(limitReadBuffer,"-noprecompileMethod",19) == 0)
{
char *p = limitReadBuffer+20;
const char *p = limitReadBuffer + 20;
if (!addFilter(p, 1, 0, lineNumber, loadLimit))
{
limitFileError = true;
Expand All @@ -488,7 +488,7 @@ TR_Debug::limitfileOption(const char *option, void *base, TR::OptionTable *entry
}
else if (includeFlag == '+' || includeFlag == '-')
{
char *p = limitReadBuffer+1;
const char *p = limitReadBuffer + 1;
int32_t optionSet;
if (*p >= '0' && *p <= '9')
optionSet = *(p++) - '0';
Expand Down Expand Up @@ -614,7 +614,7 @@ TR_Debug::limitfileOption(const char *option, void *base, TR::OptionTable *entry
const char *
TR_Debug::limitOption(const char *option, void *base, TR::OptionTable *entry, TR::Options * cmdLineOptions, TR::CompilationFilters *&filters)
{
char *p = (char *)option;
const char *p = option;

filters = findOrCreateFilters(filters);
TR_FilterBST *filter = addFilter(p, static_cast<int32_t>(entry->parm1), 0, 0, filters);
Expand Down Expand Up @@ -651,7 +651,7 @@ TR_Debug::limitOption(const char *option, void *base, TR::OptionTable *entry, TR
// If an option subset was found, save the information for later
// processing
//
char *startOptString = ++p;
const char *startOptString = ++p;
int32_t parenNest = 1;
for (; *p; p++)
{
Expand Down Expand Up @@ -931,7 +931,7 @@ TR_Debug::printFilterTree(TR_FilterBST *root)
}

int32_t
TR_Debug::scanFilterName(char *string, TR_FilterBST *filter)
TR_Debug::scanFilterName(const char *string, TR_FilterBST *filter)
{
// help for OMR parsing
bool seenFileName = false;
Expand All @@ -941,11 +941,11 @@ TR_Debug::scanFilterName(char *string, TR_FilterBST *filter)
// Walk the filter to determine the type.
//
//TR_VerboseLog::writeLine("filterName: %s", string);
char *nameChars = NULL;
const char *nameChars = NULL;
int32_t nameLen = 0;
char *classChars = NULL;
const char *classChars = NULL;
int32_t classLen = 0;
char *signatureChars = string;
const char *signatureChars = string;
int32_t signatureLen = 0;
char filterType = filter->getFilterType();
if (*string == '/' || *string == '.') // hack that works for linux
Expand Down Expand Up @@ -1027,7 +1027,7 @@ TR_Debug::scanFilterName(char *string, TR_FilterBST *filter)
if (omrPattern)
{
// need to swap name and signature, since name is currently the line number
char *tempChars = nameChars;
const char *tempChars = nameChars;
int32_t tempLen = nameLen;
nameChars = signatureChars;
nameLen = signatureLen;
Expand Down

0 comments on commit f148db8

Please sign in to comment.