silence compiler warnings

This commit is contained in:
Axel Kohlmeyer
2024-09-06 14:58:42 -04:00
parent 42a7294bc1
commit 8fcdb5c271
4 changed files with 11 additions and 7 deletions

View File

@ -33,7 +33,8 @@ static std::string find_section(FILE *fp, const std::string &name)
{ {
char linebuf[BUFLEN]; char linebuf[BUFLEN];
fgets(linebuf, BUFLEN, fp); if (!fgets(linebuf, BUFLEN, fp))
throw TokenizerException("Read error", utils::getsyserror());
while (!feof(fp)) { while (!feof(fp)) {
if (utils::strmatch(linebuf, "^\\s*\\[.*\\]\\s*$")) { if (utils::strmatch(linebuf, "^\\s*\\[.*\\]\\s*$")) {
auto words = Tokenizer(linebuf).as_vector(); auto words = Tokenizer(linebuf).as_vector();

View File

@ -148,8 +148,10 @@ void AngleWrite::command(int narg, char **arg)
FILE *coeffs; FILE *coeffs;
char line[MAXLINE] = {'\0'}; char line[MAXLINE] = {'\0'};
coeffs = fopen(coeffs_file.c_str(), "r"); coeffs = fopen(coeffs_file.c_str(), "r");
if (!coeffs)
error->one(FLERR, "Unable to open temporary file {}: {}", coeffs_file, utils::getsyserror());
for (int i = 0; i < atom->nangletypes; ++i) { for (int i = 0; i < atom->nangletypes; ++i) {
fgets(line, MAXLINE, coeffs); utils::sfgets(FLERR, line, MAXLINE, coeffs, coeffs_file.c_str(), error);
writer->input->one(fmt::format("angle_coeff {}", line)); writer->input->one(fmt::format("angle_coeff {}", line));
} }
fclose(coeffs); fclose(coeffs);

View File

@ -149,8 +149,10 @@ void DihedralWrite::command(int narg, char **arg)
FILE *coeffs; FILE *coeffs;
char line[MAXLINE] = {'\0'}; char line[MAXLINE] = {'\0'};
coeffs = fopen(coeffs_file.c_str(), "r"); coeffs = fopen(coeffs_file.c_str(), "r");
if (!coeffs)
error->one(FLERR, "Unable to open temporary file {}: {}", utils::getsyserror());
for (int i = 0; i < atom->ndihedraltypes; ++i) { for (int i = 0; i < atom->ndihedraltypes; ++i) {
fgets(line, MAXLINE, coeffs); utils::sfgets(FLERR, line, MAXLINE, coeffs, coeffs_file.c_str(), error);
writer->input->one(fmt::format("dihedral_coeff {}", line)); writer->input->one(fmt::format("dihedral_coeff {}", line));
} }
fclose(coeffs); fclose(coeffs);

View File

@ -144,7 +144,7 @@ void ReadMdfFile(void)
molecule[n].residue[j].end = i; molecule[n].residue[j].end = i;
molecule[n].residue[++j].start = i; molecule[n].residue[++j].start = i;
strncpy(molecule[n].residue[j].name,atoms[i].residue_string,MAX_NAME); memcpy(molecule[n].residue[j].name,atoms[i].residue_string,MAX_NAME);
} }
} }
molecule[n].residue[j].end = molecule[n].end; molecule[n].residue[j].end = molecule[n].end;
@ -167,10 +167,9 @@ void ReadMdfFile(void)
for (n=0; n < no_molecules; n++) { for (n=0; n < no_molecules; n++) {
for (j=0; j < molecule[n].no_residues; j++) { for (j=0; j < molecule[n].no_residues; j++) {
for (i=molecule[n].residue[j].start; i < molecule[n].residue[j].end; for (i=molecule[n].residue[j].start; i < molecule[n].residue[j].end; i++) {
i++) {
for (l=0; l < atoms[i].no_connect; l++) { for (l=0; l < atoms[i].no_connect; l++) {
strncpy(temp_string,atoms[i].connections[l],MAX_STRING); memcpy(temp_string,atoms[i].connections[l],MAX_STRING);
temp_residue = strtok(temp_string,":"); temp_residue = strtok(temp_string,":");
temp_atom_name = strtok(NULL,"%"); temp_atom_name = strtok(NULL,"%");