Unverified Commit 2777d37a authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

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

parent 47888b58
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@
#include "variable.h"
#include "memory.h"
#include "error.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace FixConst;
@@ -223,11 +225,9 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
      if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
      if (me == 0) {
        fp = fopen(arg[iarg+1],"w");
        if (fp == NULL) {
          char str[128];
          snprintf(str,128,"Cannot open fix ave/chunk file %s",arg[iarg+1]);
          error->one(FLERR,str);
        }
        if (fp == NULL)
          error->one(FLERR,fmt::format("Cannot open fix ave/chunk file {}: {}",
                                       arg[iarg+1], utils::getsyserror()));
      }
      iarg += 2;
    } else if (strcmp(arg[iarg],"overwrite") == 0) {
+5 −5
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@
#include "memory.h"
#include "error.h"
#include "force.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace FixConst;
@@ -148,11 +150,9 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
      if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
      if (me == 0) {
        fp = fopen(arg[iarg+1],"w");
        if (fp == NULL) {
          char str[128];
          snprintf(str,128,"Cannot open fix ave/correlate file %s",arg[iarg+1]);
          error->one(FLERR,str);
        }
        if (fp == NULL)
          error->one(FLERR,fmt::format("Cannot open fix ave/correlate file {}:"" {}",
                                       arg[iarg+1], utils::getsyserror()));
      }
      iarg += 2;
    } else if (strcmp(arg[iarg],"overwrite") == 0) {
+5 −5
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@
#include "memory.h"
#include "error.h"
#include "force.h"
#include "utils.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace FixConst;
@@ -963,11 +965,9 @@ void FixAveHisto::options(int iarg, int narg, char **arg)
      if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo command");
      if (me == 0) {
        fp = fopen(arg[iarg+1],"w");
        if (fp == NULL) {
          char str[128];
          snprintf(str,128,"Cannot open fix ave/histo file %s",arg[iarg+1]);
          error->one(FLERR,str);
        }
        if (fp == NULL)
          error->one(FLERR,fmt::format("Cannot open fix ave/histo file {}: {}",
                                       arg[iarg+1], utils::getsyserror()));
      }
      iarg += 2;
    } else if (strcmp(arg[iarg],"kind") == 0) {
+5 −5
Original line number Diff line number Diff line
@@ -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) {
+4 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "modify.h"
#include "respa.h"
#include "error.h"
#include "fmt/format.h"

using namespace LAMMPS_NS;
using namespace FixConst;
@@ -76,11 +77,9 @@ void FixEnforce2D::init()
      if (modify->fix[i]->enforce2d_flag) {
        if (myindex < 0)
          flist[nfixlist++] = modify->fix[i];
        else {
          char msg[256];
          snprintf(msg,256,"Fix enforce2d must be defined after fix %s",modify->fix[i]->style);
          error->all(FLERR,msg);
        }
        else
          error->all(FLERR,fmt::format("Fix enforce2d must be defined after fix {}",
                                       modify->fix[i]->style));
      }
      if (modify->fix[i] == this) myindex = i;
    }
Loading