Commit 3e9f4f34 authored by Uwe Schulzweida's avatar Uwe Schulzweida

Fix scan-build warnings.

parent fa2affaf
Pipeline #5779 passed with stages
in 14 minutes and 57 seconds
...@@ -168,7 +168,7 @@ AS_IF([test x$acx_cv_cfortran_works = 'xno'],[AC_SUBST([FORTRAN_WORKS],[no])],[A ...@@ -168,7 +168,7 @@ AS_IF([test x$acx_cv_cfortran_works = 'xno'],[AC_SUBST([FORTRAN_WORKS],[no])],[A
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
CFLAGS="$CFLAGS ${OPENMP_CFLAGS}" CFLAGS="$CFLAGS ${OPENMP_CFLAGS}"
CXXFLAGS="$CXXFLAGS ${OPENMP_CFLAGS}" CXXFLAGS="$CXXFLAGS ${OPENMP_CFLAGS}"
---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Add configure options # Add configure options
ACX_CDO_OPTIONS ACX_CDO_OPTIONS
ACX_CDI_OPTIONS ACX_CDI_OPTIONS
......
...@@ -60,7 +60,6 @@ magvector(const char *plotfile, int operatorID, const char *varname, long nlon, ...@@ -60,7 +60,6 @@ magvector(const char *plotfile, int operatorID, const char *varname, long nlon,
const char *sep_char = "="; const char *sep_char = "=";
char **split_str = nullptr; char **split_str = nullptr;
char *temp_str = nullptr; char *temp_str = nullptr;
char *titlename;
(void) varname; (void) varname;
...@@ -139,7 +138,7 @@ magvector(const char *plotfile, int operatorID, const char *varname, long nlon, ...@@ -139,7 +138,7 @@ magvector(const char *plotfile, int operatorID, const char *varname, long nlon,
/* results_template_parser(results_node, varname ); */ /* results_template_parser(results_node, varname ); */
sprintf(plotfilename, "Velocity Vectors %s", datetime); sprintf(plotfilename, "Velocity Vectors %s", datetime);
titlename = strdup(plotfilename); char *titlename = strdup(plotfilename);
sprintf(plotfilename, "%s", plotfile); sprintf(plotfilename, "%s", plotfile);
mag_setc("output_name", plotfilename); mag_setc("output_name", plotfilename);
...@@ -185,6 +184,8 @@ magvector(const char *plotfile, int operatorID, const char *varname, long nlon, ...@@ -185,6 +184,8 @@ magvector(const char *plotfile, int operatorID, const char *varname, long nlon,
mag_setc("text_justification", "centre"); mag_setc("text_justification", "centre");
mag_text(); mag_text();
} }
free(titlename);
} }
static void static void
......
...@@ -370,8 +370,6 @@ Selmulti(void *process) ...@@ -370,8 +370,6 @@ Selmulti(void *process)
const auto taxisID2 = taxisDuplicate(taxisID1); const auto taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2); vlistDefTaxis(vlistID2, taxisID2);
auto nrecs = vlistNrecs(vlistID2);
const auto streamID2 = cdoOpenWrite(1); const auto streamID2 = cdoOpenWrite(1);
cdoDefVlist(streamID2, vlistID2); cdoDefVlist(streamID2, vlistID2);
...@@ -380,8 +378,11 @@ Selmulti(void *process) ...@@ -380,8 +378,11 @@ Selmulti(void *process)
Varray<double> array(gridsize); Varray<double> array(gridsize);
int tsID = 0; int tsID = 0;
while ((nrecs = cdoStreamInqTimestep(streamID1, tsID))) while (true)
{ {
const auto nrecs = cdoStreamInqTimestep(streamID1, tsID);
if (nrecs == 0) break;
taxisCopyTimestep(taxisID2, taxisID1); taxisCopyTimestep(taxisID2, taxisID1);
cdoDefTimestep(streamID2, tsID); cdoDefTimestep(streamID2, tsID);
...@@ -499,7 +500,7 @@ Selmulti(void *process) ...@@ -499,7 +500,7 @@ Selmulti(void *process)
} // end for ( recID .. } // end for ( recID ..
tsID++; tsID++;
} // end while ( (nrecs } // end while
cdoStreamClose(streamID1); cdoStreamClose(streamID1);
cdoStreamClose(streamID2); cdoStreamClose(streamID2);
......
...@@ -53,21 +53,23 @@ Ydrunpctl(void *process) ...@@ -53,21 +53,23 @@ Ydrunpctl(void *process)
const auto ndates = parameter2int(cdoOperatorArgv(1)); const auto ndates = parameter2int(cdoOperatorArgv(1));
char *percMethod = nullptr, *readMethod = nullptr; char *percMethod = nullptr, *readMethod = nullptr;
if ( operatorArgc() > 2 ) if (operatorArgc() > 2)
{ {
auto params = cdoGetOperArgv(); auto params = cdoGetOperArgv();
params = std::vector<std::string>(params.begin() + 2, params.end()); params = std::vector<std::string>(params.begin() + 2, params.end());
KVList kvlist; KVList kvlist;
if (kvlist.parseArguments(operatorArgc()-2, params) != 0) cdoAbort("Argument parse error!"); if (kvlist.parseArguments(operatorArgc()-2, params) != 0) cdoAbort("Argument parse error!");
auto kv = kvlist.search("pm"); auto kv = kvlist.search("pm");
if (kv && kv->nvalues > 0 ) if (kv && kv->nvalues > 0) percMethod = strdup(kv->values[0].c_str());
percMethod = strdup(kv->values[0].c_str());
kv = kvlist.search("rm"); kv = kvlist.search("rm");
if (kv && kv->nvalues > 0 ) if (kv && kv->nvalues > 0) readMethod = strdup(kv->values[0].c_str());
readMethod = strdup(kv->values[0].c_str());
} }
if ( percMethod && strcmp(percMethod,"r8") == 0 ) percentile_set_method("rtype8"); if (percMethod)
{
if (strcmp(percMethod,"r8") == 0) percentile_set_method("rtype8");
free(percMethod);
}
const auto streamID1 = cdoOpenRead(0); const auto streamID1 = cdoOpenRead(0);
const auto streamID2 = cdoOpenRead(1); const auto streamID2 = cdoOpenRead(1);
...@@ -306,6 +308,8 @@ Ydrunpctl(void *process) ...@@ -306,6 +308,8 @@ Ydrunpctl(void *process)
else if (readMethod && readMethod[0] == 'c' ) else if (readMethod && readMethod[0] == 'c' )
cdoWarning("Operators cannot be piped in circular mode"); cdoWarning("Operators cannot be piped in circular mode");
if (readMethod) free(readMethod);
/* /*
int outyear = 1e9; int outyear = 1e9;
for ( dayoy = 0; dayoy < MaxDays; dayoy++ ) for ( dayoy = 0; dayoy < MaxDays; dayoy++ )
......
...@@ -37,7 +37,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, std::ve ...@@ -37,7 +37,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, std::ve
int int
cstrSplitWithSeperator(const char *source_string, const char *seperator, char ***ptr_split_string) cstrSplitWithSeperator(const char *source_string, const char *seperator, char ***ptr_split_string)
{ {
char *duplicate_src = nullptr, **temp_list = nullptr, *temp_str = nullptr, *saveptr; char **temp_list = nullptr, *temp_str = nullptr, *saveptr;
int n = 0, i; int n = 0, i;
int str_len = 0, sep_count = 0; int str_len = 0, sep_count = 0;
...@@ -47,7 +47,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char ** ...@@ -47,7 +47,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char **
if (DBG) fprintf(stderr, "cstrSplitWithSeperator Input str %s , seperator %s \n", source_string, seperator); if (DBG) fprintf(stderr, "cstrSplitWithSeperator Input str %s , seperator %s \n", source_string, seperator);
duplicate_src = strdup(source_string); char *duplicate_src = strdup(source_string);
for (i = 0; i < str_len; i++) for (i = 0; i < str_len; i++)
{ {
...@@ -58,11 +58,12 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char ** ...@@ -58,11 +58,12 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char **
if (DBG) fprintf(stderr, "Input str %s , seperator %s sep count %d\n", duplicate_src, seperator, sep_count); if (DBG) fprintf(stderr, "Input str %s , seperator %s sep count %d\n", duplicate_src, seperator, sep_count);
while ((temp_str = strtok_r(duplicate_src, seperator, &saveptr))) char *tmpstr = duplicate_src;
while ((temp_str = strtok_r(tmpstr, seperator, &saveptr)))
{ {
temp_list[n] = temp_str; temp_list[n] = temp_str;
n++; n++;
duplicate_src = saveptr; tmpstr = saveptr;
} }
if (DBG) if (DBG)
...@@ -72,6 +73,8 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char ** ...@@ -72,6 +73,8 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char **
*ptr_split_string = temp_list; *ptr_split_string = temp_list;
free(duplicate_src);
return n; return n;
} }
......
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