From b300ef29ee3a3d222bd5cc28566d5c9ce29f168e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 22 Aug 2024 23:39:29 -0400 Subject: [PATCH] simplify; make certain nmax is always initialized --- src/utils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index dc6ee459a7..59984c8443 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1005,8 +1005,6 @@ int utils::expand_type_int(const char *file, int line, const std::string &str, i char *typestr = expand_type(file, line, str, mode, lmp); int type = inumeric(file, line, typestr ? typestr : str, false, lmp); if (verify) { - int errorflag = 0; - if (type <= 0) errorflag = 1; int nmax; switch (mode) { case Atom::ATOM: @@ -1024,10 +1022,12 @@ int utils::expand_type_int(const char *file, int line, const std::string &str, i case Atom::IMPROPER: nmax = lmp->atom->nimpropertypes; break; + default: + nmax = 0; } - if (type > nmax) errorflag = 1; - if (errorflag) lmp->error->all(file, line, "{} type {} is out of bounds ({}-{})", - labeltypes[mode], type, 1, nmax); + if ((type <= 0) || (type > nmax)) + lmp->error->all(file, line, "{} type {} is out of bounds ({}-{})", labeltypes[mode], type, 1, + nmax); } delete[] typestr; return type;