remove local buffers and snprintf() for file open error messages.

This commit is contained in:
Axel Kohlmeyer
2020-06-04 13:30:44 -04:00
parent 47888b587a
commit 2777d37a61
8 changed files with 44 additions and 55 deletions

View File

@ -28,6 +28,8 @@
#include "variable.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -1043,11 +1045,9 @@ void FixAveTime::options(int iarg, int narg, char **arg)
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command");
if (me == 0) {
fp = fopen(arg[iarg+1],"w");
if (fp == NULL) {
char str[128];
snprintf(str,128,"Cannot open fix ave/time file %s",arg[iarg+1]);
error->one(FLERR,str);
}
if (fp == NULL)
error->one(FLERR,fmt::format("Cannot open fix ave/time file {}: {}",
arg[iarg+1], utils::getsyserror()));
}
iarg += 2;
} else if (strcmp(arg[iarg],"ave") == 0) {