From 52e51227527a7e68b45a20f79332e687cc998635 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 12 May 2012 23:49:24 -0400 Subject: [PATCH] Fixing more clang warnings Change-Id: I1359503f61e1fa003c078c98a99420249b915e9c --- src/gmxlib/do_fit.c | 4 ++++ src/gmxlib/index.c | 4 ++++ src/gmxlib/oenv.c | 5 ++++- src/gmxlib/string2.c | 2 ++ src/mdlib/clincs.c | 2 +- src/mdlib/coupling.c | 2 ++ src/mdlib/domdec_con.c | 2 ++ src/mdlib/domdec_setup.c | 3 +++ src/mdlib/force.c | 2 ++ 9 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/gmxlib/do_fit.c b/src/gmxlib/do_fit.c index 7b2525c19b..bea7e005df 100644 --- a/src/gmxlib/do_fit.c +++ b/src/gmxlib/do_fit.c @@ -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) diff --git a/src/gmxlib/index.c b/src/gmxlib/index.c index 9aa2fd8d9e..cd924844fa 100644 --- a/src/gmxlib/index.c +++ b/src/gmxlib/index.c @@ -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]; diff --git a/src/gmxlib/oenv.c b/src/gmxlib/oenv.c index aea00e0eb2..a9573bd17c 100644 --- a/src/gmxlib/oenv.c +++ b/src/gmxlib/oenv.c @@ -39,6 +39,7 @@ #include +#include #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-". diff --git a/src/gmxlib/string2.c b/src/gmxlib/string2.c index 3ebecc3967..9f84eb75d8 100644 --- a/src/gmxlib/string2.c +++ b/src/gmxlib/string2.c @@ -58,6 +58,7 @@ #include #endif #include +#include #include "typedefs.h" #include "smalloc.h" @@ -72,6 +73,7 @@ int continuing(char *s) */ { int sl; + assert(s); rtrim(s); sl = strlen(s); diff --git a/src/mdlib/clincs.c b/src/mdlib/clincs.c index 89531f60a4..0fc1d7bda5 100644 --- a/src/mdlib/clincs.c +++ b/src/mdlib/clincs.c @@ -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; diff --git a/src/mdlib/coupling.c b/src/mdlib/coupling.c index d12382fe47..4875d62622 100644 --- a/src/mdlib/coupling.c +++ b/src/mdlib/coupling.c @@ -35,6 +35,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include #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 #endif +#include #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) { diff --git a/src/mdlib/domdec_setup.c b/src/mdlib/domdec_setup.c index 04c2aafc62..b069d9c6dd 100644 --- a/src/mdlib/domdec_setup.c +++ b/src/mdlib/domdec_setup.c @@ -21,6 +21,7 @@ #endif #include +#include #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 #include +#include #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; -- 2.11.4.GIT