Skip to content

Commit 313c7d2

Browse files
committed
Fix compiler warnings about uninitialised variables and #15
1 parent fedd22a commit 313c7d2

File tree

9 files changed

+19
-9
lines changed

9 files changed

+19
-9
lines changed

blkchol2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd
113113
------------------------------------------------------- */
114114
xkk = x[inz];
115115
if(xkk > lb[k]){ /* now xkk > 0 */
116-
if(xkk < ub){
116+
if((m>1) && (xkk < ub)){
117117
ubk = maxabs(x+inz+1,m-1) / maxu;
118118
if(xkk < ubk){
119119
/* ------------------------------------------------------------

bwblkslv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void mexFunction(const int nlhs, mxArray *plhs[],
186186
mwIndex m,n, j, k, nsuper, inz;
187187
double *y, *fwork;
188188
const double *permPr, *b, *xsuperPr;
189-
const mwIndex *yjc, *yir, *bjc, *bir;
189+
const mwIndex *yjc=NULL, *yir=NULL, *bjc=NULL, *bir=NULL;
190190
mwIndex *perm, *xsuper, *iwork, *snode;
191191
jcir L;
192192
char bissparse;

dpr1fact.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ char dodpr1fact(double *beta, mwIndex *perm, double *d, double t, const double *
365365
------------------------------------------------------------ */
366366
else{
367367
psqrdep = 0.0;
368-
for(i = 0; dep[i] < m; i++)
368+
for(i = 0, j = 0; dep[i] < m; i++)
369369
if(psqr[dep[i]] > psqrdep){
370370
j = i;
371371
psqrdep = psqr[dep[i]];

extractA.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
9898
int nrhs, const mxArray *prhs[])
9999
{
100100
jcir At, Apart;
101-
mwIndex i, m, njc, ifirst, n, ynnz, blk0,blk1;
101+
mwIndex i, m, njc, ifirst=0, n=0, ynnz, blk0, blk1;
102102
mwIndex *Ajc;
103103
const double *blkstartPr, *AjcPr;
104104
bool isblk0negative;

fwblkslv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void mexFunction(const int nlhs, mxArray *plhs[],
197197
mwIndex m,n, j, k, nsuper, inz;
198198
double *y,*fwork;
199199
const double *permPr, *b, *xsuperPr;
200-
const mwIndex *yjc, *yir, *bjc, *bir;
200+
const mwIndex *yjc=NULL, *yir=NULL, *bjc=NULL, *bir=NULL;
201201
mwIndex *perm, *invperm, *snode, *xsuper, *iwork;
202202
jcir L;
203203
char bissparse;

install_sedumi.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ function install_sedumi( varargin )
175175
% whereas calling '-O' would result in gcc '-O1'.
176176
flags{end+1} = '-O2';
177177
flags{end+1} = '-DOCTAVE';
178+
flags{end+1} = '-Werror';
179+
flags{end+1} = '-Wall';
180+
flags{end+1} = '-Wno-unused-variable';
181+
flags{end+1} = '-Wno-unused-but-set-variable';
178182
if (ismac ())
179183
% Assume Homebrew (https://brew.sh/) installation.
180184
% https://stackoverflow.com/questions/50634727/dyld-library-not-loaded-usr-local-opt-openblas-lib-libopenblasp-r0-2-20-dylib

sedumi.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@
794794
info.err(4)=0;
795795
end
796796
% Dual infeasibility
797-
%info.err(3)=0.0; %s is not maintained explicitely
797+
info.err(3)=0.0; %s is not maintained explicitely
798798
% Relative duality gap
799799
info.err(5)=(cx-by)/(1+abs(cx)+abs(by));
800800
% Relative complementarity

spscale.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ mwIndex realdmulx(double *y, mwIndex *ycols, const double *d,
7676
{
7777
mwIndex knz, jfirst, jlast, inz, i, j;
7878
knz = 0; /* length(ycols) */
79+
jfirst = 0;
7980
jlast = 0; /* index right after last activated column */
8081
y -= n; /* point to dummy column, which will be skipped */
8182
/* ------------------------------------------------------------
@@ -133,6 +134,7 @@ mwIndex cpxdmulx(double *y, mwIndex *ycols, const double *d,
133134
const double *dpi;
134135
char found;
135136
knz = 0; /* length(ycols) */
137+
jfirst = 0;
136138
jlast = 0; /* index right after last activated column */
137139
nsqr = SQR(n);
138140
dpi = d + nsqr;
@@ -251,7 +253,7 @@ void sprealdxd(double *z, const mwIndex *zir, const mwIndex znnz,
251253
{
252254
mwIndex inz, i, icol, j, jfirst, jlast, m;
253255
double *xd;
254-
const double *dj, *xdj;
256+
const double *dj=NULL, *xdj=NULL;
255257
/* ------------------------------------------------------------
256258
Partition 2*n^2 WORKING array fwork into [fwork(n^2), xd(n^2)].
257259
------------------------------------------------------------ */
@@ -276,6 +278,7 @@ void sprealdxd(double *z, const mwIndex *zir, const mwIndex znnz,
276278
zij = (D*sym(X)*D)_ij = [ DXD_ij + DXD_ji ] /2.
277279
Note that DXD_ij = xd(:,i)' * fwork(:,j). (m mults)
278280
------------------------------------------------------------ */
281+
jfirst = 0;
279282
jlast = 0; /* index right after last activated column */
280283
for(inz = 0; inz < znnz; inz++){
281284
if((i = zir[inz]) >= jlast){ /* move to new z-column */
@@ -334,7 +337,8 @@ void spcpxdxd(double *z, const mwIndex *zir, const mwIndex znnz,
334337
mwIndex inz, i, icol, j, jfirst, jlast, m, nsqr, imgfirst;
335338
double *dx, *dxpi, *fworkpi;
336339
double zi;
337-
const double *dj, *djpi, *djx, *djxpi;
340+
const double *dj=NULL, *djpi=NULL, *djx=NULL, *djxpi=NULL;
341+
jfirst = 0;
338342
nsqr = SQR(n);
339343
/* ------------------------------------------------------------
340344
Partition 4*n^2 WORKING array fwork into [fwork(2*n^2), dxRows(2*n^2)].

urotorder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void rotorder(mwIndex *perm, double *u, mwIndex *gjc, twodouble *g, double *d,
9090
------------------------------------------------------------ */
9191
for(j = 0; j < n; j++)
9292
perm[j] = j;
93+
pivk = 0;
9394
inz = 0;
9495
d[0] = 0.0; h = 1.0;
9596
for(k = 0, rowuk = u; k < n-1; k++, rowuk++){
@@ -208,6 +209,7 @@ void prpirotorder(mwIndex *perm, double *u,double *upi, mwIndex *gjc,
208209
------------------------------------------------------------ */
209210
for(j = 0; j < n; j++)
210211
perm[j] = j;
212+
pivk = 0;
211213
inz = 0;
212214
d[0] = 0.0; h = 1.0;
213215
for(k = 0, rowuk = u, rowukpi = upi; k < n-1; k++, rowuk++, rowukpi++){
@@ -312,7 +314,7 @@ void mexFunction(const int nlhs, mxArray *plhs[],
312314
{
313315
mxArray *myplhs[NPAROUT];
314316
mwIndex i,j,k, nk, nksqr, lenud, sdplen, gnnz, inz, maxKs,maxKssqr, rgnnz, hgnnz;
315-
const double *uOld, *permOld;
317+
const double *uOld, *permOld=NULL;
316318
double *u, *d, *gjcPr, *permPr, *fwork, *fworkpi;
317319
mwIndex *perm, *gjc;
318320
double *g, *gk;

0 commit comments

Comments
 (0)