2/3 of old-style casting
authorRoland Schulz <roland.schulz@intel.com>
Mon, 2 Jul 2018 18:29:58 +0000 (11:29 -0700)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 8 Aug 2018 15:57:35 +0000 (17:57 +0200)
Manual changes.

Change-Id: I5a9d1ab65498f70539dd1f28bb538781dd1021f8

34 files changed:
src/gromacs/correlationfunctions/manyautocorrelation.cpp
src/gromacs/fft/fft_fftw3.cpp
src/gromacs/fileio/gmxfio-xdr.cpp
src/gromacs/fileio/xvgr.cpp
src/gromacs/fileio/xvgr.h
src/gromacs/gmxana/gmx_analyze.cpp
src/gromacs/gmxana/gmx_bundle.cpp
src/gromacs/gmxana/gmx_density.cpp
src/gromacs/gmxana/gmx_dielectric.cpp
src/gromacs/gmxana/gmx_disre.cpp
src/gromacs/gmxana/gmx_dos.cpp
src/gromacs/gmxana/gmx_editconf.cpp
src/gromacs/gmxana/gmx_mdmat.cpp
src/gromacs/gmxana/gmx_mindist.cpp
src/gromacs/gmxana/gmx_nmr.cpp
src/gromacs/gmxana/gmx_polystat.cpp
src/gromacs/gmxana/gmx_potential.cpp
src/gromacs/gmxana/gmx_principal.cpp
src/gromacs/gmxana/gmx_rms.cpp
src/gromacs/gmxana/gmx_saltbr.cpp
src/gromacs/gmxana/gmx_sham.cpp
src/gromacs/gmxana/gmx_traj.cpp
src/gromacs/gmxana/gmx_trjorder.cpp
src/gromacs/gmxana/gmx_vanhove.cpp
src/gromacs/gmxpreprocess/gen_ad.cpp
src/gromacs/gmxpreprocess/gpp_nextnb.cpp
src/gromacs/mdlib/ebin.cpp
src/gromacs/mdlib/ebin.h
src/gromacs/mdlib/force.cpp
src/gromacs/mdlib/mdebin.cpp
src/gromacs/mdlib/shake.cpp
src/gromacs/mdlib/splitter.cpp
src/gromacs/mdrun/tpi.cpp
src/gromacs/selection/sm_same.cpp

index e1df9220e967daace00571c18e9f290f1f028bc5..423351343ea3e303556fed75477e19804448cd77 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 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.
@@ -104,13 +104,13 @@ int many_auto_correl(std::vector<std::vector<real> > *c)
                     in[2*j+0] = (*c)[i][j];
                     in[2*j+1] = 0;
                 }
-                gmx_fft_1d(fft1, GMX_FFT_BACKWARD, (void *)in.data(), (void *)out.data());
+                gmx_fft_1d(fft1, GMX_FFT_BACKWARD, in.data(), out.data());
                 for (size_t j = 0; j < nfft; j++)
                 {
                     in[2*j+0] = (out[2*j+0]*out[2*j+0] + out[2*j+1]*out[2*j+1])/nfft;
                     in[2*j+1] = 0;
                 }
-                gmx_fft_1d(fft1, GMX_FFT_FORWARD, (void *)in.data(), (void *)out.data());
+                gmx_fft_1d(fft1, GMX_FFT_FORWARD, in.data(), out.data());
                 for (size_t j = 0; (j < nfft); j++)
                 {
                     (*c)[i][j] = out[2*j+0];
index 75a0f80e94a7c9ee3194e6974ceb4cd9203b6b25..4b741a379f06240b08b7aade0c08be9ce9ab05eb 100644 (file)
@@ -110,7 +110,7 @@ gmx_fft_init_many_1d(gmx_fft_t *        pfft,
 {
     gmx_fft_t              fft;
     FFTWPREFIX(complex)   *p1, *p2, *up1, *up2;
-    size_t                 pc;
+    char*                  pc;
     int                    i, j, k;
     int                    fftw_flags;
 
@@ -156,13 +156,13 @@ gmx_fft_init_many_1d(gmx_fft_t *        pfft,
      * In double precision the actual complex datatype will be 16 bytes,
      * so go to a char pointer and force an offset of 8 bytes instead.
      */
-    pc  = (size_t)p1;
+    pc  = reinterpret_cast<char*>(p1);
     pc += 8;
-    up1 = (FFTWPREFIX(complex) *)pc;
+    up1 = reinterpret_cast<FFTWPREFIX(complex) *>(pc);
 
-    pc  = (size_t)p2;
+    pc  = reinterpret_cast<char*>(p2);
     pc += 8;
-    up2 = (FFTWPREFIX(complex) *)pc;
+    up2 = reinterpret_cast<FFTWPREFIX(complex) *>(pc);
 
     /*                            int rank, const int *n, int howmany,
                                   fftw_complex *in, const int *inembed,
@@ -227,7 +227,7 @@ gmx_fft_init_many_1d_real(gmx_fft_t *        pfft,
 {
     gmx_fft_t              fft;
     real                  *p1, *p2, *up1, *up2;
-    size_t                 pc;
+    char*                  pc;
     int                    i, j, k;
     int                    fftw_flags;
 
@@ -273,13 +273,13 @@ gmx_fft_init_many_1d_real(gmx_fft_t *        pfft,
      * In double precision the actual complex datatype will be 16 bytes,
      * so go to a char pointer and force an offset of 8 bytes instead.
      */
-    pc  = (size_t)p1;
+    pc  = reinterpret_cast<char*>(p1);
     pc += 8;
-    up1 = (real *)pc;
+    up1 = reinterpret_cast<real*>(pc);
 
-    pc  = (size_t)p2;
+    pc  = reinterpret_cast<char*>(p2);
     pc += 8;
-    up2 = (real *)pc;
+    up2 = reinterpret_cast<real*>(pc);
 
     /*                                int rank, const int *n, int howmany,
                                       double *in, const int *inembed,
@@ -338,7 +338,7 @@ gmx_fft_init_2d_real(gmx_fft_t *        pfft,
 {
     gmx_fft_t              fft;
     real                  *p1, *p2, *up1, *up2;
-    size_t                 pc;
+    char*                  pc;
     int                    i, j, k;
     int                    fftw_flags;
 
@@ -384,13 +384,13 @@ gmx_fft_init_2d_real(gmx_fft_t *        pfft,
      * In double precision the actual complex datatype will be 16 bytes,
      * so go to a char pointer and force an offset of 8 bytes instead.
      */
-    pc  = (size_t)p1;
+    pc  = reinterpret_cast<char*>(p1);
     pc += 8;
-    up1 = (real *)pc;
+    up1 = reinterpret_cast<real*>(pc);
 
-    pc  = (size_t)p2;
+    pc  = reinterpret_cast<char*>(p2);
     pc += 8;
-    up2 = (real *)pc;
+    up2 = reinterpret_cast<real*>(pc);
 
 
     fft->plan[0][0][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, reinterpret_cast<FFTWPREFIX(complex) *>(up1), up2, fftw_flags);
@@ -442,7 +442,7 @@ gmx_fft_1d               (gmx_fft_t                  fft,
                           void *                     in_data,
                           void *                     out_data)
 {
-    int           aligned   = ((((size_t)in_data | (size_t)out_data) & 0xf) == 0);
+    int           aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
     int           inplace   = (in_data == out_data);
     int           isforward = (dir == GMX_FFT_FORWARD);
 
@@ -476,7 +476,7 @@ gmx_fft_1d_real          (gmx_fft_t                  fft,
                           void *                     in_data,
                           void *                     out_data)
 {
-    int           aligned   = ((((size_t)in_data | (size_t)out_data) & 0xf) == 0);
+    int           aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
     int           inplace   = (in_data == out_data);
     int           isforward = (dir == GMX_FFT_REAL_TO_COMPLEX);
 
@@ -517,7 +517,7 @@ gmx_fft_2d_real          (gmx_fft_t                  fft,
                           void *                     in_data,
                           void *                     out_data)
 {
-    int           aligned   = ((((size_t)in_data | (size_t)out_data) & 0xf) == 0);
+    int           aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
     int           inplace   = (in_data == out_data);
     int           isforward = (dir == GMX_FFT_REAL_TO_COMPLEX);
 
index 11a4add8ffd5171e1daf59d70054dd0bbaa0e223..88d4bd61a7c9c2c7c7231c0a12ec1dfa1b525e5f 100644 (file)
@@ -357,7 +357,7 @@ gmx_bool gmx_fio_writee_string(t_fileio *fio, const char *item,
                                const char *desc, const char *srcfile, int line)
 {
     gmx_bool ret;
-    void    *it = (void*)item; /* ugh.. */
+    void    *it = const_cast<char*>(item); /* ugh.. */
     gmx_fio_lock(fio);
     ret = do_xdr(fio, it, 1, eioSTRING, desc, srcfile, line);
     gmx_fio_unlock(fio);
index 01e8b13c9994da99361768e0069159227bb3fa1b..52e1b7a395d88b2687ea69681047b85c1f0b1618 100644 (file)
@@ -386,10 +386,10 @@ void xvgrLegend(FILE                           *out,
 {
     xvgr_legend(out, setNames.size(), setNames.data(), oenv);
 }
-void xvgr_legend(FILE *out, int nsets, const char** setnames,
+void xvgr_legend(FILE *out, int nsets, const char*const* setnames,
                  const struct gmx_output_env_t *oenv)
 {
-    xvgr_legend<char const *>(out, nsets, setnames, oenv);
+    xvgr_legend<const char *>(out, nsets, setnames, oenv);
 }
 
 void xvgr_new_dataset(FILE *out, int nr_first, int nsets,
index 1c5104d367e9b2243850e587bdc9199fc28aa6cb..e95fc543425725953ba987ac80a06606760c7c0f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015,2017,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.
@@ -137,7 +137,7 @@ void xvgrLegend(FILE                           *out,
                 const struct gmx_output_env_t  *oenv);
 /* Make a legend box, and also modifies the view to make room for the legend */
 
-void xvgr_legend(FILE *out, int nsets, const char** setnames,
+void xvgr_legend(FILE *out, int nsets, const char*const* setnames,
                  const struct gmx_output_env_t *oenv);
 /* Make a legend box, and also modifies the view to make room for the legend */
 
index 3e52009cc64b9c5b60b8e0f6d0e7f2021179c7d6..b4f8ba3640d350cc27440d1b140570de418e9c65 100644 (file)
@@ -299,7 +299,7 @@ static void histogram(const char *distfile, real binwidth, int n, int nset, real
 
 static int real_comp(const void *a, const void *b)
 {
-    real dif = *(real *)a - *(real *)b;
+    real dif = *reinterpret_cast<const real*>(a) - *reinterpret_cast<const real*>(b);
 
     if (dif < 0)
     {
@@ -440,7 +440,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
                 (n-1)*dt, n);
     }
     snew(leg, 2*nset);
-    xvgr_legend(fp, 2*nset, (const char**)leg, oenv);
+    xvgr_legend(fp, 2*nset, leg, oenv);
     sfree(leg);
 
     spacing = std::pow(2.0, 1.0/resol);
index 2e8d26d7ce46777b0ae6eeeac562ee93e143ea23..3ce667d7b6b3a21e65342d7a6539b2bbba3f6ac5 100644 (file)
@@ -236,7 +236,7 @@ int gmx_bundle(int argc, char *argv[])
     real              t, comp;
     char             *grpname[MAX_ENDS];
     /* FIXME: The constness should not be cast away */
-    char             *anm = (char *)"CA", *rnm = (char *)"GLY";
+    char             *anm = const_cast<char*>("CA"), *rnm = const_cast<char*>("GLY");
     int               i, gnx[MAX_ENDS];
     int              *index[MAX_ENDS];
     t_bundle          bun;
index e750d1d694575de7df829fe4863d3fc4b805fd2b..7914cd93c5d5afb5fbd0e7b2ad17dc175aca9d2d 100644 (file)
@@ -123,7 +123,7 @@ static int get_electrons(t_electron **eltab, const char *fn)
 
     /* sort the list */
     fprintf(stderr, "Sorting list..\n");
-    qsort ((void*)*eltab, nr, sizeof(t_electron),
+    qsort (*eltab, nr, sizeof(t_electron),
            reinterpret_cast<int(*)(const void*, const void*)>(compare));
 
     return nr;
@@ -276,8 +276,8 @@ static void calc_electron_density(const char *fn, int **index, const int gnx[],
                 sought.atomname = gmx_strdup(*(top->atoms.atomname[index[n][i]]));
 
                 /* now find the number of electrons. This is not efficient. */
-                found = static_cast<t_electron *>(bsearch((const void *)&sought,
-                                                          (const void *)eltab, nr, sizeof(t_electron),
+                found = static_cast<t_electron *>(bsearch(&sought,
+                                                          eltab, nr, sizeof(t_electron),
                                                           reinterpret_cast<int(*)(const void*, const void*)>(compare)));
 
                 if (found == nullptr)
@@ -538,7 +538,7 @@ static void plot_density(double *slDensity[], const char *afile, int nslices,
     den = xvgropen(afile,
                    title, xlabel, ylabel, oenv);
 
-    xvgr_legend(den, nr_grps, (const char**)grpname, oenv);
+    xvgr_legend(den, nr_grps, grpname, oenv);
 
     for (slice = 0; (slice < nslices); slice++)
     {
index adc6469451875290b728ec8d65062555b8cfa600..df896db69e6d1cc6760b740d1afa4e591556592a 100644 (file)
@@ -187,7 +187,7 @@ static void do_four(const char *fn, const char *cn, int nx, const real x[], cons
         gmx_fatal(FARGS, "gmx_fft_init_1d_real returned %d", fftcode);
     }
     if ((fftcode = gmx_fft_1d_real(fft, GMX_FFT_COMPLEX_TO_REAL,
-                                   (void *)tmp, (void *)tmp)) != 0)
+                                   tmp, tmp)) != 0)
     {
         gmx_fatal(FARGS, "gmx_fft_1d_real returned %d", fftcode);
     }
index fcb986a7b4ea90ae6be06fb8c3598e4336f573eb..3f07b144f03a0b99a355f85c2a82d19f99ab2799 100644 (file)
@@ -106,17 +106,6 @@ static void reset5(void)
     }
 }
 
-static int tpcomp(const void *a, const void *b)
-{
-    t_toppop *tpa;
-    t_toppop *tpb;
-
-    tpa = (t_toppop *)a;
-    tpb = (t_toppop *)b;
-
-    return static_cast<int>(1e7*(tpb->v-tpa->v));
-}
-
 static void add5(int ndr, real viol)
 {
     int i, mini;
@@ -140,7 +129,7 @@ static void print5(FILE *fp)
 {
     int i;
 
-    qsort(top, ntop, sizeof(top[0]), tpcomp);
+    std::sort(top, top+ntop, [](const t_toppop &a, const t_toppop &b) {return a.v > b.v; }); //reverse sort
     fprintf(fp, "Index:");
     for (i = 0; (i < ntop); i++)
     {
@@ -205,7 +194,7 @@ static void check_viol(FILE *log,
                (forceparams[forceatoms[i+n]].disres.label == label));
 
         calc_disres_R_6(nullptr, nullptr, n, &forceatoms[i],
-                        (const rvec*)x, pbc, fcd, nullptr);
+                        x, pbc, fcd, nullptr);
 
         if (fcd->disres.Rt_6[label] <= 0)
         {
index abd09992d7380d86012dcea4757107eb89def341..602e11db34e81d615b5dcd71483995fffde36a84 100644 (file)
@@ -482,7 +482,7 @@ int gmx_dos(int argc, char *argv[])
         gmx_fatal(FARGS, "gmx_fft_init_1d_real returned %d", fftcode);
     }
     if ((fftcode = gmx_fft_1d_real(fft, GMX_FFT_REAL_TO_COMPLEX,
-                                   (void *)dos[MVACF], (void *)dos[DOS])) != 0)
+                                   dos[MVACF], dos[DOS])) != 0)
     {
         gmx_fatal(FARGS, "gmx_fft_1d_real returned %d", fftcode);
     }
index d03f922cb1cf7dcb6ff950389bcacb02360e8bcd..9d012ec3ee674ce08370d01a7f92f9a651ca0253 100644 (file)
@@ -348,8 +348,8 @@ static void visualize_images(const char *fn, int ePBC, matrix box)
     atoms.nr = nat;
     snew(img, nat);
     /* FIXME: Constness should not be cast away */
-    c   = (char *) "C";
-    ala = (char *) "ALA";
+    c   = const_cast<char*>("C");
+    ala = const_cast<char*>("ALA");
     for (i = 0; i < nat; i++)
     {
         atoms.atomname[i]        = &c;
index 621166afc464cd96137232c291031076ef09767b..8e63f022f9fe90802fe9acf45ed24ec56ba0c599 100644 (file)
@@ -382,7 +382,7 @@ int gmx_mdmat(int argc, char *argv[])
         sprintf(legend[2], "Mean");
         sprintf(legend[3], "# atoms");
         sprintf(legend[4], "Mean/# atoms");
-        xvgr_legend(fp, 5, (const char**)legend, oenv);
+        xvgr_legend(fp, 5, legend, oenv);
         for (i = 0; (i < nres); i++)
         {
             if (mean_n[i] == 0)
index 6312fdb033bf5b3b3a90a4f3d707fa57b0ab2cfa..43c1331a00e24ded52eae9ac0fdb2c5c547ba0b6 100644 (file)
@@ -368,10 +368,10 @@ static void dist_plot(const char *fn, const char *afile, const char *dfile,
             snew(leg, 1);
             sprintf(buf, "Internal in %s", grpn[0]);
             leg[0] = gmx_strdup(buf);
-            xvgr_legend(dist, 0, (const char**)leg, oenv);
+            xvgr_legend(dist, 0, leg, oenv);
             if (num)
             {
-                xvgr_legend(num, 0, (const char**)leg, oenv);
+                xvgr_legend(num, 0, leg, oenv);
             }
         }
         else
@@ -385,10 +385,10 @@ static void dist_plot(const char *fn, const char *afile, const char *dfile,
                     leg[j] = gmx_strdup(buf);
                 }
             }
-            xvgr_legend(dist, j, (const char**)leg, oenv);
+            xvgr_legend(dist, j, leg, oenv);
             if (num)
             {
-                xvgr_legend(num, j, (const char**)leg, oenv);
+                xvgr_legend(num, j, leg, oenv);
             }
         }
     }
@@ -400,10 +400,10 @@ static void dist_plot(const char *fn, const char *afile, const char *dfile,
             sprintf(buf, "%s-%s", grpn[0], grpn[i+1]);
             leg[i] = gmx_strdup(buf);
         }
-        xvgr_legend(dist, ng-1, (const char**)leg, oenv);
+        xvgr_legend(dist, ng-1, leg, oenv);
         if (num)
         {
-            xvgr_legend(num, ng-1, (const char**)leg, oenv);
+            xvgr_legend(num, ng-1, leg, oenv);
         }
     }
 
@@ -411,7 +411,7 @@ static void dist_plot(const char *fn, const char *afile, const char *dfile,
     {
         sprintf(buf, "%simum Distance", bMin ? "Min" : "Max");
         respertime = xvgropen(rfile, buf, output_env_get_time_label(oenv), "Distance (nm)", oenv);
-        xvgr_legend(respertime, ng-1, (const char**)leg, oenv);
+        xvgr_legend(respertime, ng-1, leg, oenv);
         if (bPrintResName && output_env_get_print_xvgr_codes(oenv) )
         {
             fprintf(respertime, "# ");
@@ -580,7 +580,7 @@ static void dist_plot(const char *fn, const char *afile, const char *dfile,
 
         sprintf(buf, "%simum Distance", bMin ? "Min" : "Max");
         res = xvgropen(rfile, buf, "Residue (#)", "Distance (nm)", oenv);
-        xvgr_legend(res, ng-1, (const char**)leg, oenv);
+        xvgr_legend(res, ng-1, leg, oenv);
         for (j = 0; j < nres; j++)
         {
             fprintf(res, "%4d", j+1);
index 2a8c650d56df16b40e0612430d687952f825dc24..4bf48a4eef90132b02470b2fe0820c1eac454d82 100644 (file)
@@ -586,7 +586,7 @@ int gmx_nmr(int argc, char *argv[])
                     {
                         fprintf(fort, "%s", orinst_sub);
                     }
-                    xvgr_legend(fort, norsel, (const char**)odtleg, oenv);
+                    xvgr_legend(fort, norsel, odtleg, oenv);
                 }
                 if (bODT)
                 {
@@ -597,7 +597,7 @@ int gmx_nmr(int argc, char *argv[])
                     {
                         fprintf(fodt, "%s", orinst_sub);
                     }
-                    xvgr_legend(fodt, norsel, (const char**)odtleg, oenv);
+                    xvgr_legend(fodt, norsel, odtleg, oenv);
                 }
                 for (i = 0; i < norsel; i++)
                 {
@@ -627,7 +627,7 @@ int gmx_nmr(int argc, char *argv[])
                     }
                 }
             }
-            xvgr_legend(foten, bOvec ? nex*12 : nex*3, (const char**)otenleg, oenv);
+            xvgr_legend(foten, bOvec ? nex*12 : nex*3, otenleg, oenv);
             for (j = 0; j < 3; j++)
             {
                 sfree(otenleg[j]);
@@ -721,7 +721,7 @@ int gmx_nmr(int argc, char *argv[])
                     snew(leg[2*i+1], 32);
                     sprintf(leg[2*i+1], "i %s", pairleg[set[i]]);
                 }
-                xvgr_legend(fp_pairs, 2*nset, (const char**)leg, oenv);
+                xvgr_legend(fp_pairs, 2*nset, leg, oenv);
             }
 
             /*
index f371846364c5fca98ab72bd16d6b741da7de786c..2c5f05bec37b8d7c96ff74f22bb6177ae1e01fa1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,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.
@@ -238,7 +238,7 @@ int gmx_polystat(int argc, char *argv[])
                 legp[d*DIM+d2] = gmx_strdup(buf);
             }
         }
-        xvgr_legend(outv, DIM*DIM, (const char**)legp, oenv);
+        xvgr_legend(outv, DIM*DIM, legp, oenv);
     }
     else
     {
index 40cb12033eec278bded765e6071d5b75e09682ca..3131aceaaf68a75e2eca421171d7730ec3628fa8 100644 (file)
@@ -361,7 +361,7 @@ static void calc_potential(const char *fn, int **index, int gnx[],
 
 static void plot_potential(double *potential[], double *charge[], double *field[],
                            const char *afile, const char *bfile, const char *cfile,
-                           int nslices, int nr_grps, const char *grpname[], double slWidth,
+                           int nslices, int nr_grps, const char *const grpname[], double slWidth,
                            const gmx_output_env_t *oenv)
 {
     FILE       *pot,     /* xvgr file with potential */
@@ -492,7 +492,7 @@ int gmx_potential(int argc, char *argv[])
 
     plot_potential(potential, charge, field, opt2fn("-o", NFILE, fnm),
                    opt2fn("-oc", NFILE, fnm), opt2fn("-of", NFILE, fnm),
-                   nslices, ngrps, (const char**)grpname, slWidth, oenv);
+                   nslices, ngrps, grpname, slWidth, oenv);
 
     do_view(oenv, opt2fn("-o", NFILE, fnm), nullptr);  /* view xvgr file */
     do_view(oenv, opt2fn("-oc", NFILE, fnm), nullptr); /* view xvgr file */
index 6a5c037b372ff355f83d89b8ad2291ee94577a5b..65bfa3a2026bcf496fd5ec970a443e8db6ea2f5f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,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.
@@ -132,15 +132,15 @@ int gmx_principal(int argc, char *argv[])
 
     axis1 = xvgropen(opt2fn("-a1", NFILE, fnm), "Principal axis 1 (major axis)",
                      output_env_get_xvgr_tlabel(oenv), "Component (nm)", oenv);
-    xvgr_legend(axis1, DIM, (const char **)legend, oenv);
+    xvgr_legend(axis1, DIM, legend, oenv);
 
     axis2 = xvgropen(opt2fn("-a2", NFILE, fnm), "Principal axis 2 (middle axis)",
                      output_env_get_xvgr_tlabel(oenv), "Component (nm)", oenv);
-    xvgr_legend(axis2, DIM, (const char **)legend, oenv);
+    xvgr_legend(axis2, DIM, legend, oenv);
 
     axis3 = xvgropen(opt2fn("-a3", NFILE, fnm), "Principal axis 3 (minor axis)",
                      output_env_get_xvgr_tlabel(oenv), "Component (nm)", oenv);
-    xvgr_legend(axis3, DIM, (const char **)legend, oenv);
+    xvgr_legend(axis3, DIM, legend, oenv);
 
     sprintf(legend[XX], "Axis 1 (major)");
     sprintf(legend[YY], "Axis 2 (middle)");
@@ -148,7 +148,7 @@ int gmx_principal(int argc, char *argv[])
 
     fmoi  = xvgropen(opt2fn("-om", NFILE, fnm), "Moments of inertia around inertial axes",
                      output_env_get_xvgr_tlabel(oenv), "I (au nm\\S2\\N)", oenv);
-    xvgr_legend(fmoi, DIM, (const char **)legend, oenv);
+    xvgr_legend(fmoi, DIM, legend, oenv);
 
     for (i = 0; i < DIM; i++)
     {
index 487df83eb4fef6b2f4082f4519794ab9ada6d614..3ffab0943ac05c390ccfc841aa3ea888ab3bdd88 100644 (file)
@@ -1136,7 +1136,7 @@ int gmx_rms(int argc, char *argv[])
     }
     if (nrms != 1)
     {
-        xvgr_legend(fp, nrms, (const char**)gn_rms, oenv);
+        xvgr_legend(fp, nrms, gn_rms, oenv);
     }
     for (i = 0; (i < teller); i++)
     {
@@ -1179,7 +1179,7 @@ int gmx_rms(int argc, char *argv[])
             {
                 fprintf(fp, "@ subtitle \"after lsq fit to mirror %s\"\n", bFit ? gn_fit : "");
             }
-            xvgr_legend(fp, nrms, (const char**)gn_rms, oenv);
+            xvgr_legend(fp, nrms, gn_rms, oenv);
         }
         for (i = 0; (i < teller); i++)
         {
index 6fdd9c575cc8c095baf132566e3158f3daded948..d7f0a8629e12e429d1a5158f50e491f9fa4ea6d2 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,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.
@@ -282,7 +282,7 @@ int gmx_saltbr(int argc, char *argv[])
 
                     if (nset[nnn] == 0)
                     {
-                        xvgr_legend(out[nnn], 1, (const char**)&buf, oenv);
+                        xvgr_legend(out[nnn], 1, &buf, oenv);
                     }
                     else
                     {
index c250a41deebefaa4034cd3bfeeeb15a8451435e7..b8550687a2bd52e933c377fd94dc95dfd97b5906 100644 (file)
@@ -210,8 +210,8 @@ typedef struct {
 
 static int comp_minima(const void *a, const void *b)
 {
-    t_minimum *ma = (t_minimum *) a;
-    t_minimum *mb = (t_minimum *) b;
+    const t_minimum *ma = reinterpret_cast<const t_minimum*>(a);
+    const t_minimum *mb = reinterpret_cast<const t_minimum*>(b);;
 
     if (ma->ener < mb->ener)
     {
index fc28be140f510b868b09a7afc59e50f863f33e25..1ecb1ecf16dc3647243b5298b49eaa6dadab62d9 100644 (file)
@@ -250,7 +250,7 @@ static void make_legend(FILE *fp, int ngrps, int isize, int index[],
             }
         }
     }
-    xvgr_legend(fp, j, (const char**)leg, oenv);
+    xvgr_legend(fp, j, leg, oenv);
 
     for (i = 0; i < j; i++)
     {
index d2e1c68dce2921fe4f7bb30968107f4e222706b9..f34e6077c603c141f49ba16aaf566495f936ec2b 100644 (file)
@@ -65,10 +65,10 @@ static t_order *order;
 
 static int ocomp(const void *a, const void *b)
 {
-    t_order *oa, *ob;
+    const t_order *oa, *ob;
 
-    oa = (t_order *)a;
-    ob = (t_order *)b;
+    oa = reinterpret_cast<const t_order*>(a);
+    ob = reinterpret_cast<const t_order*>(b);
 
     if (oa->d2 < ob->d2)
     {
index dcd2374122cbe37bbf41554a09d4ee32b0066753..7d2ca2c17018b1a0ef1542cda0a049599af069b4 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,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.
@@ -453,7 +453,7 @@ int gmx_vanhove(int argc, char *argv[])
             sprintf(buf, "%g ps", (fbin + 1)*fshift*dt);
             legend[fbin] = gmx_strdup(buf);
         }
-        xvgr_legend(fp, nr, (const char**)legend, oenv);
+        xvgr_legend(fp, nr, legend, oenv);
         for (i = 0; i < nalloc; i++)
         {
             fprintf(fp, "%g", i*rbin);
index dcdeba36071a6f80419db9d01f623c049da4f20c..957a2454b45f76118c4d090f783001da084a240f 100644 (file)
@@ -284,11 +284,6 @@ static void set_p(t_param *p, const int ai[4], const real *c, char *s)
     set_p_string(p, s);
 }
 
-static int int_comp(const void *a, const void *b)
-{
-    return (*(int *)a) - (*(int *)b);
-}
-
 static int idcomp(const void *a, const void *b)
 {
     const t_param *pa, *pb;
@@ -625,7 +620,7 @@ static void gen_excls(t_atoms *atoms, t_excls *excls, t_hackblock hb[],
     {
         if (excls[a].nr > 1)
         {
-            qsort(excls[a].e, excls[a].nr, static_cast<size_t>(sizeof(int)), int_comp);
+            std::sort(excls[a].e, excls[a].e+excls[a].nr);
         }
     }
 }
index 47826b54f03489b3d63c34172d43bc041185547a..a1e1baa09cfd94ba349a4617342d25a0f176053b 100644 (file)
@@ -56,10 +56,10 @@ typedef struct {
 static int
 bond_sort (const void *a, const void *b)
 {
-    sortable *sa, *sb;
+    const sortable *sa, *sb;
 
-    sa = (sortable *) a;
-    sb = (sortable *) b;
+    sa = reinterpret_cast<const sortable*>(a);
+    sb = reinterpret_cast<const sortable*>(b);
 
     if (sa->ai == sb->ai)
     {
@@ -74,7 +74,7 @@ bond_sort (const void *a, const void *b)
 static int
 compare_int (const void * a, const void * b)
 {
-    return ( *(int*)a - *(int*)b );
+    return ( *reinterpret_cast<const int*>(a) - *reinterpret_cast<const int*>(b) );
 }
 
 
@@ -210,7 +210,7 @@ static void nnb2excl(t_nextnb *nnb, t_blocka *excl)
         prints("nnb2excl before qsort", nr_of_sortables, s);
         if (nr_of_sortables > 1)
         {
-            qsort ((void *)s, nr_of_sortables, static_cast<size_t>(sizeof(s[0])), bond_sort);
+            qsort (s, nr_of_sortables, static_cast<size_t>(sizeof(s[0])), bond_sort);
             prints("nnb2excl after qsort", nr_of_sortables, s);
         }
 
@@ -391,7 +391,7 @@ void gen_nnb(t_nextnb *nnb, t_params plist[])
     prints("gen_excl before qsort", nrbonds, s);
     if (nrbonds > 1)
     {
-        qsort((void *) s, nrbonds, static_cast<size_t>(sizeof(sortable)), bond_sort);
+        qsort(s, nrbonds, static_cast<size_t>(sizeof(sortable)), bond_sort);
         prints("gen_excl after qsort", nrbonds, s);
     }
 
index 3096deb0457ad163cc815993f6b757153f54181a..655d5a440679961b4cce597829d3d3873a6f61e3 100644 (file)
@@ -73,7 +73,7 @@ void done_ebin(t_ebin *eb)
     sfree(eb->enm);
 }
 
-int get_ebin_space(t_ebin *eb, int nener, const char *enm[], const char *unit)
+int get_ebin_space(t_ebin *eb, int nener, const char *const enm[], const char *unit)
 {
     int         index;
     int         i, f;
index ca762320588271a672f73564cafced3fbbda1597..2c4240af2511fb55279fdfe5f47d64eb0c977741 100644 (file)
@@ -65,7 +65,7 @@ t_ebin *mk_ebin(void);
 //! Empty the contents of \c eb.
 void done_ebin(t_ebin *eb);
 
-int get_ebin_space(t_ebin *eb, int nener, const char *enm[], const char *unit);
+int get_ebin_space(t_ebin *eb, int nener, const char *const enm[], const char *unit);
 
 /* Create space in the energy bin and register names.
  * The enm array must be static, because the contents are not copied,
index d93646f1b7ea2d9c4b952d82715fdabf6fac2a03..45929d219f1b8fef8381d65ea66ae5e6239f3ba2 100644 (file)
@@ -335,7 +335,7 @@ void do_force_lowlevel(t_forcerec           *fr,
     }
 
     do_force_listed(wcycle, box, ir->fepvals, cr, ms,
-                    idef, (const rvec *) x, hist,
+                    idef, x, hist,
                     forceForUseWithShiftForces, forceWithVirial,
                     fr, &pbc, graph, enerd, nrnb, lambda, md, fcd,
                     DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr,
index 64cfab706060f8a871464dea6f2c6cf24d9195e9..b8ea3238eb3324b06c375f522b5a697818fa155a 100644 (file)
@@ -408,7 +408,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                     }
                 }
                 md->igrp[n] = get_ebin_space(md->ebin, md->nEc,
-                                             (const char **)gnm, unit_energy);
+                                             gnm, unit_energy);
                 n++;
             }
         }
@@ -467,7 +467,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
         sprintf(buf, "T-%s", *(groups->grpname[ni]));
         grpnms[i] = gmx_strdup(buf);
     }
-    md->itemp = get_ebin_space(md->ebin, md->nTC, (const char **)grpnms,
+    md->itemp = get_ebin_space(md->ebin, md->nTC, grpnms,
                                unit_temp_K);
 
     if (md->etc == etcNOSEHOOVER)
@@ -489,7 +489,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                     }
                 }
                 md->itc = get_ebin_space(md->ebin, md->mde_n,
-                                         (const char **)grpnms, unit_invtime);
+                                         grpnms, unit_invtime);
                 if (md->bMTTK)
                 {
                     for (i = 0; (i < md->nTCP); i++)
@@ -504,7 +504,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                         }
                     }
                     md->itcb = get_ebin_space(md->ebin, md->mdeb_n,
-                                              (const char **)grpnms, unit_invtime);
+                                              grpnms, unit_invtime);
                 }
             }
             else
@@ -519,7 +519,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
                     grpnms[2*i+1] = gmx_strdup(buf);
                 }
                 md->itc = get_ebin_space(md->ebin, md->mde_n,
-                                         (const char **)grpnms, unit_invtime);
+                                         grpnms, unit_invtime);
             }
         }
     }
@@ -532,7 +532,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
             sprintf(buf, "Lamb-%s", *(groups->grpname[ni]));
             grpnms[i] = gmx_strdup(buf);
         }
-        md->itc = get_ebin_space(md->ebin, md->mde_n, (const char **)grpnms, "");
+        md->itc = get_ebin_space(md->ebin, md->mde_n, grpnms, "");
     }
 
     for (i = 0; i < md->mde_n; i++)
@@ -555,7 +555,7 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
             sprintf(buf, "Uz-%s", *(groups->grpname[ni]));
             grpnms[3*i+ZZ] = gmx_strdup(buf);
         }
-        md->iu = get_ebin_space(md->ebin, 3*md->nU, (const char **)grpnms, unit_vel);
+        md->iu = get_ebin_space(md->ebin, 3*md->nU, grpnms, unit_vel);
         sfree(grpnms);
     }
 
@@ -876,7 +876,7 @@ extern FILE *open_dhdl(const char *filename, const t_inputrec *ir,
                                                           nsets */
         }
 
-        xvgr_legend(fp, nsetsextend, (const char **)setname, oenv);
+        xvgr_legend(fp, nsetsextend, setname, oenv);
 
         for (s = 0; s < nsetsextend; s++)
         {
index 2f448ff4bc30ea7e510bc0edff8458d91c4718cb..c168e041763d0c8db6a357a6d5b122544443b4d7 100644 (file)
@@ -116,10 +116,10 @@ typedef struct {
 //! Compares sort blocks.
 static int pcomp(const void *p1, const void *p2)
 {
-    int          db;
-    int          min1, min2, max1, max2;
-    t_sortblock *a1 = (t_sortblock *)p1;
-    t_sortblock *a2 = (t_sortblock *)p2;
+    int                db;
+    int                min1, min2, max1, max2;
+    const t_sortblock *a1 = reinterpret_cast<const t_sortblock*>(p1);
+    const t_sortblock *a2 = reinterpret_cast<const t_sortblock*>(p2);
 
     db = a1->blocknr-a2->blocknr;
 
index be752e8bb8c674964ce8eb54b198db53867c3c02..3f53746ab67610061a8aeea9f810c0f681ce50f0 100644 (file)
@@ -54,22 +54,15 @@ typedef struct {
     int atom, sid;
 } t_sid;
 
-static int sid_comp(const void *a, const void *b)
+static bool sid_comp(const t_sid &sa, const t_sid &sb)
 {
-    t_sid *sa, *sb;
-    int    dd;
-
-    sa = (t_sid *)a;
-    sb = (t_sid *)b;
-
-    dd = sa->sid-sb->sid;
-    if (dd == 0)
+    if (sa.sid == sb.sid)
     {
-        return (sa->atom-sb->atom);
+        return sa.atom < sb.atom;
     }
     else
     {
-        return dd;
+        return sa.sid < sb.sid;
     }
 }
 
@@ -382,7 +375,7 @@ void gen_sblocks(FILE *fp, int at_start, int at_end,
     }
 
     /* Now sort the shake blocks... */
-    qsort(sid+at_start, at_end-at_start, static_cast<size_t>(sizeof(sid[0])), sid_comp);
+    std::sort(sid+at_start, sid+at_end, sid_comp);
 
     if (debug)
     {
index 4414c8ef295fc8c19106d4f7790fbf99637fea6f..575c362654c02298857554d2084004910d88b92f 100644 (file)
@@ -417,7 +417,7 @@ Integrator::do_tpi()
                 leg[e++] = gmx_strdup(str);
             }
         }
-        xvgr_legend(fp_tpi, 4+nener, (const char**)leg, oenv);
+        xvgr_legend(fp_tpi, 4+nener, leg, oenv);
         for (i = 0; i < 4+nener; i++)
         {
             sfree(leg[i]);
@@ -842,7 +842,7 @@ Integrator::do_tpi()
                           "\\betaU - log(V/<V>)", "count", oenv);
         sprintf(str, "number \\betaU > %g: %9.3e", bU_bin_limit, bin[0]);
         xvgr_subtitle(fp_tpi, str, oenv);
-        xvgr_legend(fp_tpi, 2, (const char **)tpid_leg, oenv);
+        xvgr_legend(fp_tpi, 2, tpid_leg, oenv);
         for (i = nbin-1; i > 0; i--)
         {
             bUlogV = -i/invbinw + bU_logV_bin_limit - refvolshift + log(V_all/frame);
index b98a8e0bfb6a3687e57f89140b88e81fb89374b3..d89a201d7657a5b105f79cfaeb67d2fbe7f5a01f 100644 (file)
@@ -318,11 +318,11 @@ free_data_same(void *data)
 static int
 cmp_int(const void *a, const void *b)
 {
-    if (*(int *)a < *(int *)b)
+    if (*reinterpret_cast<const int*>(a) < *reinterpret_cast<const int*>(b))
     {
         return -1;
     }
-    if (*(int *)a > *(int *)b)
+    if (*reinterpret_cast<const int*>(a) > *reinterpret_cast<const int*>(b))
     {
         return 1;
     }