Fix some issues found by cppcheck-1.58.
authorTeemu Murtola <teemu.murtola@gmail.com>
Thu, 30 May 2013 04:05:26 +0000 (07:05 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Thu, 27 Jun 2013 18:03:23 +0000 (21:03 +0300)
Some are real (although unlikely) bugs, others are just removal of
unnecessary code or stylistic changes. Fixes about 1/3 of the issues
this version of cppcheck finds; the remaining aren't as easily fixed and
most look like false positives.

Change-Id: Ic7ba3cc26be9906e037ecec9f8e63739ac3786be

12 files changed:
src/gromacs/analysisdata/modules/displacement.cpp
src/gromacs/commandline/cmdlinemodulemanager.cpp
src/gromacs/gmxana/gmx_make_ndx.c
src/gromacs/gmxana/gmx_saltbr.c
src/gromacs/gmxlib/gmx_cpuid.c
src/gromacs/gmxlib/nonbonded/nb_free_energy.c
src/gromacs/gmxlib/tpxio.c
src/gromacs/mdlib/qm_orca.c
src/gromacs/mdlib/tables.c
src/gromacs/options/basicoptions.cpp
src/gromacs/selection/sm_keywords.cpp
src/programs/gmx/tpbcmp.c

index 834d21538507463746521dc87342259bc10c55c5..2dd5836e3d07cd65557112c810b454c000467caf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
  * others, as listed in the AUTHORS file in the top-level source
  * directory and at http://www.gromacs.org.
@@ -100,7 +100,7 @@ class AnalysisDataDisplacementModule::Impl
 
 AnalysisDataDisplacementModule::Impl::Impl()
     : nmax(0), tmax(0.0), ndim(3),
-      bFirst(true), t0(0.0), dt(0.0), t(0.0),
+      bFirst(true), t0(0.0), dt(0.0), t(0.0), ci(0),
       max_store(-1), nstored(0), oldval(NULL),
       histm(NULL)
 {
index 1bdb8a7508c912754deccced96db463901aec359..f99e511cfb37d2995fe9ec1f21bc4d15d436c285 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013, by the GROMACS development team, led by
  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
  * others, as listed in the AUTHORS file in the top-level source
  * directory and at http://www.gromacs.org.
@@ -384,7 +384,7 @@ class CommandLineModuleManager::Impl
 };
 
 CommandLineModuleManager::Impl::Impl(const ProgramInfo &programInfo)
-    : programInfo_(programInfo)
+    : programInfo_(programInfo), helpModule_(NULL)
 {
 }
 
index 0501465c6418351f90872746b5096db66c56644c..c8a2b4c77851ed8fcc38fa0db4e39ef4b5a78379 100644 (file)
@@ -113,7 +113,7 @@ static int or_groups(atom_id nr1, atom_id *at1, atom_id nr2, atom_id *at2,
             }
         }
 
-        printf("Merged two groups with OR: %u %u -> %u\n", nr1, nr2, *nr);
+        printf("Merged two groups with OR: %d %d -> %d\n", nr1, nr2, *nr);
     }
 
     return *nr;
@@ -137,7 +137,7 @@ static int and_groups(atom_id nr1, atom_id *at1, atom_id nr2, atom_id *at2,
         }
     }
 
-    printf("Merged two groups with AND: %u %u -> %u\n", nr1, nr2, *nr);
+    printf("Merged two groups with AND: %d %d -> %d\n", nr1, nr2, *nr);
 
     return *nr;
 }
@@ -316,14 +316,14 @@ static int select_atomnumbers(char **string, t_atoms *atoms, atom_id n1,
                 index[*nr] = i;
                 (*nr)++;
             }
-            printf("Found %u atom%s in range %u-%d\n", *nr, (*nr == 1) ? "" : "s", n1, up);
+            printf("Found %d atom%s in range %d-%d\n", *nr, (*nr == 1) ? "" : "s", n1, up);
             if (n1 == up)
             {
-                sprintf(buf, "a_%u", n1);
+                sprintf(buf, "a_%d", n1);
             }
             else
             {
-                sprintf(buf, "a_%u-%d", n1, up);
+                sprintf(buf, "a_%d-%d", n1, up);
             }
             strcpy(gname, buf);
         }
@@ -389,15 +389,15 @@ static int select_residuenumbers(char **string, t_atoms *atoms,
                 }
             }
         }
-        printf("Found %u atom%s with res.nr. in range %u-%d\n",
+        printf("Found %d atom%s with res.nr. in range %d-%d\n",
                *nr, (*nr == 1) ? "" : "s", n1, up);
         if (n1 == up)
         {
-            sprintf(buf, "r_%u", n1);
+            sprintf(buf, "r_%d", n1);
         }
         else
         {
-            sprintf(buf, "r_%u-%d", n1, up);
+            sprintf(buf, "r_%d-%d", n1, up);
         }
         strcpy(gname, buf);
     }
@@ -464,15 +464,15 @@ static int select_residueindices(char **string, t_atoms *atoms,
                 }
             }
         }
-        printf("Found %u atom%s with resind.+1 in range %u-%d\n",
+        printf("Found %d atom%s with resind.+1 in range %d-%d\n",
                *nr, (*nr == 1) ? "" : "s", n1, up);
         if (n1 == up)
         {
-            sprintf(buf, "r_%u", n1);
+            sprintf(buf, "r_%d", n1);
         }
         else
         {
-            sprintf(buf, "r_%u-%d", n1, up);
+            sprintf(buf, "r_%d-%d", n1, up);
         }
         strcpy(gname, buf);
     }
@@ -532,7 +532,7 @@ static gmx_bool atoms_from_residuenumbers(t_atoms *atoms, int group, t_blocka *b
             }
         }
     }
-    printf("Found %u atom%s in %d residues from group %s\n",
+    printf("Found %d atom%s in %d residues from group %s\n",
            *nr, (*nr == 1) ? "" : "s", j1-j0, gname);
     return *nr;
 }
@@ -595,7 +595,7 @@ static int select_chainnames(t_atoms *atoms, int n_names, char **names,
             (*nr)++;
         }
     }
-    printf("Found %u atom%s with chain identifier%s",
+    printf("Found %d atom%s with chain identifier%s",
            *nr, (*nr == 1) ? "" : "s", (n_names == 1) ? "" : "s");
     for (j = 0; (j < n_names); j++)
     {
@@ -635,7 +635,7 @@ static int select_atomnames(t_atoms *atoms, int n_names, char **names,
             (*nr)++;
         }
     }
-    printf("Found %u atoms with %s%s",
+    printf("Found %d atoms with %s%s",
            *nr, bType ? "type" : "name", (n_names == 1) ? "" : "s");
     for (j = 0; (j < n_names); j++)
     {
@@ -668,7 +668,7 @@ static int select_residuenames(t_atoms *atoms, int n_names, char **names,
             (*nr)++;
         }
     }
-    printf("Found %u atoms with residue name%s", *nr, (n_names == 1) ? "" : "s");
+    printf("Found %d atoms with residue name%s", *nr, (n_names == 1) ? "" : "s");
     for (j = 0; (j < n_names); j++)
     {
         printf(" %s", names[j]);
@@ -789,7 +789,7 @@ static void split_group(t_atoms *atoms, int sel_nr, t_blocka *block, char ***gn,
             srenew(*gn, block->nr);
             if (bAtom)
             {
-                sprintf(buf, "%s_%s_%u", (*gn)[sel_nr], *atoms->atomname[a], a+1);
+                sprintf(buf, "%s_%s_%d", (*gn)[sel_nr], *atoms->atomname[a], a+1);
             }
             else
             {
@@ -869,7 +869,7 @@ static int split_chain(t_atoms *atoms, rvec *x,
     }
     for (j = 0; j < nchain; j++)
     {
-        printf("%d:%6u atoms (%u to %u)\n",
+        printf("%d:%6d atoms (%d to %d)\n",
                j+1, end[j]-start[j]+1, start[j]+1, end[j]+1);
     }
 
@@ -1096,7 +1096,7 @@ static gmx_bool parse_entry(char **string, int natoms, t_atoms *atoms,
             gname[i] = gname[i-1];
         }
         gname[0] = '!';
-        printf("Complemented group: %u atoms\n", *nr);
+        printf("Complemented group: %d atoms\n", *nr);
     }
 
     return bRet;
@@ -1194,7 +1194,7 @@ static void edit_index(int natoms, t_atoms *atoms, rvec *x, t_blocka *block, cha
             }
             for (i = i0; i < i1; i++)
             {
-                printf("%3d %-20s: %5u atoms\n", i, (*gn)[i],
+                printf("%3d %-20s: %5d atoms\n", i, (*gn)[i],
                        block->index[i+1]-block->index[i]);
             }
             newgroup = NOTSET;
index 6fccd9608acd3e615742cbc318d8bf6580b46237..b853772c84886fc0bc274ae696ba55d244e126c3 100644 (file)
@@ -98,7 +98,7 @@ static t_charge *mk_charge(t_atoms *atoms, t_block *cgs, int *nncg)
                cg[i].label, cg[i].q);
         for (j = cgs->index[cg[i].cg]; (j < cgs->index[cg[i].cg+1]); j++)
         {
-            printf(" %4u", j);
+            printf(" %4d", j);
         }
         printf("\n");
     }
index c12ce798a4df1b226c61659ccdef28d8a57fa124..c3c5ff8cd790ee365cee7b3c67c4b0682760ebc9 100644 (file)
@@ -803,8 +803,6 @@ cpuid_check_vendor(void)
         }
     }
     fclose(fp);
-#else
-    vendor = GMX_CPUID_VENDOR_UNKNOWN;
 #endif
 
     return vendor;
index 8c0ec0b588456cf1e4bb6fa23808a73843f3997c..119323020f32b3d3f72532e1eee6b7c7e02a66f1 100644 (file)
@@ -135,14 +135,10 @@ gmx_nb_free_energy_kernel(t_nblist *                nlist,
     krf                 = fr->k_rf;
     crf                 = fr->c_rf;
     ewc                 = fr->ewaldcoeff;
-    Vc                  = kernel_data->energygrp_elec;
     typeA               = mdatoms->typeA;
     typeB               = mdatoms->typeB;
     ntype               = fr->ntype;
     nbfp                = fr->nbfp;
-    Vv                  = kernel_data->energygrp_vdw;
-    tabscale            = kernel_data->table_elec_vdw->scale;
-    VFtab               = kernel_data->table_elec_vdw->data;
     lambda_coul         = kernel_data->lambda[efptCOUL];
     lambda_vdw          = kernel_data->lambda[efptVDW];
     dvdl                = kernel_data->dvdl;
index e8d5d2c73bbf48c310a84555503eb00c51167df4..387d429a7d51f3a44a01b10f8e972ea50c3c897c 100644 (file)
@@ -238,7 +238,6 @@ static void _do_section(t_fileio *fio, int key, gmx_bool bRead, const char *src,
 static void do_pullgrp(t_fileio *fio, t_pullgrp *pgrp, gmx_bool bRead,
                        int file_version)
 {
-    gmx_bool bDum = TRUE;
     int      i;
 
     gmx_fio_do_int(fio, pgrp->nat);
@@ -246,13 +245,13 @@ static void do_pullgrp(t_fileio *fio, t_pullgrp *pgrp, gmx_bool bRead,
     {
         snew(pgrp->ind, pgrp->nat);
     }
-    bDum = gmx_fio_ndo_int(fio, pgrp->ind, pgrp->nat);
+    gmx_fio_ndo_int(fio, pgrp->ind, pgrp->nat);
     gmx_fio_do_int(fio, pgrp->nweight);
     if (bRead)
     {
         snew(pgrp->weight, pgrp->nweight);
     }
-    bDum = gmx_fio_ndo_real(fio, pgrp->weight, pgrp->nweight);
+    gmx_fio_ndo_real(fio, pgrp->weight, pgrp->nweight);
     gmx_fio_do_int(fio, pgrp->pbcatom);
     gmx_fio_do_rvec(fio, pgrp->vec);
     gmx_fio_do_rvec(fio, pgrp->init);
@@ -273,7 +272,6 @@ static void do_expandedvals(t_fileio *fio, t_expanded *expand, t_lambda *fepvals
     /* i is used in the ndo_double macro*/
     int      i;
     real     fv;
-    gmx_bool bDum = TRUE;
     real     rdum;
     int      n_lambda = fepvals->n_lambda;
 
@@ -288,7 +286,7 @@ static void do_expandedvals(t_fileio *fio, t_expanded *expand, t_lambda *fepvals
             {
                 snew(expand->init_lambda_weights, n_lambda);
             }
-            bDum = gmx_fio_ndo_real(fio, expand->init_lambda_weights, n_lambda);
+            gmx_fio_ndo_real(fio, expand->init_lambda_weights, n_lambda);
             gmx_fio_do_gmx_bool(fio, expand->bInit_weights);
         }
 
@@ -320,8 +318,6 @@ static void do_expandedvals(t_fileio *fio, t_expanded *expand, t_lambda *fepvals
 static void do_simtempvals(t_fileio *fio, t_simtemp *simtemp, int n_lambda, gmx_bool bRead,
                            int file_version)
 {
-    gmx_bool bDum = TRUE;
-
     if (file_version >= 79)
     {
         gmx_fio_do_int(fio, simtemp->eSimTempScale);
@@ -333,7 +329,7 @@ static void do_simtempvals(t_fileio *fio, t_simtemp *simtemp, int n_lambda, gmx_
             {
                 snew(simtemp->temperatures, n_lambda);
             }
-            bDum = gmx_fio_ndo_real(fio, simtemp->temperatures, n_lambda);
+            gmx_fio_ndo_real(fio, simtemp->temperatures, n_lambda);
         }
     }
 }
@@ -343,7 +339,6 @@ static void do_fepvals(t_fileio *fio, t_lambda *fepvals, gmx_bool bRead, int fil
     /* i is defined in the ndo_double macro; use g to iterate. */
     int      i, g;
     real     fv;
-    gmx_bool bDum = TRUE;
     real     rdum;
 
     /* free energy values */
@@ -381,8 +376,8 @@ static void do_fepvals(t_fileio *fio, t_lambda *fepvals, gmx_bool bRead, int fil
                 {
                     snew(fepvals->all_lambda[g], fepvals->n_lambda);
                 }
-                bDum = gmx_fio_ndo_double(fio, fepvals->all_lambda[g], fepvals->n_lambda);
-                bDum = gmx_fio_ndo_int(fio, fepvals->separate_dvdl, efptNR);
+                gmx_fio_ndo_double(fio, fepvals->all_lambda[g], fepvals->n_lambda);
+                gmx_fio_ndo_int(fio, fepvals->separate_dvdl, efptNR);
             }
             else if (fepvals->init_lambda >= 0)
             {
@@ -407,8 +402,8 @@ static void do_fepvals(t_fileio *fio, t_lambda *fepvals, gmx_bool bRead, int fil
                 }
             }
         }
-        bDum = gmx_fio_ndo_double(fio, fepvals->all_lambda[efptFEP],
-                                  fepvals->n_lambda);
+        gmx_fio_ndo_double(fio, fepvals->all_lambda[efptFEP],
+                           fepvals->n_lambda);
         if (fepvals->init_lambda >= 0)
         {
             int g, h;
@@ -589,7 +584,6 @@ static void do_pull(t_fileio *fio, t_pull *pull, gmx_bool bRead, int file_versio
 
 static void do_rotgrp(t_fileio *fio, t_rotgrp *rotg, gmx_bool bRead, int file_version)
 {
-    gmx_bool bDum = TRUE;
     int      i;
 
     gmx_fio_do_int(fio, rotg->eType);
@@ -639,7 +633,6 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
                         int file_version, real *fudgeQQ)
 {
     int      i, j, k, *tmp, idum = 0;
-    gmx_bool bDum = TRUE;
     real     rdum, bd_temp;
     rvec     vdum;
     gmx_bool bSimAnn;
@@ -1319,7 +1312,7 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
             }
             if (ir->adress->n_tf_grps > 0)
             {
-                bDum = gmx_fio_ndo_int(fio, ir->adress->tf_table_index, ir->adress->n_tf_grps);
+                gmx_fio_ndo_int(fio, ir->adress->tf_table_index, ir->adress->n_tf_grps);
             }
             if (bRead)
             {
@@ -1327,7 +1320,7 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
             }
             if (ir->adress->n_energy_grps > 0)
             {
-                bDum = gmx_fio_ndo_int(fio, ir->adress->group_explicit, ir->adress->n_energy_grps);
+                gmx_fio_ndo_int(fio, ir->adress->group_explicit, ir->adress->n_energy_grps);
             }
         }
     }
@@ -1404,7 +1397,7 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
         if (bRead && file_version < 13)
         {
             snew(tmp, ir->opts.ngtc);
-            bDum = gmx_fio_ndo_int(fio, tmp, ir->opts.ngtc);
+            gmx_fio_ndo_int(fio, tmp, ir->opts.ngtc);
             for (i = 0; i < ir->opts.ngtc; i++)
             {
                 ir->opts.nrdf[i] = tmp[i];
@@ -1413,10 +1406,10 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
         }
         else
         {
-            bDum = gmx_fio_ndo_real(fio, ir->opts.nrdf, ir->opts.ngtc);
+            gmx_fio_ndo_real(fio, ir->opts.nrdf, ir->opts.ngtc);
         }
-        bDum = gmx_fio_ndo_real(fio, ir->opts.ref_t, ir->opts.ngtc);
-        bDum = gmx_fio_ndo_real(fio, ir->opts.tau_t, ir->opts.ngtc);
+        gmx_fio_ndo_real(fio, ir->opts.ref_t, ir->opts.ngtc);
+        gmx_fio_ndo_real(fio, ir->opts.tau_t, ir->opts.ngtc);
         if (file_version < 33 && ir->eI == eiBD)
         {
             for (i = 0; i < ir->opts.ngtc; i++)
@@ -1427,7 +1420,7 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
     }
     if (ir->opts.ngfrz > 0)
     {
-        bDum = gmx_fio_ndo_ivec(fio, ir->opts.nFreeze, ir->opts.ngfrz);
+        gmx_fio_ndo_ivec(fio, ir->opts.nFreeze, ir->opts.ngfrz);
     }
     if (ir->opts.ngacc > 0)
     {
@@ -1435,8 +1428,8 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
     }
     if (file_version >= 12)
     {
-        bDum = gmx_fio_ndo_int(fio, ir->opts.egp_flags,
-                               ir->opts.ngener*ir->opts.ngener);
+        gmx_fio_ndo_int(fio, ir->opts.egp_flags,
+                        ir->opts.ngener*ir->opts.ngener);
     }
 
     if (bRead && file_version < 26)
@@ -1469,8 +1462,8 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
     {
         /* file version 26 or later */
         /* First read the lists with annealing and npoints for each group */
-        bDum = gmx_fio_ndo_int(fio, ir->opts.annealing, ir->opts.ngtc);
-        bDum = gmx_fio_ndo_int(fio, ir->opts.anneal_npoints, ir->opts.ngtc);
+        gmx_fio_ndo_int(fio, ir->opts.annealing, ir->opts.ngtc);
+        gmx_fio_ndo_int(fio, ir->opts.anneal_npoints, ir->opts.ngtc);
         for (j = 0; j < (ir->opts.ngtc); j++)
         {
             k = ir->opts.anneal_npoints[j];
@@ -1479,8 +1472,8 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
                 snew(ir->opts.anneal_time[j], k);
                 snew(ir->opts.anneal_temp[j], k);
             }
-            bDum = gmx_fio_ndo_real(fio, ir->opts.anneal_time[j], k);
-            bDum = gmx_fio_ndo_real(fio, ir->opts.anneal_temp[j], k);
+            gmx_fio_ndo_real(fio, ir->opts.anneal_time[j], k);
+            gmx_fio_ndo_real(fio, ir->opts.anneal_temp[j], k);
         }
     }
     /* Walls */
@@ -1524,10 +1517,10 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
             snew(ir->et[j].a,  ir->et[j].n);
             snew(ir->et[j].phi, ir->et[j].n);
         }
-        bDum = gmx_fio_ndo_real(fio, ir->ex[j].a,  ir->ex[j].n);
-        bDum = gmx_fio_ndo_real(fio, ir->ex[j].phi, ir->ex[j].n);
-        bDum = gmx_fio_ndo_real(fio, ir->et[j].a,  ir->et[j].n);
-        bDum = gmx_fio_ndo_real(fio, ir->et[j].phi, ir->et[j].n);
+        gmx_fio_ndo_real(fio, ir->ex[j].a,  ir->ex[j].n);
+        gmx_fio_ndo_real(fio, ir->ex[j].phi, ir->ex[j].n);
+        gmx_fio_ndo_real(fio, ir->et[j].a,  ir->et[j].n);
+        gmx_fio_ndo_real(fio, ir->et[j].phi, ir->et[j].n);
     }
 
     /* QMMM stuff */
@@ -1554,18 +1547,18 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
         }
         if (ir->opts.ngQM > 0)
         {
-            bDum = gmx_fio_ndo_int(fio, ir->opts.QMmethod, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_int(fio, ir->opts.QMbasis, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_int(fio, ir->opts.QMcharge, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_int(fio, ir->opts.QMmult, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_gmx_bool(fio, ir->opts.bSH, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_int(fio, ir->opts.CASorbitals, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_int(fio, ir->opts.CASelectrons, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_real(fio, ir->opts.SAon, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_real(fio, ir->opts.SAoff, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_int(fio, ir->opts.SAsteps, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_gmx_bool(fio, ir->opts.bOPT, ir->opts.ngQM);
-            bDum = gmx_fio_ndo_gmx_bool(fio, ir->opts.bTS, ir->opts.ngQM);
+            gmx_fio_ndo_int(fio, ir->opts.QMmethod, ir->opts.ngQM);
+            gmx_fio_ndo_int(fio, ir->opts.QMbasis, ir->opts.ngQM);
+            gmx_fio_ndo_int(fio, ir->opts.QMcharge, ir->opts.ngQM);
+            gmx_fio_ndo_int(fio, ir->opts.QMmult, ir->opts.ngQM);
+            gmx_fio_ndo_gmx_bool(fio, ir->opts.bSH, ir->opts.ngQM);
+            gmx_fio_ndo_int(fio, ir->opts.CASorbitals, ir->opts.ngQM);
+            gmx_fio_ndo_int(fio, ir->opts.CASelectrons, ir->opts.ngQM);
+            gmx_fio_ndo_real(fio, ir->opts.SAon, ir->opts.ngQM);
+            gmx_fio_ndo_real(fio, ir->opts.SAoff, ir->opts.ngQM);
+            gmx_fio_ndo_int(fio, ir->opts.SAsteps, ir->opts.ngQM);
+            gmx_fio_ndo_gmx_bool(fio, ir->opts.bOPT, ir->opts.ngQM);
+            gmx_fio_ndo_gmx_bool(fio, ir->opts.bTS, ir->opts.ngQM);
         }
         /* end of QMMM stuff */
     }
@@ -1584,7 +1577,6 @@ void do_iparams(t_fileio *fio, t_functype ftype, t_iparams *iparams,
                 gmx_bool bRead, int file_version)
 {
     int      idum;
-    gmx_bool bDum;
     real     rdum;
 
     if (!bRead)
@@ -1668,7 +1660,7 @@ void do_iparams(t_fileio *fio, t_functype ftype, t_iparams *iparams,
             break;
         case F_QUARTIC_ANGLES:
             gmx_fio_do_real(fio, iparams->qangle.theta);
-            bDum = gmx_fio_ndo_real(fio, iparams->qangle.c, 5);
+            gmx_fio_ndo_real(fio, iparams->qangle.c, 5);
             break;
         case F_BHAM:
             gmx_fio_do_real(fio, iparams->bham.a);
@@ -1828,18 +1820,18 @@ void do_iparams(t_fileio *fio, t_functype ftype, t_iparams *iparams,
             gmx_fio_do_real(fio, iparams->fbposres.k);
             break;
         case F_RBDIHS:
-            bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcA, NR_RBDIHS);
+            gmx_fio_ndo_real(fio, iparams->rbdihs.rbcA, NR_RBDIHS);
             if (file_version >= 25)
             {
-                bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcB, NR_RBDIHS);
+                gmx_fio_ndo_real(fio, iparams->rbdihs.rbcB, NR_RBDIHS);
             }
             break;
         case F_FOURDIHS:
             /* Fourier dihedrals are internally represented
              * as Ryckaert-Bellemans since those are faster to compute.
              */
-            bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcA, NR_RBDIHS);
-            bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcB, NR_RBDIHS);
+            gmx_fio_ndo_real(fio, iparams->rbdihs.rbcA, NR_RBDIHS);
+            gmx_fio_ndo_real(fio, iparams->rbdihs.rbcB, NR_RBDIHS);
             break;
         case F_CONSTR:
         case F_CONSTRNC:
@@ -1905,7 +1897,6 @@ static void do_ilist(t_fileio *fio, t_ilist *ilist, gmx_bool bRead, int file_ver
                      int ftype)
 {
     int      i, k, idum;
-    gmx_bool bDum = TRUE;
 
     if (!bRead)
     {
@@ -1923,7 +1914,7 @@ static void do_ilist(t_fileio *fio, t_ilist *ilist, gmx_bool bRead, int file_ver
     {
         snew(ilist->iatoms, ilist->nr);
     }
-    bDum = gmx_fio_ndo_int(fio, ilist->iatoms, ilist->nr);
+    gmx_fio_ndo_int(fio, ilist->iatoms, ilist->nr);
     if (!bRead)
     {
         gmx_fio_unset_comment(fio);
@@ -1934,7 +1925,6 @@ static void do_ffparams(t_fileio *fio, gmx_ffparams_t *ffparams,
                         gmx_bool bRead, int file_version)
 {
     int          idum, i, j;
-    gmx_bool     bDum = TRUE;
     unsigned int k;
 
     gmx_fio_do_int(fio, ffparams->atnr);
@@ -1954,7 +1944,7 @@ static void do_ffparams(t_fileio *fio, gmx_ffparams_t *ffparams,
         snew(ffparams->iparams, ffparams->ntypes);
     }
     /* Read/write all the function types */
-    bDum = gmx_fio_ndo_int(fio, ffparams->functype, ffparams->ntypes);
+    gmx_fio_ndo_int(fio, ffparams->functype, ffparams->ntypes);
     if (bRead && debug)
     {
         pr_ivec(debug, 0, "functype", ffparams->functype, ffparams->ntypes, TRUE);
@@ -2030,7 +2020,7 @@ static void do_ilists(t_fileio *fio, t_ilist *ilist, gmx_bool bRead,
                       int file_version)
 {
     int          i, j, renum[F_NRE];
-    gmx_bool     bDum = TRUE, bClear;
+    gmx_bool     bClear;
     unsigned int k;
 
     for (j = 0; (j < F_NRE); j++)
@@ -2083,7 +2073,6 @@ static void do_idef(t_fileio *fio, gmx_ffparams_t *ffparams, gmx_moltype_t *molt
 static void do_block(t_fileio *fio, t_block *block, gmx_bool bRead, int file_version)
 {
     int      i, idum, dum_nra, *dum_a;
-    gmx_bool bDum = TRUE;
 
     if (file_version < 44)
     {
@@ -2106,12 +2095,12 @@ static void do_block(t_fileio *fio, t_block *block, gmx_bool bRead, int file_ver
         block->nalloc_index = block->nr+1;
         snew(block->index, block->nalloc_index);
     }
-    bDum = gmx_fio_ndo_int(fio, block->index, block->nr+1);
+    gmx_fio_ndo_int(fio, block->index, block->nr+1);
 
     if (file_version < 51 && dum_nra > 0)
     {
         snew(dum_a, dum_nra);
-        bDum = gmx_fio_ndo_int(fio, dum_a, dum_nra);
+        gmx_fio_ndo_int(fio, dum_a, dum_nra);
         sfree(dum_a);
     }
 }
@@ -2120,7 +2109,6 @@ static void do_blocka(t_fileio *fio, t_blocka *block, gmx_bool bRead,
                       int file_version)
 {
     int      i, idum;
-    gmx_bool bDum = TRUE;
 
     if (file_version < 44)
     {
@@ -2138,8 +2126,8 @@ static void do_blocka(t_fileio *fio, t_blocka *block, gmx_bool bRead,
         block->nalloc_a = block->nra;
         snew(block->a, block->nalloc_a);
     }
-    bDum = gmx_fio_ndo_int(fio, block->index, block->nr+1);
-    bDum = gmx_fio_ndo_int(fio, block->a, block->nra);
+    gmx_fio_ndo_int(fio, block->index, block->nr+1);
+    gmx_fio_ndo_int(fio, block->a, block->nra);
 }
 
 static void do_atom(t_fileio *fio, t_atom *atom, int ngrp, gmx_bool bRead,
@@ -2196,7 +2184,6 @@ static void do_grps(t_fileio *fio, int ngrp, t_grps grps[], gmx_bool bRead,
                     int file_version)
 {
     int      i, j, myngrp;
-    gmx_bool bDum = TRUE;
 
     if (file_version < 23)
     {
@@ -2220,7 +2207,7 @@ static void do_grps(t_fileio *fio, int ngrp, t_grps grps[], gmx_bool bRead,
             {
                 snew(grps[j].nm_ind, grps[j].nr);
             }
-            bDum = gmx_fio_ndo_int(fio, grps[j].nm_ind, grps[j].nr);
+            gmx_fio_ndo_int(fio, grps[j].nm_ind, grps[j].nr);
         }
         else
         {
@@ -2341,7 +2328,6 @@ static void do_groups(t_fileio *fio, gmx_groups_t *groups,
                       int file_version)
 {
     int      g, n, i;
-    gmx_bool bDum = TRUE;
 
     do_grps(fio, egcNR, groups->grps, bRead, file_version);
     gmx_fio_do_int(fio, groups->ngrpname);
@@ -2366,7 +2352,7 @@ static void do_groups(t_fileio *fio, gmx_groups_t *groups,
             {
                 snew(groups->grpnr[g], groups->ngrpnr[g]);
             }
-            bDum = gmx_fio_ndo_uchar(fio, groups->grpnr[g], groups->ngrpnr[g]);
+            gmx_fio_ndo_uchar(fio, groups->grpnr[g], groups->ngrpnr[g]);
         }
     }
 }
@@ -2375,7 +2361,6 @@ static void do_atomtypes(t_fileio *fio, t_atomtypes *atomtypes, gmx_bool bRead,
                          t_symtab *symtab, int file_version)
 {
     int      i, j;
-    gmx_bool bDum = TRUE;
 
     if (file_version > 25)
     {
@@ -2390,17 +2375,17 @@ static void do_atomtypes(t_fileio *fio, t_atomtypes *atomtypes, gmx_bool bRead,
             snew(atomtypes->gb_radius, j);
             snew(atomtypes->S_hct, j);
         }
-        bDum = gmx_fio_ndo_real(fio, atomtypes->radius, j);
-        bDum = gmx_fio_ndo_real(fio, atomtypes->vol, j);
-        bDum = gmx_fio_ndo_real(fio, atomtypes->surftens, j);
+        gmx_fio_ndo_real(fio, atomtypes->radius, j);
+        gmx_fio_ndo_real(fio, atomtypes->vol, j);
+        gmx_fio_ndo_real(fio, atomtypes->surftens, j);
         if (file_version >= 40)
         {
-            bDum = gmx_fio_ndo_int(fio, atomtypes->atomnumber, j);
+            gmx_fio_ndo_int(fio, atomtypes->atomnumber, j);
         }
         if (file_version >= 60)
         {
-            bDum = gmx_fio_ndo_real(fio, atomtypes->gb_radius, j);
-            bDum = gmx_fio_ndo_real(fio, atomtypes->S_hct, j);
+            gmx_fio_ndo_real(fio, atomtypes->gb_radius, j);
+            gmx_fio_ndo_real(fio, atomtypes->S_hct, j);
         }
     }
     else
@@ -3064,7 +3049,7 @@ static int do_tpx(t_fileio *fio, gmx_bool bRead,
     t_tpxheader     tpx;
     t_inputrec      dum_ir;
     gmx_mtop_t      dum_top;
-    gmx_bool        TopOnlyOK, bDum = TRUE;
+    gmx_bool        TopOnlyOK;
     int             file_version, file_generation;
     int             i;
     rvec           *xptr, *vptr;
@@ -3146,10 +3131,10 @@ static int do_tpx(t_fileio *fio, gmx_bool bRead,
         snew(dumv, state->ngtc);
         if (file_version < 69)
         {
-            bDum = gmx_fio_ndo_real(fio, dumv, state->ngtc);
+            gmx_fio_ndo_real(fio, dumv, state->ngtc);
         }
         /* These used to be the Berendsen tcoupl_lambda's */
-        bDum = gmx_fio_ndo_real(fio, dumv, state->ngtc);
+        gmx_fio_ndo_real(fio, dumv, state->ngtc);
         sfree(dumv);
     }
 
index 50b098c6e4f46fe910e6f537cd8b1bdcf4505291..240f51f79c1a6b365719e89b9cd887aedc6ff28c 100644 (file)
@@ -487,7 +487,7 @@ real call_orca(t_commrec *cr,  t_forcerec *fr,
     int
         i, j;
     real
-        QMener = 0.0;
+        QMener;
     rvec
        *QMgrad, *MMgrad;
     char
index 0b41ed1601950b67212e5f99df5ae350a6430802..e8aa04b7e94fdff4d2c4cfffb6a0b2c2bf4fb8e7 100644 (file)
@@ -1397,8 +1397,6 @@ t_forcetable make_gb_table(FILE *out, const output_env_t oenv,
 
     for (i = nx0; i < nx; i++)
     {
-        Vtab    = 0.0;
-        Ftab    = 0.0;
         r       = td->x[i];
         r2      = r*r;
         expterm = exp(-0.25*r2);
index 33eca9bb6101dd049fb802a6229771bf5fea38ce..6b7c33d16ce63a5f96dbe0ed14369c3adab2cebd 100644 (file)
@@ -72,7 +72,7 @@ namespace
 template <typename ValueType>
 void expandVector(size_t length, std::vector<ValueType> *values)
 {
-    if (length > 0 && values->size() > 0 && values->size() != length)
+    if (length > 0 && !values->empty() && values->size() != length)
     {
         if (values->size() != 1)
         {
index d710a6bf67ab9e14b26eb286e596b9df843d5a32..dd0124dd5d555d2504a3433efc47972d1dfae3f8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013, by the GROMACS development team, led by
  * David van der Spoel, Berk Hess, Erik Lindahl, and including many
  * others, as listed in the AUTHORS file in the top-level source
  * directory and at http://www.gromacs.org.
@@ -530,7 +530,7 @@ void
 _gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer &sel,
                                   gmx::SelectionStringMatchType           matchType)
 {
-    t_methoddata_kwstr *d = (t_methoddata_kwstr *)sel->u.expr.mdata;
+    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(sel->u.expr.mdata);
 
     if (sel->type != SEL_EXPRESSION || !sel->u.expr.method
         || sel->u.expr.method->name != sm_keyword_str.name)
@@ -549,7 +549,7 @@ _gmx_selelem_set_kwstr_match_type(const gmx::SelectionTreeElementPointer &sel,
 static void
 init_kwstr(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_kwstr *d = (t_methoddata_kwstr *)data;
+    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
 
     d->v   = param[0].val.u.s;
     /* Return if this is not the first time */
@@ -572,7 +572,7 @@ init_kwstr(t_topology *top, int npar, gmx_ana_selparam_t *param, void *data)
 static void
 free_data_kwstr(void *data)
 {
-    t_methoddata_kwstr *d = (t_methoddata_kwstr *)data;
+    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
     delete d;
 }
 
@@ -589,7 +589,7 @@ static void
 evaluate_keyword_str(t_topology *top, t_trxframe *fr, t_pbc *pbc,
                      gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_kwstr *d = (t_methoddata_kwstr *)data;
+    t_methoddata_kwstr *d = static_cast<t_methoddata_kwstr *>(data);
 
     out->u.g->isize = 0;
     for (int i = 0; i < g->isize; ++i)
index 1415786a7d0ab61d8b45489029cb408a15010a82..e6ac510d2da1a85065d4aa39544ce7ddcfaadff9 100644 (file)
@@ -87,11 +87,11 @@ static void cmp_us(FILE *fp, const char *s, int index, unsigned short i1, unsign
     {
         if (index != -1)
         {
-            fprintf(fp, "%s[%d] (%d - %d)\n", s, index, i1, i2);
+            fprintf(fp, "%s[%d] (%u - %u)\n", s, index, i1, i2);
         }
         else
         {
-            fprintf(fp, "%s (%d - %d)\n", s, i1, i2);
+            fprintf(fp, "%s (%u - %u)\n", s, i1, i2);
         }
     }
 }