Most of these are real errors or potential problems.
It's only a small start ~100 warnings are left and quite a few
false positives are within those remaining ones.
Change-Id: I7c83afa84c52362ecc1b7c992591d82f8262a6ac
#ifdef __cplusplus
extern "C" {
#endif
+
+#ifndef __has_feature // Optional.
+#define __has_feature(x) 0 // Compatibility with non-clang compilers.
+#endif
+
+/** \def GMX_ATTRIBUTE_NORETURN \brief Indicate that a function is not
+ * expected to return.
+ * WARNING: In general this flag should not be used for compiler
+ * optimizations, since set_gmx_error_handler can be set to a
+ * handler which does not quit.
+ */
+#ifndef GMX_ATTRIBUTE_NORETURN
+#if __has_feature(attribute_analyzer_noreturn)
+#define GMX_ATTRIBUTE_NORETURN __attribute__((analyzer_noreturn))
+#else
+#define GMX_ATTRIBUTE_NORETURN
+#endif
+#endif
void
_where(const char *file,int line);
/* unsets filename to be removed */
void
-gmx_fatal(int fatal_errno,const char *file,int line,const char *fmt,...);
+gmx_fatal(int fatal_errno,const char *file,int line,const char *fmt,...) GMX_ATTRIBUTE_NORETURN;
#define FARGS 0,__FILE__,__LINE__
/*
* Routine gmx_fatal prints
void
gmx_fatal_collective(int f_errno,const char *file,int line,
t_commrec *cr,gmx_domdec_t *dd,
- const char *fmt,...);
+ const char *fmt,...) GMX_ATTRIBUTE_NORETURN;
/* As gmx_fatal, but only the master process prints the error message.
* This should only be called one of the following two situations:
* 1) On all nodes in cr->mpi_comm_mysim, with cr!=NULL,dd==NULL.
* The messages are stored in src/gmxlib/fatal.c
*/
- void _gmx_error(const char *key,const char *msg,const char *file,int line);
+ void _gmx_error(const char *key,const char *msg,const char *file,int line) GMX_ATTRIBUTE_NORETURN;
#define gmx_error(key,msg) _gmx_error(key,msg,__FILE__,__LINE__)
/* Error msg of type key is generated and the program is
* terminated unless and error handle is set (see below)
mpi_in_place_buf_t *mpb;
} t_commrec;
-#define MASTERNODE(cr) ((cr)->nodeid == 0)
+#define MASTERNODE(cr) (((cr)->nodeid == 0) || !PAR(cr))
/* #define MASTERTHREAD(cr) ((cr)->threadid == 0) */
/* #define MASTER(cr) (MASTERNODE(cr) && MASTERTHREAD(cr)) */
#define MASTER(cr) MASTERNODE(cr)
#define RANK(cr,nodeid) (nodeid)
#define MASTERRANK(cr) (0)
-#define DOMAINDECOMP(cr) ((cr)->dd != NULL)
+#define DOMAINDECOMP(cr) (((cr)->dd != NULL) && PAR(cr))
#define DDMASTER(dd) ((dd)->rank == (dd)->masterrank)
#define PARTDECOMP(cr) ((cr)->pd != NULL)
else {
while ((ps->prev != NULL) && (ps->prev->fp != fp))
ps=ps->prev;
- if (ps->prev->fp == fp) {
+ if ((ps->prev != NULL) && ps->prev->fp == fp) {
if (ps->prev->fp != NULL)
ret = pclose(ps->prev->fp);
tmp=ps->prev;
(*grpname)[b->nr-1]=strdup(str);
} else {
pt=line;
- while ((i=sscanf(pt,"%s",str)) == 1) {
+ while (sscanf(pt,"%s",str) == 1) {
i=b->index[b->nr];
if (i>=maxentries) {
maxentries+=1024;
void read_xpm_entry(FILE *in,t_matrix *mm)
{
t_mapping *map;
- char *line_buf=NULL,*line=NULL,*str,buf[256];
+ char *line_buf=NULL,*line=NULL,*str,buf[256]={0};
int i,m,col_len,nch,n_axis_x,n_axis_y,llmax;
int llalloc=0;
unsigned int r,g,b;
parsestring(line,"y-label",(mm->label_y));
parsestring(line,"type",buf);
}
+
+ if (!line || strncmp(line,"static",6) != 0)
+ {
+ gmx_input("Invalid XPixMap");
+ }
+
if (buf[0] && (gmx_strcasecmp(buf,"Discrete")==0))
mm->bDiscrete=TRUE;
fprintf(debug,"%s %s %s %s\n",
mm->title,mm->legend,mm->label_x,mm->label_y);
- if (strncmp(line,"static",6) != 0)
- gmx_input("Invalid XPixMap");
/* Read sizes */
bGetOnWithIt=FALSE;
while (!bGetOnWithIt && (NULL != fgetline(&line_buf,llmax,&llalloc,in))) {
line2string(&line);
sscanf(line,"%d %d %d %d",&(mm->nx),&(mm->ny),&(mm->nmap),&nch);
if (nch > 2)
- gmx_fatal(FARGS,"Sorry can only read xpm's with at most 2 caracters per pixel\n");
+ {
+ gmx_fatal(FARGS,"Sorry can only read xpm's with at most 2 caracters per pixel\n");
+ }
+ if (mm->nx <= 0 || mm->ny <= 0 )
+ {
+ gmx_fatal(FARGS,"Dimensions of xpm-file have to be larger than 0\n");
+ }
llmax = max(STRLEN,mm->nx+10);
bGetOnWithIt=TRUE;
}
}
}
-static void g_error(int line,const char *file)
+GMX_ATTRIBUTE_NORETURN static void g_error(int line,const char *file)
{
gmx_fatal(FARGS,"Tring to print non existant graph (file %s, line %d)",
file,line);
/* Fill the cmdline string */
snew(oenv->cmd_line,cmdlength+argc+1);
- for (i=0; i<argc; i++)
+ if (argv)
{
- strcat(oenv->cmd_line,argv[i]);
- strcat(oenv->cmd_line," ");
+ for (i=0; i<argc; i++)
+ {
+ strcat(oenv->cmd_line,argv[i]);
+ strcat(oenv->cmd_line," ");
+ }
}
}
#include <ctype.h>
+#include <assert.h>
#include "copyrite.h"
#include "sysstuff.h"
#include "macros.h"
static void usage(const char *type,const char *arg)
{
- if (arg != NULL)
- gmx_fatal(FARGS,"Expected %s argument for option %s\n",type,arg);
+ assert(arg);
+ gmx_fatal(FARGS,"Expected %s argument for option %s\n",type,arg);
}
int iscan(int argc,char *argv[],int *i)
{
t_tpxheader header;
int natoms,i,version,generation;
- gmx_bool bTop,bXNULL;
+ gmx_bool bTop,bXNULL=FALSE;
gmx_mtop_t *mtop;
t_topology *topconv;
gmx_atomprop_t aps;
else {
get_stx_coordnum(infile,&natoms);
init_t_atoms(&top->atoms,natoms,FALSE);
- bXNULL = (x == NULL);
+ if (x == NULL)
+ {
+ snew(x,1);
+ bXNULL = TRUE;
+ }
snew(*x,natoms);
if (v)
snew(*v,natoms);
read_stx_conf(infile,title,&top->atoms,*x,(v==NULL) ? NULL : *v,ePBC,box);
- if (bXNULL) {
+ if (bXNULL)
+ {
sfree(*x);
- x = NULL;
+ sfree(x);
}
if (bMass) {
aps = gmx_atomprop_init();
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <assert.h>
/*
* Plugin header files; get plugin source from www.ks.uiuc.edu/Research/vmd"
if (fr->vmdplugin.api->abiversion > 10 && fr->vmdplugin.api->read_timestep_metadata)
{
fr->vmdplugin.api->read_timestep_metadata(fr->vmdplugin.handle, metadata);
+ assert(metadata);
fr->vmdplugin.bV = metadata->has_velocities;
if (fr->vmdplugin.bV)
{
#include <string.h>
#include <errno.h>
#include <ctype.h>
+#include <assert.h>
+
#include "futil.h"
#include "sysstuff.h"
#include "typedefs.h"
push_vsitesn(d,plist,mi0->plist,&(mi0->atoms),atype,pline,wi);
break;
case d_exclusions:
+ assert(block2);
if (!block2[nmol-1].nr)
init_block2(&(block2[nmol-1]),mi0->atoms.nr);
push_excl(pline,&(block2[nmol-1]));
#include <config.h>
#endif
+#include <assert.h>
+
#include "typedefs.h"
#include "smalloc.h"
#include "strdb.h"
if (fr->bBHAM) {
if (bhama == NULL) {
+ assert(bhamb==NULL && bhamc==NULL);
snew(bhama,atnr);
snew(bhamb,atnr);
snew(bhamc,atnr);
}
else {
if (sigma == NULL) {
+ assert(eps==NULL && c6==NULL && cn==NULL);
snew(sigma,atnr);
snew(eps,atnr);
snew(c6,atnr);
fprintf(debug,"val = %g\n",val);
switch (range[i].ptype) {
case eseSIGMA:
+ assert(!fr->bBHAM);
sigma[range[i].atype] = val;
break;
case eseEPSILON:
+ assert(!fr->bBHAM);
eps[range[i].atype] = val;
break;
case eseBHAMA:
+ assert(fr->bBHAM);
bhama[range[i].atype] = val;
break;
case eseBHAMB:
+ assert(fr->bBHAM);
bhamb[range[i].atype] = val;
break;
case eseBHAMC:
+ assert(fr->bBHAM);
bhamc[range[i].atype] = val;
break;
case eseCELLX:
tensor dumpres,dumvir;
double *scalefac,dtc;
int *trotter_seq;
- rvec sumv,consk;
+ rvec sumv={0,0,0},consk;
gmx_bool bCouple;
if (trotter_seqno <= ettTSEQ2)
ivec npulse;
int i,cg_gl;
int *ibuf,buf2[2] = { 0, 0 };
-
- if (DDMASTER(dd))
+ gmx_bool bMaster = DDMASTER(dd);
+ if (bMaster)
{
ma = dd->ma;
srenew(dd->index_gl,dd->cg_nalloc);
srenew(dd->cgindex,dd->cg_nalloc+1);
}
- if (DDMASTER(dd))
+ if (bMaster)
{
for(i=0; i<dd->nnodes; i++)
{
free(N1); free(oN1); /*these are not used for this order*/
free(K0); free(oK0); /*the rest is freed in destroy*/
}
+ N[2]=pN[2]=-1; /*not used*/
/*
Difference between x-y-z regarding 2d decomposition is whether they are
#include <stdio.h>
#include <string.h>
#include <math.h>
+#include <assert.h>
#include "typedefs.h"
#include "txtdump.h"
#include "vec.h"
real * fftgrid;
t_complex * cfftgrid;
int thread;
+ gmx_bool bCalcEnerVir = flags & GMX_PME_CALC_ENER_VIR;
+ gmx_bool bCalcF = flags & GMX_PME_CALC_F;
+
+ assert(pme->nnodes > 0);
+ assert(pme->nnodes == 1 || pme->ndecompdim > 0);
if (pme->nnodes > 1) {
atc = &pme->atc[0];
loop_count =
solve_pme_yzx(pme,cfftgrid,ewaldcoeff,
box[XX][XX]*box[YY][YY]*box[ZZ][ZZ],
- flags & GMX_PME_CALC_ENER_VIR,
+ bCalcEnerVir,
pme->nthread,thread);
if (thread == 0)
{
}
}
- if (flags & GMX_PME_CALC_F)
+ if (bCalcF)
{
/* do 3d-invfft */
if (thread == 0)
* With MPI we have to synchronize here before gmx_sum_qgrid_dd.
*/
- if (flags & GMX_PME_CALC_F)
+ if (bCalcF)
{
/* distribute local grid to all nodes */
#ifdef GMX_MPI
wallcycle_stop(wcycle,ewcPME_SPREADGATHER);
}
- if (flags & GMX_PME_CALC_ENER_VIR)
+ if (bCalcEnerVir)
{
/* This should only be called on the master thread
* and after the threads have synchronized.
}
} /* of q-loop */
- if ((flags & GMX_PME_CALC_F) && pme->nnodes > 1) {
+ if (bCalcF && pme->nnodes > 1) {
wallcycle_start(wcycle,ewcPME_REDISTXF);
for(d=0; d<pme->ndecompdim; d++)
{
}
where();
- if (!pme->bFEP) {
- *energy = energy_AB[0];
- m_add(vir,vir_AB[0],vir);
- } else {
- *energy = (1.0-lambda)*energy_AB[0] + lambda*energy_AB[1];
- *dvdlambda += energy_AB[1] - energy_AB[0];
- for(i=0; i<DIM; i++)
- for(j=0; j<DIM; j++)
- vir[i][j] += (1.0-lambda)*vir_AB[0][i][j] + lambda*vir_AB[1][i][j];
+ if (bCalcEnerVir)
+ {
+ if (!pme->bFEP) {
+ *energy = energy_AB[0];
+ m_add(vir,vir_AB[0],vir);
+ } else {
+ *energy = (1.0-lambda)*energy_AB[0] + lambda*energy_AB[1];
+ *dvdlambda += energy_AB[1] - energy_AB[0];
+ for(i=0; i<DIM; i++)
+ {
+ for(j=0; j<DIM; j++)
+ {
+ vir[i][j] += (1.0-lambda)*vir_AB[0][i][j] +
+ lambda*vir_AB[1][i][j];
+ }
+ }
+ }
}
if (debug)
xvgrclose(fp);
}
}
- for(i=0;(i<nparm);i++)
- fitparms[i] = parm[i];
+ if (fitparms)
+ {
+ for(i=0;(i<nparm);i++)
+ {
+ fitparms[i] = parm[i];
+ }
+ }
sfree(parm);
sfree(dparm);
}
}
if (bFreeze) {
- if (atoms && atoms->pdbinfo)
+ if (!atoms || !atoms->pdbinfo)
gmx_fatal(FARGS,"No B-factors in input file %s, use a pdb file next time.",
xfn);