address issues flagged by coverity scan

This commit is contained in:
Axel Kohlmeyer
2023-06-17 00:35:05 -04:00
parent a20ed8e5e4
commit ce75691eae
3 changed files with 9 additions and 18 deletions

View File

@ -476,16 +476,14 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword)
utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
nwords = utils::count_words(utils::trim_comment(line));
if (nwords != nspecies+2) {
printf("nwords=%d nspecies=%d\n",nwords,nspecies);
error->all(FLERR,"Illegal fix eos/table/rx command");
}
nwords = 0;
if (nwords != nspecies+2)
error->all(FLERR,"Illegal fix eos/table/rx command: nwords={} nspecies={}", nwords, nspecies);
word = strtok(line," \t\n\r\f");
word = strtok(nullptr," \t\n\r\f");
rtmp = atof(word);
for (int icolumn=0;icolumn<ncolumn;icolumn++) {
for (int icolumn=0; icolumn < ncolumn; icolumn++) {
ispecies = eosSpecies[icolumn];
Table *tbl = &tables[ispecies];

View File

@ -249,7 +249,7 @@ void FixRX::post_constructor()
// Assign species names to tmpspecies array and determine the number of unique species
int n,nwords;
int n;
char line[MAXLINE],*ptr;
int eof = 0;
char * word;
@ -270,12 +270,10 @@ void FixRX::post_constructor()
// strip comment, skip line if blank
if ((ptr = strchr(line,'#'))) *ptr = '\0';
nwords = utils::count_words(line);
if (nwords == 0) continue;
if (utils::count_words(line) == 0) continue;
// words = ptrs to all words in line
nwords = 0;
word = strtok(line," \t\n\r\f");
while (word != nullptr) {
word = strtok(nullptr, " \t\n\r\f");
@ -785,7 +783,7 @@ void FixRX::read_file(char *file)
// Count the number of reactions from kinetics file
int n,nwords,ispecies;
int n,ispecies;
char line[MAXLINE],*ptr;
int eof = 0;
@ -805,8 +803,7 @@ void FixRX::read_file(char *file)
// strip comment, skip line if blank
if ((ptr = strchr(line,'#'))) *ptr = '\0';
nwords = utils::count_words(line);
if (nwords == 0) continue;
if (utils::count_words(line) == 0) continue;
nreactions++;
}
@ -859,12 +856,10 @@ void FixRX::read_file(char *file)
// strip comment, skip line if blank
if ((ptr = strchr(line,'#'))) *ptr = '\0';
nwords = utils::count_words(line);
if (nwords == 0) continue;
if (utils::count_words(line) == 0) continue;
// words = ptrs to all words in line
nwords = 0;
word = strtok(line," \t\n\r\f");
while (word != nullptr) {
tmpStoich = atof(word);

View File

@ -165,7 +165,6 @@ void PairLJSwitch3CoulGaussLong::compute(int eflag, int vflag)
// Correction for Gaussian radii
if (lj2[itype][jtype]==0.0) {
// This means a point charge is considered, so the correction is zero
expn2 = 0.0;
erfc2 = 0.0;
forcecoul2 = 0.0;
prefactor2 = 0.0;
@ -616,7 +615,6 @@ double PairLJSwitch3CoulGaussLong::single(int i, int j, int itype, int jtype,
r6inv = r2inv*r2inv*r2inv;
forcelj = r6inv*(12.0*lj3[itype][jtype]*r6inv-6.0*lj4[itype][jtype]);
if (lj2[itype][jtype] == 0.0) {
expn2 = 0.0;
erfc2 = 0.0;
forcecoul2 = 0.0;
prefactor2 = 0.0;