Commit 454710d6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Set constant parameter and member functions to const.

parent 4703f5f5
......@@ -132,12 +132,9 @@ Process::defPrompt()
}
const char *
Process::inqPrompt()
Process::inqPrompt() const
{
const char *newPrompt = "cdo";
if (prompt[0]) newPrompt = prompt;
return newPrompt;
return prompt[0] ? prompt : "cdo";
}
void
......@@ -163,9 +160,9 @@ Process::handleProcessErr(ProcessStatus p_proErr)
case ProcessStatus::TooManyStreams:
case ProcessStatus::TooFewStreams:
{
int inCnt = m_module.streamInCnt;
const int inCnt = m_module.streamInCnt;
int outCnt = m_module.streamOutCnt;
bool lobase = outCnt == -1;
const bool lobase = outCnt == -1;
if (lobase) outCnt = 1;
CdoError::Abort(Cdo::progname, "Too ", (p_proErr == ProcessStatus::TooManyStreams) ? "many" : "few",
" streams specified! Operator ", m_operatorCommand, " needs ", inCnt, " input stream",
......@@ -310,7 +307,7 @@ Process::inqUserInputForOpArg(const char *enter)
int
Process::operatorAdd(const char *name, int f1, int f2, const char *enter)
{
int operID = m_noper;
const int operID = m_noper;
if (operID >= MAX_OPERATOR) cdoAbort("Maximum number of %d operators reached!", MAX_OPERATOR);
......@@ -439,7 +436,7 @@ Process::run()
}
pthread_t thrID;
int rval = pthread_create(&thrID, &attr, m_module.func, this);
const int rval = pthread_create(&thrID, &attr, m_module.func, this);
if (rval != 0)
{
errno = rval;
......@@ -527,7 +524,7 @@ Process::printProcessedValues()
fprintf(stderr, "%s: ", prompt);
reset_text_color(stderr);
int64_t nvals = m_nvals;
const int64_t nvals = m_nvals;
if (nvals > 0)
{
......
......@@ -144,7 +144,7 @@ public:
*/
int getOperatorID();
void setInactive();
const char *inqPrompt();
const char *inqPrompt() const;
void printProcessedValues();
void printBenchmarks(double p_walltime, const char *p_memstring);
ProcessStatus checkStreamCnt();
......
......@@ -49,6 +49,7 @@ cdoFiletype(void)
return CdoDefault::FileType;
}
void
cdoRun(int processed_argc, const char **processed_argv)
{
......@@ -61,7 +62,7 @@ Process &
processSelf(void)
{
// Cdo_Debug(CdoDebug::PROCESS,"Calling self for thread: ", pthread_self());
pthread_t thID = pthread_self();
const pthread_t thID = pthread_self();
return g_processManager.getProcessByThreadID(thID);
}
......@@ -84,7 +85,7 @@ cdoStreamInqTimestep(int pstreamID, int tsID)
Cdo_Debug(CdoDebug::PROCESS, "Inquiring Timestep ", tsID, " for stream ", pstreamID);
Process &process = processSelf();
Pstream *pstreamptr = pstreamToPointer(pstreamID);
int nrecs = pstreamInqTimestep(pstreamptr, tsID);
const int nrecs = pstreamInqTimestep(pstreamptr, tsID);
Cdo_Debug(CdoDebug::PROCESS, "tsID: ", tsID, " ", pstreamptr->tsID);
if (nrecs && tsID == pstreamptr->tsID)
{
......@@ -119,7 +120,7 @@ operatorArgv(void)
void
operatorCheckArgc(int numargs)
{
int argc = processSelf().m_oargc;
const int argc = processSelf().m_oargc;
if (argc < numargs)
cdoAbort("Too few arguments! Need %d found %d.", numargs, argc);
......@@ -198,6 +199,7 @@ cdoStreamOpenRead(int inStreamIDX)
{
ERROR("instream ", inStreamIDX, " of process ", process.m_ID, " not found");
}
Pstream *inStream = process.inputStreams[inStreamIDX];
if (inStream->isPipe())
......@@ -226,7 +228,7 @@ cdoStreamOpenWrite(int p_outStreamIDX, int filetype)
Cdo_Debug(CdoDebug::PROCESS, "Getting out stream ", p_outStreamIDX, " of process ", processSelf().m_ID);
Process &process = processSelf();
int outStreamIDX = p_outStreamIDX - process.inputStreams.size();
const int outStreamIDX = p_outStreamIDX - process.inputStreams.size();
if (outStreamIDX > process.getOutStreamCnt() || outStreamIDX < 0)
{
ERROR("outstream ", outStreamIDX, " of ", process.m_ID, " not found.", " Was called with streamIDX = ", p_outStreamIDX);
......@@ -245,7 +247,7 @@ cdoStreamOpenWrite(int p_outStreamIDX, int filetype)
if (Options::cdoInteractive)
{
struct stat stbuf;
int rstatus = stat(outStream->m_name.c_str(), &stbuf);
const int rstatus = stat(outStream->m_name.c_str(), &stbuf);
/* If permanent file already exists, query user whether to overwrite or exit */
if (rstatus != -1) process.query_user_exit(outStream->m_name.c_str());
}
......@@ -264,7 +266,7 @@ cdoStreamOpenWrite(std::string p_filename, int filetype)
Process &process = processSelf();
process.addFileOutStream(p_filename);
int pstreamID = process.outputStreams.back()->pstreamOpenWriteFile(filetype);
const int pstreamID = process.outputStreams.back()->pstreamOpenWriteFile(filetype);
if (pstreamID == -1) ERROR("Could not create pstream for file: ", p_filename);
return pstreamID;
......@@ -288,7 +290,7 @@ int
cdoStreamOpenAppend(int p_outFileIndex)
{
Process &process = processSelf();
int streamIndex = p_outFileIndex - process.inputStreams.size();
const int streamIndex = p_outFileIndex - process.inputStreams.size();
Pstream *outStream = process.outputStreams[streamIndex];
int pstreamID = -1;
if (outStream->ispipe)
......@@ -331,10 +333,7 @@ cdoGetInStreamName(int p_inStream)
{
for (Process *processPtr : process.childProcesses)
{
if (processPtr->hasOutStream(process.inputStreams[p_inStream]))
{
return processPtr->operatorName;
}
if (processPtr->hasOutStream(process.inputStreams[p_inStream])) return processPtr->operatorName;
}
CdoError::Abort(Cdo::progname, "error");
}
......@@ -406,7 +405,7 @@ processInqPrompt(void)
{
if (g_processManager.processNums() > 0)
{
Process &process = processSelf();
const Process &process = processSelf();
return process.inqPrompt();
}
......@@ -460,12 +459,13 @@ cdoFinish(void)
int
cdoStreamInqVlist(int pstreamID)
{
int vlistID = pstreamInqVlist(pstreamID);
const int vlistID = pstreamInqVlist(pstreamID);
if (vlistNumber(vlistID) == CDI_COMP && cdoStreamNumber() == CDI_REAL)
cdoAbort("Fields with complex numbers are not supported by this operator!");
if (vlistNumber(vlistID) == CDI_REAL && cdoStreamNumber() == CDI_COMP)
cdoAbort("This operator needs fields with complex numbers!");
processDefVarNum(vlistNvars(vlistID));
return vlistID;
}
......@@ -481,6 +481,7 @@ processNums()
{
return g_processManager.processNums();
}
void
cdoKillProcesses()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment