chiark / gitweb /
Fix all uninitialized variable warnings
authorJulien Schueller <schueller@phimeca.com>
Wed, 23 Aug 2017 19:46:11 +0000 (21:46 +0200)
committerJulien Schueller <schueller@phimeca.com>
Wed, 23 Aug 2017 19:49:29 +0000 (21:49 +0200)
Every variables that yields a -Wmaybe-uninitialized gcc warning is set to 0

Fixes #133

bobyqa/bobyqa.c
cobyla/cobyla.c
luksan/pnet.c
luksan/pssubs.c
mma/ccsa_quadratic.c
newuoa/newuoa.c
praxis/praxis.c
slsqp/slsqp.c

index 031778922a48d10dc700cca1bb400dd688a18e05..2ef46a30e20784191c978d25dc4aaaedc3323353 100644 (file)
@@ -158,8 +158,8 @@ static nlopt_result rescue_(int *n, int *npt, const double *xl, const double *xu
     /* Local variables */
     double f;
     int i__, j, k, ih, jp, ip, iq, np, iw;
-    double xp, xq, den;
-    int ihp;
+    double xp = 0.0, xq, den;
+    int ihp = 0;
     double one;
     int ihq, jpn, kpt;
     double sum, diff, half, beta;
@@ -760,12 +760,12 @@ static void altmov_(int *n, int *npt, double *xpt,
     double slbd;
     int iubd;
     double vlag, subd, temp;
-    int ksav;
-    double step, zero, curv;
+    int ksav = 0;
+    double step = 0.0, zero, curv;
     int iflag;
-    double scale, csave, tempa, tempb, tempd, const__, sumin, ggfree;
-    int ibdsav;
-    double dderiv, bigstp, predsq, presav, distsq, stpsav, wfixsq, wsqsav;
+    double scale, csave = 0.0, tempa, tempb, tempd, const__, sumin, ggfree;
+    int ibdsav = 0;
+    double dderiv, bigstp, predsq, presav, distsq, stpsav = 0.0, wfixsq, wsqsav;
 
 
 /*     The arguments N, NPT, XPT, XOPT, BMAT, ZMAT, NDIM, SL and SU all have */
@@ -1174,16 +1174,16 @@ static void trsbox_(int *n, int *npt, double *xpt,
     double ds;
     int iu;
     double dhd, dhs, cth, one, shs, sth, ssq, half, beta, sdec, blen;
-    int iact, nact;
+    int iact = 0, nact;
     double angt, qred;
     int isav;
-    double temp, zero, xsav, xsum, angbd, dredg, sredg;
+    double temp, zero, xsav = 0.0, xsum, angbd = 0.0, dredg = 0.0, sredg = 0.0;
     int iterc;
-    double resid, delsq, ggsav, tempa, tempb, ratio, sqstp, redmax, 
-           dredsq, redsav, onemin, gredsq, rednew;
-    int itcsav;
-    double rdprev, rdnext, stplen, stepsq;
-    int itermax;
+    double resid, delsq, ggsav = 0.0, tempa, tempb, ratio, sqstp, redmax, 
+           dredsq = 0.0, redsav, onemin, gredsq = 0.0, rednew;
+    int itcsav = 0;
+    double rdprev, rdnext = 0.0, stplen, stepsq;
+    int itermax = 0;
 
 
 /*     The arguments N, NPT, XPT, XOPT, GOPT, HQ, PQ, SL and SU have the same */
@@ -1728,8 +1728,8 @@ static nlopt_result prelim_(int *n, int *npt, double *x,
     double f;
     int i__, j, k, ih, np, nfm;
     double one;
-    int nfx, ipt, jpt;
-    double two, fbeg, diff, half, temp, zero, recip, stepa, stepb;
+    int nfx, ipt = 0, jpt = 0;
+    double two, fbeg, diff, half, temp, zero, recip, stepa = 0.0, stepb = 0.0;
     int itemp;
     double rhosq;
 
@@ -1979,7 +1979,7 @@ static nlopt_result bobyqb_(int *n, int *npt, double *x,
     int kopt, nptm;
     double zero, curv;
     int ksav;
-    double gqsq, dist, sumw, sumz, diffa, diffb, diffc, hdiag;
+    double gqsq, dist, sumw, sumz, diffa, diffb, diffc = 0.0, hdiag;
     int kbase;
     double alpha, delta, adelt, denom, fsave, bdtol, delsq;
     int nresc, nfsav;
index ca4219a15683a7bf06b9e71a9cb7f1cebaa11d6f..2e7a81c56a84c69d97e41901979a8108da3c2e3b 100644 (file)
@@ -478,7 +478,7 @@ static nlopt_result cobylb(int *n, int *m, int *mpp,
   int ivmc;
   int ivmd;
   int mp, np, iz, ibrnch;
-  int nbest, ifull, iptem, jdrop;
+  int nbest, ifull = 0, iptem, jdrop;
   nlopt_result rc = NLOPT_SUCCESS;
   uint32_t seed = (uint32_t) (*n + *m); /* arbitrary deterministic LCG seed */
   int feasible;
index d57461c1d6224de35cd34b3ab8f257bab33bc5a2..3e25634314ceae8cb8b8f9c0fc8f9f7e1c51c872 100644 (file)
@@ -144,7 +144,7 @@ static void pnet_(int *nf, int *nb, double *x, int *
     /* Builtin functions */
 
     /* Local variables */
-    double a, b;
+    double a = 0.0, b = 0.0;
     int i__, n;
     double p, r__;
     int kd, ld;
index cfec171b3986092241b0f27124fd11dd682add97..6e81e56cecc4ded8ed62624aaf7c2b1f1ec87474 100644 (file)
@@ -96,7 +96,7 @@ void luksan_pnint1__(double *rl, double *ru, double *fl,
     double d__1, d__2;
 
     /* Local variables */
-    double a, b, c__, d__, den, dis;
+    double a = 0.0, b = 0.0, c__, d__, den = 0.0, dis;
     int ntyp;
 
     *merr = 0;
index 01f2413fa2762f9dde1235d1da926a7b76ad179f..2b34527856cdbd605b1eef1004dbc336cba588b2 100644 (file)
@@ -224,7 +224,7 @@ nlopt_result ccsa_quadratic_minimize(
      double *xcur, rho, *sigma, *dfdx, *dfdx_cur, *xprev, *xprevprev, fcur;
      double *dfcdx, *dfcdx_cur;
      double *fcval, *fcval_cur, *rhoc, *gcval, *y, *dual_lb, *dual_ub;
-     double *pre_lb, *pre_ub;
+     double *pre_lb = NULL, *pre_ub = NULL;
      unsigned i, ifc, j, k = 0;
      dual_data dd;
      int feasible;
index f6ad2ce72c7a630ea7d75a5cb9ed5ec2d9c8fd71..a22849e3802ad3e0730c7c0e37a2a18388f2a656 100644 (file)
@@ -108,16 +108,16 @@ static nlopt_result trsapp_(int *n, int *npt, double *xopt,
 
     /* Local variables */
     int i__, j, k;
-    double dd, cf, dg, gg;
+    double dd = 0.0, cf, dg, gg = 0.0;
     int ih;
-    double ds, sg;
+    double ds, sg = 0.0;
     int iu;
-    double ss, dhd, dhs, cth, sgk, shs, sth, qadd, half, qbeg, qred, qmin,
-            temp, qsav, qnew, zero, ggbeg, alpha, angle, reduc;
+    double ss, dhd, dhs, cth, sgk, shs = 0.0, sth, qadd, half, qbeg, qred = 0.0, qmin,
+            temp, qsav, qnew, zero, ggbeg = 0.0, alpha, angle, reduc;
     int iterc;
-    double ggsav, delsq, tempa, tempb;
+    double ggsav, delsq, tempa = 0.0, tempb = 0.0;
     int isave;
-    double bstep, ratio, twopi;
+    double bstep = 0.0, ratio, twopi;
     int itersw;
     double angtest;
     int itermax;
@@ -1070,7 +1070,7 @@ static nlopt_result biglag_(int *n, int *npt, double *xopt,
     int nptm;
     double zero, angle, scale, denom;
     int iterc, isave;
-    double delsq, tempa, tempb, twopi, taubeg, tauold, taumax;
+    double delsq, tempa, tempb = 0.0, twopi, taubeg, tauold, taumax;
 
 
 /* N is the number of variables. */
@@ -1390,7 +1390,7 @@ static void update_(int *n, int *npt, double *bmat,
     int nptm;
     double zero;
     int iflag;
-    double scala, scalb_, alpha, denom, tempa, tempb, tausq;
+    double scala, scalb_, alpha, denom, tempa, tempb = 0.0, tausq;
 
 
 /* The arrays BMAT and ZMAT with IDZ are updated, in order to shift the */
@@ -1579,31 +1579,31 @@ static nlopt_result newuob_(int *n, int *npt, double *x,
     double d__1, d__2, d__3;
 
     /* Local variables */
-    double f;
+    double f = 0.0;
     int i__, j, k, ih, nf, nh, ip, jp;
     double dx;
     int np, nfm;
     double one;
     int idz;
-    double dsq, rho;
-    int ipt, jpt;
-    double sum, fbeg, diff, half, beta;
+    double dsq, rho = 0.0;
+    int ipt = 0, jpt = 0;
+    double sum, fbeg = 0.0, diff, half, beta;
     int nfmm;
     double gisq;
     int knew;
     double temp, suma, sumb, fopt = HUGE_VAL, bsum, gqsq;
     int kopt, nptm;
-    double zero, xipt, xjpt, sumz, diffa, diffb, diffc, hdiag, alpha
+    double zero, xipt = 0.0, xjpt = 0.0, sumz, diffa = 0.0, diffb = 0.0, diffc = 0.0, hdiag, alpha = 0.0
            delta, recip, reciq, fsave;
-    int ksave, nfsav, itemp;
-    double dnorm, ratio, dstep, tenth, vquad;
+    int ksave, nfsav = 0, itemp;
+    double dnorm = 0.0, ratio = 0.0, dstep, tenth, vquad;
     int ktemp;
     double tempq;
-    int itest;
+    int itest = 0;
     double rhosq;
-    double detrat, crvmin;
+    double detrat, crvmin = 0.0;
     double distsq;
-    double xoptsq;
+    double xoptsq = 0.0;
     double rhoend;
     nlopt_result rc = NLOPT_SUCCESS, rc2;
 
index d6636a9fb69d75af9af887f19284b59af71c09aa..a032904847c185062db1fdf18f4021ab88e6107a 100644 (file)
@@ -622,7 +622,7 @@ static void minfit_(int m, int n, double machep,
 
     /* Local variables */
     double *e; /* size n */
-    double c__, f, g, h__;
+    double c__, f = 0.0, g, h__;
     int i__, j, k, l;
     double s, x, y, z__;
     int l2, ii, kk, kt, ll2, lp1;
index 6cb284d095666a5dd2f8da5a7c550ed0ca98e77a..8a4be2da5cfc319a86d29ea92287af3f291f1f9c 100644 (file)
@@ -315,7 +315,7 @@ static void nnls_(double *a, int *mda, int *m, int *
     double up;
     int iz1, iz2, npp1, iter;
     double wmax, alpha, asave;
-    int itmax, izmax, nsetp;
+    int itmax, izmax = 0, nsetp;
     double unorm;
 
 /*     C.L.LAWSON AND R.J.HANSON, JET PROPULSION LABORATORY: */