From 987bff27d44b430f17669ad6ae2ade5350d4e32c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 10 May 2020 14:05:32 -0400 Subject: [PATCH] fix issues in AtomVec refactoring detected by compiler warnings --- src/atom.cpp | 11 +++++++---- src/atom_vec.cpp | 11 ++--------- src/atom_vec_ellipsoid.cpp | 1 - 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 7c1b5ae6dc..9a9e5bb48b 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -604,10 +604,13 @@ void Atom::add_peratom(const char *name, void *address, void Atom::add_peratom_change_columns(const char *name, int cols) { int i; - for (int i = 0; i < nperatom; i++) - if (strcmp(name,peratom[i].name) == 0) peratom[i].cols = cols; - if (i == nperatom) - error->all(FLERR,"Could not find name of peratom array for column change"); + for (i = 0; i < nperatom; i++) { + if (strcmp(name,peratom[i].name) == 0) { + peratom[i].cols = cols; + return; + } + } + error->all(FLERR,"Could not find name of peratom array for column change"); } /* ---------------------------------------------------------------------- diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 194cf246ce..e7962ca038 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -192,7 +192,7 @@ int AtomVec::grow_nmax_bonus(int nmax_bonus) void AtomVec::grow(int n) { int datatype,cols,maxcols; - void *pdata,*plength; + void *pdata; if (n == 0) grow_nmax(); else nmax = n; @@ -1775,7 +1775,7 @@ void AtomVec::pack_data(double **buf) int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { + for (i = 0; i < nlocal; i++) { // if needed, change values before packing @@ -1841,33 +1841,26 @@ void AtomVec::write_data(FILE *fp, int n, double **buf) j = 1; for (nn = 1; nn < ndata_atom; nn++) { - pdata = mdata_atom.pdata[nn]; datatype = mdata_atom.datatype[nn]; cols = mdata_atom.cols[nn]; if (datatype == DOUBLE) { if (cols == 0) { - double *vec = *((double **) pdata); fprintf(fp," %-1.16e",buf[i][j++]); } else { - double **array = *((double ***) pdata); for (m = 0; m < cols; m++) fprintf(fp," %-1.16e",buf[i][j++]); } } else if (datatype == INT) { if (cols == 0) { - int *vec = *((int **) pdata); fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); } else { - int **array = *((int ***) pdata); for (m = 0; m < cols; m++) fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); } } else if (datatype == BIGINT) { if (cols == 0) { - bigint *vec = *((bigint **) pdata); fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); } else { - bigint **array = *((bigint ***) pdata); for (m = 0; m < cols; m++) fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); } diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 4d83565c7a..c4c9942aed 100644 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -192,7 +192,6 @@ void AtomVecEllipsoid::unpack_comm_bonus(int n, int first, double *buf) int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf) { int i,j,m; - double dx,dy,dz; double *shape,*quat; m = 0;