avoid converting a null pointer to a std::string and correct error check

This commit is contained in:
Axel Kohlmeyer
2022-03-28 15:07:23 -04:00
parent 9920b22509
commit 120c080fc2

View File

@ -307,15 +307,14 @@ void PairKIM::settings(int narg, char **arg)
++settings_call_count; ++settings_call_count;
init_style_call_count = 0; init_style_call_count = 0;
if (narg != 1) { // arg[0] is the KIM Model name
const std::string arg_str(arg[0]); if (narg == 0) error->all(FLERR,"Illegal pair_style command");
if ((narg > 0) && if (narg > 1) {
((arg_str == "KIMvirial") || (arg_str == "LAMMPSvirial"))) { const std::string arg_str(arg[1]);
error->all(FLERR,"'KIMvirial' or 'LAMMPSvirial' not supported " if ((arg_str == "KIMvirial") || (arg_str == "LAMMPSvirial")) {
"with kim-api"); error->all(FLERR,"'KIMvirial' or 'LAMMPSvirial' not supported with kim-api");
} else error->all(FLERR,"Illegal pair_style command"); } else error->all(FLERR,"Illegal pair_style command");
} }
// arg[0] is the KIM Model name
lmps_using_molecular = (atom->molecular > 0); lmps_using_molecular = (atom->molecular > 0);