clang-tidy: readability-non-const-parameter (1/2)
authorRoland Schulz <roland.schulz@intel.com>
Sun, 20 May 2018 20:25:02 +0000 (13:25 -0700)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 29 Jun 2018 16:00:09 +0000 (18:00 +0200)
Manual part of readability-non-const-parameter.
Auto fix-it works outside of:
 - function pointers
 - passing pointer to constructor for storage
 - non-const usage inside #if

Those are fixed/ignored here. Auto patch is next.

Change-Id: I996367d9710a764db53f84e6601935afb7415544

src/gromacs/gmxana/gmx_msd.cpp
src/gromacs/mdlib/ns.cpp
src/gromacs/selection/nbsearch.cpp
src/gromacs/utility/init.cpp

index 1d8f683e6844cf8d23697b9e5ae16770661bd81e..6818ac285589168ab1f1c93aaeb13c95d9507512 100644 (file)
@@ -96,8 +96,8 @@ typedef struct {
                                  point. */
 } t_corr;
 
-typedef real t_calc_func (t_corr *curr, int nx, int index[], int nx0, rvec xc[],
-                          rvec dcom, gmx_bool bTen, matrix mat);
+typedef real t_calc_func (t_corr *curr, int nx, const int index[], int nx0, rvec xc[],
+                          const rvec dcom, gmx_bool bTen, matrix mat);
 
 static real thistime(t_corr *curr)
 {
@@ -265,8 +265,8 @@ static void calc_corr(t_corr *curr, int nr, int nx, int index[], rvec xc[],
 }
 
 /* the non-mass-weighted mean-squared displacement calcuation */
-static real calc1_norm(t_corr *curr, int nx, int index[], int nx0, rvec xc[],
-                       rvec dcom, gmx_bool bTen, matrix mat)
+static real calc1_norm(t_corr *curr, int nx, const int index[], int nx0, rvec xc[],
+                       const rvec dcom, gmx_bool bTen, matrix mat)
 {
     int  i, ix, m, m2;
     real g, r, r2;
@@ -324,7 +324,7 @@ static real calc1_norm(t_corr *curr, int nx, int index[], int nx0, rvec xc[],
 }
 
 /* calculate the com of molecules in x and put it into xa */
-static void calc_mol_com(int nmol, int *molindex, const t_block *mols, const t_atoms *atoms,
+static void calc_mol_com(int nmol, const int *molindex, const t_block *mols, const t_atoms *atoms,
                          rvec *x, rvec *xa)
 {
     int  m, mol, i, d;
@@ -350,7 +350,7 @@ static void calc_mol_com(int nmol, int *molindex, const t_block *mols, const t_a
 }
 
 static real calc_one_mw(t_corr *curr, int ix, int nx0, rvec xc[], real *tm,
-                        rvec dcom, gmx_bool bTen, matrix mat)
+                        const rvec dcom, gmx_bool bTen, matrix mat)
 {
     real r2, r, mm;
     rvec rv;
@@ -403,8 +403,8 @@ static real calc_one_mw(t_corr *curr, int ix, int nx0, rvec xc[], real *tm,
 }
 
 /* the normal, mass-weighted mean-squared displacement calcuation */
-static real calc1_mw(t_corr *curr, int nx, int index[], int nx0, rvec xc[],
-                     rvec dcom, gmx_bool bTen, matrix mat)
+static real calc1_mw(t_corr *curr, int nx, const int index[], int nx0, rvec xc[],
+                     const rvec dcom, gmx_bool bTen, matrix mat)
 {
     int  i;
     real g, tm;
@@ -431,7 +431,7 @@ static real calc1_mw(t_corr *curr, int nx, int index[], int nx0, rvec xc[],
    xcur = the current coordinates
    xprev = the previous coordinates
    box = the box matrix */
-static void prep_data(gmx_bool bMol, int gnx, int index[],
+static void prep_data(gmx_bool bMol, int gnx, const int index[],
                       rvec xcur[], rvec xprev[], matrix box)
 {
     int  i, m, ind;
@@ -519,8 +519,8 @@ static void calc_com(gmx_bool bMol, int gnx, int index[],
 }
 
 
-static real calc1_mol(t_corr *curr, int nx, int gmx_unused index[], int nx0, rvec xc[],
-                      rvec dcom, gmx_bool bTen, matrix mat)
+static real calc1_mol(t_corr *curr, int nx, const int gmx_unused index[], int nx0, rvec xc[],
+                      const rvec dcom, gmx_bool bTen, matrix mat)
 {
     int  i;
     real g, tm, gtot, tt;
@@ -545,7 +545,7 @@ static real calc1_mol(t_corr *curr, int nx, int gmx_unused index[], int nx0, rve
 }
 
 static void printmol(t_corr *curr, const char *fn,
-                     const char *fn_pdb, int *molindex, const t_topology *top,
+                     const char *fn_pdb, const int *molindex, const t_topology *top,
                      rvec *x, int ePBC, matrix box, const gmx_output_env_t *oenv)
 {
 #define NDIST 100
index fd9c8b99b9df117c8bd97c8d6ddd68d49367610e..c24e28ac026005126def7de5b7ea0f58dad5ef25 100644 (file)
@@ -480,7 +480,7 @@ static inline void add_j_to_nblist(t_nblist *nlist, int j_atom)
 
 static inline void add_j_to_nblist_cg(t_nblist *nlist,
                                       int j_start, int j_end,
-                                      t_excl *bexcl, gmx_bool i_is_j)
+                                      const t_excl *bexcl, gmx_bool i_is_j)
 {
     int nrj = nlist->nrj;
     int j;
@@ -525,15 +525,15 @@ static inline void add_j_to_nblist_cg(t_nblist *nlist,
 }
 
 typedef void
-    put_in_list_t (gmx_bool              bHaveVdW[],
+    put_in_list_t (const gmx_bool        bHaveVdW[],
                    int                   ngid,
                    const t_mdatoms      *md,
                    int                   icg,
                    int                   jgid,
                    int                   nj,
-                   int                   jjcg[],
-                   int                   index[],
-                   t_excl                bExcl[],
+                   const int             jjcg[],
+                   const int             index[],
+                   const t_excl          bExcl[],
                    int                   shift,
                    t_forcerec     *      fr,
                    gmx_bool              bDoVdW,
@@ -541,20 +541,20 @@ typedef void
                    int                   solvent_opt);
 
 static void
-put_in_list_at(gmx_bool              bHaveVdW[],
-               int                   ngid,
-               const t_mdatoms      *md,
-               int                   icg,
-               int                   jgid,
-               int                   nj,
-               int                   jjcg[],
-               int                   index[],
-               t_excl                bExcl[],
-               int                   shift,
-               t_forcerec     *      fr,
-               gmx_bool              bDoVdW,
-               gmx_bool              bDoCoul,
-               int                   solvent_opt)
+put_in_list_at(const gmx_bool              bHaveVdW[],
+               int                         ngid,
+               const t_mdatoms            *md,
+               int                         icg,
+               int                         jgid,
+               int                         nj,
+               const int                   jjcg[],
+               const int                   index[],
+               const t_excl                bExcl[],
+               int                         shift,
+               t_forcerec           *      fr,
+               gmx_bool                    bDoVdW,
+               gmx_bool                    bDoCoul,
+               int                         solvent_opt)
 {
     /* The a[] index has been removed,
      * to put it back in i_atom should be a[i0] and jj should be a[jj].
@@ -1047,15 +1047,15 @@ put_in_list_at(gmx_bool              bHaveVdW[],
 }
 
 static void
-put_in_list_qmmm(gmx_bool gmx_unused              bHaveVdW[],
+put_in_list_qmmm(const gmx_bool gmx_unused        bHaveVdW[],
                  int                              ngid,
                  const t_mdatoms                  * /* md */,
                  int                              icg,
                  int                              jgid,
                  int                              nj,
-                 int                              jjcg[],
-                 int                              index[],
-                 t_excl                           bExcl[],
+                 const int                        jjcg[],
+                 const int                        index[],
+                 const t_excl                     bExcl[],
                  int                              shift,
                  t_forcerec                *      fr,
                  gmx_bool  gmx_unused             bDoVdW,
@@ -1111,15 +1111,15 @@ put_in_list_qmmm(gmx_bool gmx_unused              bHaveVdW[],
 }
 
 static void
-put_in_list_cg(gmx_bool  gmx_unused             bHaveVdW[],
+put_in_list_cg(const gmx_bool  gmx_unused       bHaveVdW[],
                int                              ngid,
                const t_mdatoms                  * /* md */,
                int                              icg,
                int                              jgid,
                int                              nj,
-               int                              jjcg[],
-               int                              index[],
-               t_excl                           bExcl[],
+               const int                        jjcg[],
+               const int                        index[],
+               const t_excl                     bExcl[],
                int                              shift,
                t_forcerec                *      fr,
                gmx_bool   gmx_unused            bDoVdW,
@@ -1258,8 +1258,8 @@ int calc_naaj(int icg, int cgtot)
  *
  ************************************************/
 
-static real calc_image_tric(rvec xi, rvec xj, matrix box,
-                            rvec b_inv, int *shift)
+static real calc_image_tric(const rvec xi, const rvec xj, matrix box,
+                            const rvec b_inv, int *shift)
 {
     /* This code assumes that the cut-off is smaller than
      * a half times the smallest diagonal element of the box.
@@ -1300,8 +1300,8 @@ static real calc_image_tric(rvec xi, rvec xj, matrix box,
     return r2;
 }
 
-static real calc_image_rect(rvec xi, rvec xj, rvec box_size,
-                            rvec b_inv, int *shift)
+static real calc_image_rect(const rvec xi, const rvec xj, const rvec box_size,
+                            const rvec b_inv, int *shift)
 {
     const real h15 = 1.5;
     real       ddx, ddy, ddz;
@@ -1362,22 +1362,22 @@ static void add_simple(t_ns_buf       * nsbuf,
     nsbuf->nj               += nrj;
 }
 
-static void ns_inner_tric(rvec             x[],
-                          int              icg,
-                          int             *i_egp_flags,
-                          int              njcg,
-                          int              jcg[],
-                          matrix           box,
-                          rvec             b_inv,
-                          real             rcut2,
-                          t_block         *cgs,
-                          t_ns_buf       **ns_buf,
-                          gmx_bool         bHaveVdW[],
-                          int              ngid,
-                          const t_mdatoms *md,
-                          t_excl           bexcl[],
-                          t_forcerec      *fr,
-                          put_in_list_t   *put_in_list)
+static void ns_inner_tric(rvec                   x[],
+                          int                    icg,
+                          const int             *i_egp_flags,
+                          int                    njcg,
+                          const int              jcg[],
+                          matrix                 box,
+                          rvec                   b_inv,
+                          real                   rcut2,
+                          t_block               *cgs,
+                          t_ns_buf             **ns_buf,
+                          gmx_bool               bHaveVdW[],
+                          int                    ngid,
+                          const t_mdatoms       *md,
+                          t_excl                 bexcl[],
+                          t_forcerec            *fr,
+                          put_in_list_t         *put_in_list)
 {
     int       shift;
     int       j, nrj, jgid;
@@ -1403,23 +1403,23 @@ static void ns_inner_tric(rvec             x[],
     }
 }
 
-static void ns_inner_rect(rvec             x[],
-                          int              icg,
-                          int             *i_egp_flags,
-                          int              njcg,
-                          int              jcg[],
-                          gmx_bool         bBox,
-                          rvec             box_size,
-                          rvec             b_inv,
-                          real             rcut2,
-                          t_block         *cgs,
-                          t_ns_buf       **ns_buf,
-                          gmx_bool         bHaveVdW[],
-                          int              ngid,
-                          const t_mdatoms *md,
-                          t_excl           bexcl[],
-                          t_forcerec      *fr,
-                          put_in_list_t   *put_in_list)
+static void ns_inner_rect(rvec                   x[],
+                          int                    icg,
+                          const int             *i_egp_flags,
+                          int                    njcg,
+                          const int              jcg[],
+                          gmx_bool               bBox,
+                          rvec                   box_size,
+                          rvec                   b_inv,
+                          real                   rcut2,
+                          t_block               *cgs,
+                          t_ns_buf             **ns_buf,
+                          gmx_bool               bHaveVdW[],
+                          int                    ngid,
+                          const t_mdatoms       *md,
+                          t_excl                 bexcl[],
+                          t_forcerec            *fr,
+                          put_in_list_t         *put_in_list)
 {
     int       shift;
     int       j, nrj, jgid;
@@ -1706,7 +1706,7 @@ static int nsgrid_core(const t_commrec *cr,
                        gmx_localtop_t  *top,
                        t_grid          *grid,
                        t_excl           bexcl[],
-                       gmx_bool        *bExcludeAlleg,
+                       const gmx_bool  *bExcludeAlleg,
                        const t_mdatoms *md,
                        put_in_list_t   *put_in_list,
                        gmx_bool         bHaveVdW[],
index 4e3defa990014f72a7071ef1c1226abc6979e7cc..275b91788d74deb9ecc149db4b079d891dcccded 100644 (file)
@@ -1229,7 +1229,7 @@ class MindistAction
          * stores the pointers for later use.
          * See the class description for additional semantics.
          */
-        MindistAction(int *closestPoint, real *minDist2, rvec *dx)
+        MindistAction(int *closestPoint, real *minDist2, rvec *dx) // NOLINT(readability-non-const-parameter)
             : closestPoint_(*closestPoint), minDist2_(*minDist2), dx_(*dx)
         {
         }
index 795e37110d0e982958027e03dce33b71870a2f27..75eb9aed381e200ebb898948bd02e26e3f1f862d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2018, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -63,7 +63,7 @@ int g_initializationCounter = 0;
 #endif
 }
 
-void init(int *argc, char ***argv)
+void init(int *argc, char ***argv) // NOLINT(readability-non-const-parameter)
 {
 #if GMX_LIB_MPI
     int isInitialized = 0, isFinalized = 0;