Fixing more clang warnings
authorRoland Schulz <roland@utk.edu>
Sun, 13 May 2012 03:49:24 +0000 (23:49 -0400)
committerRoland Schulz <roland@utk.edu>
Wed, 16 May 2012 00:57:18 +0000 (20:57 -0400)
Change-Id: I1359503f61e1fa003c078c98a99420249b915e9c

src/gmxlib/do_fit.c
src/gmxlib/index.c
src/gmxlib/oenv.c
src/gmxlib/string2.c
src/mdlib/clincs.c
src/mdlib/coupling.c
src/mdlib/domdec_con.c
src/mdlib/domdec_setup.c
src/mdlib/force.c

index 7b2525c19b0c44eb3c236e51ad49d44249fbd3c4..bea7e005dff020df04581957b300310d1cdccdee 100644 (file)
@@ -244,6 +244,10 @@ void reset_x_ndim(int ndim,int ncm,const atom_id *ind_cm,
     rvec xcm;
     real tm,mm;
     
+    if (ndim>DIM)
+    {
+        gmx_incons("More than 3 dimensions not supported.");
+    }
     tm = 0.0;
     clear_rvec(xcm);
     if (ind_cm != NULL)
index 9aa2fd8d9ebbf4275934322ba045fa4efc6e5186..cd924844fa66097f4b908be48ca4eab7a0f056f2 100644 (file)
@@ -921,6 +921,10 @@ t_blocka *init_index(const char *gfile, char ***grpname)
        b->index[b->nr]=b->index[b->nr-1];
        (*grpname)[b->nr-1]=strdup(str);
       } else {
+          if (b->nr==0)
+          {
+              gmx_fatal(FARGS,"The first header of your indexfile is invalid");
+          }
        pt=line;
        while (sscanf(pt,"%s",str) == 1) {
          i=b->index[b->nr];
index aea00e0eb2875e7c57d4923e8c6ac594a7551f1f..a9573bd17ccba827deedf8e51acc06dc1eed871f 100644 (file)
@@ -39,6 +39,7 @@
 
 
 #include <ctype.h>
+#include <assert.h>
 #include "sysstuff.h"
 #include "macros.h"
 #include "string2.h"
@@ -101,8 +102,10 @@ void output_env_init(output_env_t oenv,  int argc, char *argv[],
     oenv->program_name=NULL;
 
     if (argv)
+    {
         argvzero=argv[0];
-
+        assert(argvzero);
+    }
     /* set program name */
     /* When you run a dynamically linked program before installing
      * it, libtool uses wrapper scripts and prefixes the name with "lt-".
index 3ebecc3967a9aff20f2813fa29d35981c0c8dbf9..9f84eb75d84e85ed50c4569c57557a209ae113af 100644 (file)
@@ -58,6 +58,7 @@
 #include <pwd.h>
 #endif
 #include <time.h>
+#include <assert.h>
 
 #include "typedefs.h"
 #include "smalloc.h"
@@ -72,6 +73,7 @@ int continuing(char *s)
  */
 {
   int sl;
+  assert(s);
 
   rtrim(s);
   sl = strlen(s);
index 89531f60a4fd7505e989fdc54bab5869a275f2c5..0fc1d7bda50189f3a5b2a7b8fdb76aa2f4cce96d 100644 (file)
@@ -1158,7 +1158,7 @@ gmx_bool constrain_lincs(FILE *fplog,gmx_bool bLog,gmx_bool bEner,
 {
     char  buf[STRLEN],buf2[22],buf3[STRLEN];
     int   i,warn,p_imax,error;
-    real  ncons_loc,p_ssd,p_max;
+    real  ncons_loc,p_ssd,p_max=0;
     t_pbc pbc,*pbc_null;
     rvec  dx;
     gmx_bool  bOK;
index d12382fe47dd18e56951f21c24b547a2f5680f5d..4875d62622bf5f63cc2be0e5d3eb9c8aa3c83634 100644 (file)
@@ -35,6 +35,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include <assert.h>
 
 #include "typedefs.h"
 #include "smalloc.h"
@@ -675,6 +676,7 @@ void trotter_update(t_inputrec *ir,gmx_large_int_t step, gmx_ekindata_t *ekind,
     dtc = ir->nsttcouple*ir->delta_t;
     opts = &(ir->opts); /* just for ease of referencing */
     ngtc = opts->ngtc;
+    assert(ngtc>0);
     snew(scalefac,opts->ngtc);
     for (i=0;i<ngtc;i++) 
     {
index 9152317c7c180d4edb837afe81e35af23ffb1e12..84e662c3515cca3d83a8b0724ba17f625e81cd52 100644 (file)
@@ -19,6 +19,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include <assert.h>
 
 #include "smalloc.h"
 #include "vec.h"
@@ -764,6 +765,7 @@ static void walk_out(int con,int con_offset,int a,int offset,int nrec,
     /* Check to not ask for the same atom more than once */
     if (dc->ga2la[offset+a] == -1)
     {
+        assert(dcc);
         /* Add this non-home atom to the list */
         if (dcc->nind_req+1 > dcc->ind_req_nalloc)
         {
index 04c2aafc6269cdb09e7b556e376307eef32a5549..b069d9c6dd27c5baac3d64e87f59ea570c461137 100644 (file)
@@ -21,6 +21,7 @@
 #endif
 
 #include <stdio.h>
+#include <assert.h>
 #include "domdec.h"
 #include "network.h"
 #include "perf_est.h"
@@ -319,6 +320,8 @@ static float comm_cost_est(gmx_domdec_t *dd,real limit,real cutoff,
         return -1;
     }
 
+    assert(ddbox->npbcdim<=DIM);
+
     /* Check if the triclinic requirements are met */
     for(i=0; i<DIM; i++)
     {
index 79b12d888e420a89bf0c12c348f545e626f5c87a..60988b7d8c5e40f47361ee6ca2bb9fae4cd8f85e 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <math.h>
 #include <string.h>
+#include <assert.h>
 #include "sysstuff.h"
 #include "typedefs.h"
 #include "macros.h"
@@ -431,6 +432,7 @@ void do_force_lowlevel(FILE       *fplog,   gmx_large_int_t step,
         case eelP3M_AD:
             if (cr->duty & DUTY_PME)
             {
+                assert(fr->n_tpi >= 0);
                 if (fr->n_tpi == 0 || (flags & GMX_FORCE_STATECHANGED))
                 {
                     pme_flags = GMX_PME_SPREAD_Q | GMX_PME_SOLVE;