Skip to content

Commit

Permalink
Merge branch 'v90_pclint_fixes' into 'v90-bugfix'
Browse files Browse the repository at this point in the history
several pclint fixes

See merge request integer/scip!3320
  • Loading branch information
pfetsch committed Feb 11, 2024
2 parents 767c69f + 3f986d1 commit 18864ac
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 85 deletions.
2 changes: 2 additions & 0 deletions pclint/scip.lnt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
-emacro(644,QUAD)
-emacro(647,QUAD_ARRAY_SIZE)
-emacro(665,QUAD)
-emacro(665,QUAD_MEMBER)
-emacro(666,SCIPquadprecProdQD)
-emacro(666,SCIPquadprecSumQD)

Expand Down Expand Up @@ -198,6 +199,7 @@
-emacro(776,SCIPduplicateBufferArray)
-emacro(776,SCIPallocClearBufferArray)
-emacro(776,SCIPallocBlockMemoryArray)
-emacro(776,SCIPallocClearBlockMemoryArray)
-emacro(776,SCIPduplicateBlockMemoryArray)
-emacro(776,BMSallocMemorySize)
-emacro(776,BMSallocBufferMemoryArray)
Expand Down
2 changes: 1 addition & 1 deletion src/scip/conflict_dualproofanalysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ SCIP_RETCODE tightenSingleVar(

SCIP_CALL( SCIPaddCoefLinear(set->scip, cons, var, 1.0) );

if( applyglobal )
if( applyglobal ) /*lint !e774*/
{
SCIP_CALL( SCIPprobAddCons(transprob, set, stat, cons) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/scip/cons_knapsack.c
Original file line number Diff line number Diff line change
Expand Up @@ -13281,7 +13281,7 @@ SCIP_DECL_CONSPARSE(consParseKnapsack)
/* try to parse coefficient, and use 1 if not successful */
weight = 1;
nread = 0;
sscanf(str, "%" SCIP_LONGINT_FORMAT "%n", &weight, &nread);
(void) sscanf(str, "%" SCIP_LONGINT_FORMAT "%n", &weight, &nread);
str += nread;

/* parse variable name */
Expand Down
2 changes: 1 addition & 1 deletion src/scip/cons_nonlinear.c
Original file line number Diff line number Diff line change
Expand Up @@ -10435,7 +10435,7 @@ SCIP_RETCODE addSymmetryInformation(
SCIP_EXPR** children;
int sumidx;
int optype;
int childidx = 0;
int childidx;

/* sums are handled by a special gadget */
usedefaultgadget = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/scip/heur_dps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ SCIP_DECL_EVENTEXEC(eventExecDps)
assert(event != NULL);
assert(SCIPeventGetType(event) & SCIP_EVENTTYPE_LPSOLVED);

SCIPdebugMsg(scip, "dual bound: %0.2f\n", SCIPgetDualbound(scip));
SCIPdebugMsg(scip, "dual bound: %.2f\n", SCIPgetDualbound(scip));

if( SCIPisFeasGT(scip, SCIPgetDualbound(scip), 0.0) && SCIPgetNSols(scip) >= 1 )
{
Expand Down
1 change: 1 addition & 0 deletions src/scip/nlhdlr_quadratic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ SCIP_Bool areCoefsNumericsGood(
{
max = 0.0;
min = SCIPinfinity(scip);
assert(coefs4b != NULL);
for( j = 0; j < 3; ++j )
{
SCIP_Real absval;
Expand Down
4 changes: 2 additions & 2 deletions src/scip/prop_symmetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -4278,7 +4278,7 @@ SCIP_RETCODE createConflictGraphSST(
assert( cliquevars != NULL );
assert( ncliquevars > 0 );

SCIPdebugMsg(scip, "\tIdentify edges for clique ID: %d; Index: %d).\n", SCIPcliqueGetId(clique),
SCIPdebugMsg(scip, "\tIdentify edges for clique ID: %u; Index: %d).\n", SCIPcliqueGetId(clique),
SCIPcliqueGetIndex(clique));

/* for all variables, list which cliques it is part of */
Expand Down Expand Up @@ -4321,7 +4321,7 @@ SCIP_RETCODE createConflictGraphSST(
assert( cliquevars != NULL );
assert( ncliquevars > 0 );

SCIPdebugMsg(scip, "\tAdd edges for clique ID: %d; Index: %d).\n", SCIPcliqueGetId(clique),
SCIPdebugMsg(scip, "\tAdd edges for clique ID: %u; Index: %d).\n", SCIPcliqueGetId(clique),
SCIPcliqueGetIndex(clique));

/* for all variables, list which cliques it is part of */
Expand Down
2 changes: 1 addition & 1 deletion src/scip/pub_implics.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ SCIP_Bool SCIPcliqueIsEquation(
#define SCIPcliqueGetVars(clique) ((clique)->vars)
#define SCIPcliqueGetValues(clique) ((clique)->values)
#define SCIPcliqueGetId(clique) ((clique)->id)
#define SCIPcliqueGetIndex(clique) ((clique)->index)
#define SCIPcliqueGetIndex(clique) ((clique)->index)
#define SCIPcliqueIsCleanedUp(clique) ((clique)->startcleanup == -1)
#define SCIPcliqueIsEquation(clique) ((SCIP_Bool)(clique)->equation)

Expand Down
12 changes: 12 additions & 0 deletions src/scip/rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ void rbRotate(
int dir /**< direction of rotation */
)
{
assert(x != NULL);

SCIP_RBTREENODE* p;
SCIP_RBTREENODE* y = x->child[OPPOSITE(dir)];

x->child[OPPOSITE(dir)] = y->child[dir];
if( y->child[dir] != NULL )
{
Expand Down Expand Up @@ -85,6 +88,8 @@ void rbInsertFixup(
SCIP_RBTREENODE* z /**< inserted node */
)
{
assert(z != NULL);

SCIP_RBTREENODE* p;
p = PARENT(z);

Expand All @@ -94,7 +99,9 @@ void rbInsertFixup(
SCIP_RBTREENODE* y;
int dir;

assert(p != NULL);
pp = PARENT(p);
assert(pp != NULL);
dir = p == pp->child[LEFT] ? RIGHT : LEFT;

y = pp->child[dir];
Expand All @@ -112,10 +119,13 @@ void rbInsertFixup(
z = p;
rbRotate(root, z, OPPOSITE(dir));
p = PARENT(z);
assert(p != NULL);
pp = PARENT(p);
}

assert(p != NULL);
MAKE_BLACK(p);
assert(pp != NULL);
MAKE_RED(pp);
rbRotate(root, pp, dir);
}
Expand All @@ -141,6 +151,7 @@ void rbDeleteFixup(
int dir;

p = PARENT(x == NULL ? nil : x);
assert(p != NULL);
dir = x == p->child[LEFT] ? RIGHT : LEFT;

w = p->child[dir];
Expand Down Expand Up @@ -171,6 +182,7 @@ void rbDeleteFixup(
assert(p == PARENT(x == NULL ? nil : x));
w = p->child[dir];
}
assert(w != NULL);
SET_COLOR(w, COLOR(p));
MAKE_BLACK(p);
MAKE_BLACK(w->child[dir]);
Expand Down
10 changes: 4 additions & 6 deletions src/scip/sepa_lagromory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,7 @@ void linfBallProjection(
* the terminology related to best Lagrangian multipliers)
*/
static
SCIP_RETCODE weightedDualVector(
SCIP* scip, /**< SCIP data structure */
void weightedDualVector(
SCIP_SEPADATA* sepadata, /**< separator data structure */
SCIP_Real* dualvector, /**< Lagrangian multipliers */
int dualvectorlen, /**< length of the Lagrangian multipliers vector */
Expand Down Expand Up @@ -1238,8 +1237,6 @@ SCIP_RETCODE weightedDualVector(
{
dualvector[i] = alpha * dualvector[i];
}

return SCIP_OKAY;
}

/** stabilize Lagrangian multipliers */
Expand Down Expand Up @@ -1296,8 +1293,7 @@ SCIP_RETCODE stabilizeDualVector(
if( sepadata->stabilitycentertype == 1 )
{
/* weighted Lagrangian multipliers based on best Langrangian multipliers as stability center */
SCIP_CALL( weightedDualVector(scip, sepadata, dualvector, dualvectorlen, bestdualvector,
bestdualvectorlen, nbestdualupdates, totaliternum) );
weightedDualVector(sepadata, dualvector, dualvectorlen, bestdualvector, bestdualvectorlen, nbestdualupdates, totaliternum);
}

return SCIP_OKAY;
Expand Down Expand Up @@ -1357,12 +1353,14 @@ SCIP_RETCODE updateDualVector(
/* update Lagrangian multipliers */
for( int i = 0; i < ncuts; i++ )
{
assert(subgradient != NULL); /* for lint */
dualvector1[i] += steplength * subgradient[i];
}

/* projection onto non-negative orthant */
for( int i = 0; i < ncuts; i++ )
{
assert(dualvector1 != NULL); /* for lint */
dualvector1[i] = MAX(dualvector1[i], 0.0);
}

Expand Down
64 changes: 32 additions & 32 deletions src/scip/symmetry_orbital.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,16 +767,16 @@ SCIP_RETCODE applyOrbitalBranchingPropagations(
assert( SCIPsymLE(scip, varlbs[varid], varubs[varid]) );
switch (update->boundchgtype)
{
case SCIP_BOUNDTYPE_LOWER:
assert( SCIPsymGE(scip, update->newbound, varlbs[varid]) );
varlbs[varid] = update->newbound;
break;
case SCIP_BOUNDTYPE_UPPER:
assert( SCIPsymLE(scip, update->newbound, varubs[varid]) );
varubs[varid] = update->newbound;
break;
default:
assert( FALSE );
case SCIP_BOUNDTYPE_LOWER:
assert( SCIPsymGE(scip, update->newbound, varlbs[varid]) );
varlbs[varid] = update->newbound;
break;
case SCIP_BOUNDTYPE_UPPER:
assert( SCIPsymLE(scip, update->newbound, varubs[varid]) );
varubs[varid] = update->newbound;
break;
default:
SCIPABORT();
}
assert( SCIPsymLE(scip, varlbs[varid], varubs[varid]) );
}
Expand Down Expand Up @@ -871,30 +871,30 @@ SCIP_RETCODE applyOrbitalBranchingPropagations(
assert( SCIPsymLE(scip, varlbs[branchingdecisionvarid], varubs[branchingdecisionvarid]) );
switch (branchingdecision->boundchgtype)
{
case SCIP_BOUNDTYPE_LOWER:
/* incompatible upper bound */
if ( SCIPsymGT(scip, branchingdecision->newbound, varubs[branchingdecisionvarid]) )
{
*infeasible = TRUE;
goto FREE;
}
case SCIP_BOUNDTYPE_LOWER:
/* incompatible upper bound */
if ( SCIPsymGT(scip, branchingdecision->newbound, varubs[branchingdecisionvarid]) )
{
*infeasible = TRUE;
goto FREE;
}

assert( SCIPsymLE(scip, varlbs[branchingdecisionvarid], branchingdecision->newbound) );
varlbs[branchingdecisionvarid] = branchingdecision->newbound;
break;
case SCIP_BOUNDTYPE_UPPER:
/* incompatible lower bound */
if ( SCIPsymLT(scip, branchingdecision->newbound, varlbs[branchingdecisionvarid]) )
{
*infeasible = TRUE;
goto FREE;
}
assert( SCIPsymLE(scip, varlbs[branchingdecisionvarid], branchingdecision->newbound) );
varlbs[branchingdecisionvarid] = branchingdecision->newbound;
break;
case SCIP_BOUNDTYPE_UPPER:
/* incompatible lower bound */
if ( SCIPsymLT(scip, branchingdecision->newbound, varlbs[branchingdecisionvarid]) )
{
*infeasible = TRUE;
goto FREE;
}

assert( SCIPsymGE(scip, varubs[branchingdecisionvarid], branchingdecision->newbound) );
varubs[branchingdecisionvarid] = branchingdecision->newbound;
break;
default:
assert( FALSE );
assert( SCIPsymGE(scip, varubs[branchingdecisionvarid], branchingdecision->newbound) );
varubs[branchingdecisionvarid] = branchingdecision->newbound;
break;
default:
SCIPABORT();
}

/* 3. propagate that branching variable is >= the variables in its orbit
Expand Down
45 changes: 21 additions & 24 deletions src/scip/symmetry_orbitopal.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,24 +379,24 @@ SCIP_RETCODE updateColumnOrderWhenBranchingOnColumn(
*/
switch (orbidata->columnordering)
{
case SCIP_COLUMNORDERING_FIRST:
/* only swap with c if c is earlier in column order than swaporigcolid */
if ( colorderinv[c] >= colorderinv[swaporigcolid] )
goto CONDITIONFAIL;
break;
case SCIP_COLUMNORDERING_LAST:
/* only swap with c if c is later in column order than swaporigcolid */
if ( colorderinv[c] <= colorderinv[swaporigcolid] )
goto CONDITIONFAIL;
break;
case SCIP_COLUMNORDERING_CENTRE:
/* if the column is not more central than swaporigcolid, ignore */
if ( ABS(colorderinv[c] - middlecolumn) >=
ABS(colorderinv[swaporigcolid] - middlecolumn) )
goto CONDITIONFAIL;
break;
default:
return SCIP_ERROR;
case SCIP_COLUMNORDERING_FIRST:
/* only swap with c if c is earlier in column order than swaporigcolid */
if ( colorderinv[c] >= colorderinv[swaporigcolid] )
continue;
break;
case SCIP_COLUMNORDERING_LAST:
/* only swap with c if c is later in column order than swaporigcolid */
if ( colorderinv[c] <= colorderinv[swaporigcolid] )
continue;
break;
case SCIP_COLUMNORDERING_CENTRE:
/* if the column is not more central than swaporigcolid, ignore */
if ( ABS(colorderinv[c] - middlecolumn) >=
ABS(colorderinv[swaporigcolid] - middlecolumn) )
continue;
break;
default:
return SCIP_ERROR;
}

/* test: are c and origcolid the same columns w.r.t. the variable domain restrictions? */
Expand All @@ -405,9 +405,6 @@ SCIP_RETCODE updateColumnOrderWhenBranchingOnColumn(

/* the variable domain reductions in c and origcolid are the same */
swaporigcolid = c;

CONDITIONFAIL:
; /* no-op for going to the next iteration */
}

/* end switch */
Expand Down Expand Up @@ -930,7 +927,7 @@ SCIP_DECL_EVENTEXEC(eventExecNodeBranched)
colorderinv, branchvars[i], &tmpcolswap) );

/* skip trivial swaps of columns */
if ( tmpcolswap.from == tmpcolswap.to )
if ( tmpcolswap.from == tmpcolswap.to ) /*lint !e644*/
continue;

/* mark that this row index is the new one in the node */
Expand All @@ -946,8 +943,8 @@ SCIP_DECL_EVENTEXEC(eventExecNodeBranched)
newnodeinfo->ncolswaps + 1) );
}
thiscolswap = &(newnodeinfo->colswaps[newnodeinfo->ncolswaps++]);
thiscolswap->from = tmpcolswap.from;
thiscolswap->to = tmpcolswap.to;
thiscolswap->from = tmpcolswap.from; /*lint !e644*/
thiscolswap->to = tmpcolswap.to; /*lint !e644*/
}

SCIPfreeBufferArray(scip, &colorder);
Expand Down
Loading

0 comments on commit 18864ac

Please sign in to comment.