Skip to content

Commit

Permalink
Merge branch 'fix_current_pclint_warnings' into 'master'
Browse files Browse the repository at this point in the history
Fix current pclint warnings

See merge request integer/scip!3606
  • Loading branch information
pfetsch committed Dec 2, 2024
2 parents 1cc8137 + 87db108 commit 346ad2f
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 53 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ ifeq ($(SYM),none)
SYMOBJ = symmetry/compute_symmetry_none.o
SYMOBJFILES = $(addprefix $(LIBOBJDIR)/,$(SYMOBJ))
SYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
LINTSYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
ALLSRC += $(SYMSRC)
endif

Expand All @@ -343,6 +344,7 @@ ifeq ($(SYM),bliss)
SYMOBJ = symmetry/compute_symmetry_bliss.o
SYMOBJFILES = $(addprefix $(LIBOBJDIR)/,$(SYMOBJ))
SYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
LINTSYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
FLAGS += -I$(LIBDIR)/include/
ALLSRC += $(SYMSRC)
SOFTLINKS += $(LIBDIR)/include/bliss
Expand All @@ -362,6 +364,7 @@ SYMOBJ = symmetry/build_sassy_graph.o
SYMOBJ += symmetry/compute_symmetry_sassy_bliss.o
SYMOBJFILES = $(addprefix $(LIBOBJDIR)/,$(SYMOBJ))
SYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
LINTSYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
FLAGS += -I$(LIBDIR)/include/
ALLSRC += $(SYMSRC)
CXXFLAGS += $(CXX17FLAG)
Expand All @@ -381,6 +384,7 @@ ifeq ($(SYM),nauty)
SYMOBJ = symmetry/compute_symmetry_nauty.o
SYMOBJFILES = $(addprefix $(LIBOBJDIR)/,$(SYMOBJ))
SYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.c))
LINTSYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.c))
ifeq ($(NAUTYEXTERNAL),false)
FLAGS += -I$(SRCDIR)/nauty/src -I$(SRCDIR)/nauty/include
LIBOBJSUBDIRS += $(LIBOBJDIR)/nauty
Expand Down Expand Up @@ -411,6 +415,7 @@ SYMOBJ = symmetry/build_sassy_graph.o
SYMOBJ += symmetry/compute_symmetry_sassy_nauty.o
SYMOBJFILES = $(addprefix $(LIBOBJDIR)/,$(SYMOBJ))
SYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
LINTSYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
ifeq ($(NAUTYEXTERNAL),false)
FLAGS += -I$(SRCDIR)/nauty/src -I$(SRCDIR)/nauty/include
LIBOBJSUBDIRS += $(LIBOBJDIR)/nauty
Expand Down Expand Up @@ -1079,7 +1084,7 @@ preprocess: checkdefines
@$(MAKE) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE)

.PHONY: lint
lint: $(SCIPLIBBASESRC) $(OBJSCIPLIBSRC) $(LPILIBSRC) $(TPILIBSRC) $(MAINSRC) $(SYMSRC) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE) $(SCIPBUILDFLAGSFILE) githash
lint: $(SCIPLIBBASESRC) $(OBJSCIPLIBSRC) $(LPILIBSRC) $(TPILIBSRC) $(MAINSRC) $(LINTSYMSRC) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE) $(SCIPBUILDFLAGSFILE) githash
-rm -f lint.out

@$(SHELL) -ec 'if test -e lint/co-gcc.mak ; \
Expand All @@ -1106,7 +1111,7 @@ else
endif

.PHONY: pclint
pclint: $(SCIPLIBBASESRC) $(OBJSCIPLIBSRC) $(LPILIBSRC) $(TPILIBSRC) $(MAINSRC) $(SYMSRC) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE) $(SCIPBUILDFLAGSFILE)
pclint: $(SCIPLIBBASESRC) $(OBJSCIPLIBSRC) $(LPILIBSRC) $(TPILIBSRC) $(MAINSRC) $(LINTSYMSRC) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE) $(SCIPBUILDFLAGSFILE)
-rm -f pclint.out

@$(SHELL) -ec 'if ! test -e pclint/co-gcc.h ; \
Expand All @@ -1129,7 +1134,7 @@ else
endif

.PHONY: splint
splint: $(SCIPLIBBASESRC) $(OBJSCIPLIBSRC) $(LPILIBSRC) $(TPILIBSRC) $(MAINSRC) $(SYMSRC) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE) $(SCIPBUILDFLAGSFILE)
splint: $(SCIPLIBBASESRC) $(OBJSCIPLIBSRC) $(LPILIBSRC) $(TPILIBSRC) $(MAINSRC) $(LINTSYMSRC) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE) $(SCIPBUILDFLAGSFILE)
-rm -f splint.out
ifeq ($(FILES),)
$(SHELL) -c '$(SPLINT) -I$(SRCDIR) -I/usr/include/linux $(FLAGS) $(SPLINTFLAGS) $(filter %.c %.h,$^) >> splint.out;'
Expand Down
1 change: 1 addition & 0 deletions pclint/scip.lnt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
-e1784 // symbol previously declared as "C" [only for information, but clutters output]]
-e2666 // expression with side effects passed to unexpanded parameter: parameter is not referenced in the expansion
-e2704 // potentially negating the most negative number [often if x = -y, and y is int, only relevant if y = INT_MAX]
-e2751 // indeterminable mutex

// for the time being turn off warning 666 (expression with side effects passed to repeated parameter of macro), since it currently produces too much noise
-e666
Expand Down
6 changes: 3 additions & 3 deletions src/scip/cons_benders.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ SCIP_DECL_CONSCHECK(consCheckBenders)
int solindex;
int i;
SCIP_Bool performcheck;
SCIP_Bool infeasible;
SCIP_Bool auxviol;

assert(scip != NULL);
Expand All @@ -565,7 +564,6 @@ SCIP_DECL_CONSCHECK(consCheckBenders)

(*result) = SCIP_FEASIBLE;
performcheck = TRUE;
infeasible = FALSE;
auxviol = FALSE;

conshdlrdata = SCIPconshdlrGetData(conshdlr);
Expand Down Expand Up @@ -600,11 +598,13 @@ SCIP_DECL_CONSCHECK(consCheckBenders)
*/
if( SCIPbendersSubproblemsAreInfeasible(benders[i]) )
{
infeasible = TRUE;
(*result) = SCIP_INFEASIBLE;
}
else
{
SCIP_Bool infeasible;
infeasible = FALSE;

SCIP_CALL( SCIPsolveBendersSubproblems(scip, benders[i], sol, result, &infeasible, &auxviol,
SCIP_BENDERSENFOTYPE_CHECK, TRUE) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/scip/cons_fixedvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct SCIP_ConshdlrData
* above the feasibility tolerance by aggregation factors. Usually, the violation should still be
* rather "small". For this test, we quantify "small" as 0.5.
*/
#define assertSmallViolation(lb, val, ub) (assert((val) >= (lb) - 0.5 && (val) <= (ub) + 0.5));
#define assertSmallViolation(lb, val, ub) (assert((val) >= (lb) - 0.5 && (val) <= (ub) + 0.5))

/** add cut to enforce global bounds on variable aggregation
*
Expand Down
13 changes: 7 additions & 6 deletions src/scip/heur_alns.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,13 @@
#define TABLE_EARLIEST_STAGE_NEIGHBORHOOD SCIP_STAGE_TRANSFORMED /**< output of the statistics table is only printed from this stage onwards */

/** reward types of ALNS */
enum RewardType {
REWARDTYPE_TOTAL, /**< combination of the other rewards */
REWARDTYPE_BESTSOL, /**< 1, if a new solution was found, 0 otherwise */
REWARDTYPE_CLOSEDGAP, /**< 0 if no solution was found, closed gap otherwise */
REWARDTYPE_NOSOLPENALTY, /**< 1 if a solution was found, otherwise between 0 and 1 depending on the effort spent */
NREWARDTYPES
enum RewardType /*lint !e753*/
{
REWARDTYPE_TOTAL = 0, /**< combination of the other rewards */
REWARDTYPE_BESTSOL = 1, /**< 1, if a new solution was found, 0 otherwise */
REWARDTYPE_CLOSEDGAP = 2, /**< 0 if no solution was found, closed gap otherwise */
REWARDTYPE_NOSOLPENALTY = 3, /**< 1 if a solution was found, otherwise between 0 and 1 depending on the effort spent */
NREWARDTYPES = 4
};

/*
Expand Down
23 changes: 14 additions & 9 deletions src/scip/hypergraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ SCIP_RETCODE ensureNumVertices(
while( newcapacity < required )
newcapacity *= 2;

assert( hypergraph->memvertices >= 0 );
SCIP_ALLOC( BMSreallocBlockMemoryArray(hypergraph->blkmem, &hypergraph->verticesdata,
hypergraph->memvertices * hypergraph->sizevertexdata / sizeof(*(hypergraph->verticesdata)),
newcapacity * hypergraph->sizevertexdata / sizeof(*(hypergraph->verticesdata))) );
newcapacity * hypergraph->sizevertexdata / sizeof(*(hypergraph->verticesdata))) ); /*lint --e{737}*/
hypergraph->memvertices = newcapacity;
SCIPdebugMessage("ensuring memory for %d vertices.\n", newcapacity);
}
Expand All @@ -84,9 +85,10 @@ SCIP_RETCODE ensureNumEdges(
while( newcapacity < required )
newcapacity *= 2;

assert( hypergraph->memedges >= 0 );
SCIP_ALLOC( BMSreallocBlockMemoryArray(hypergraph->blkmem, &hypergraph->edgesdata,
hypergraph->memedges * hypergraph->sizeedgedata / sizeof(*(hypergraph->edgesdata)),
newcapacity * hypergraph->sizeedgedata / sizeof(*(hypergraph->edgesdata))) );
newcapacity * hypergraph->sizeedgedata / sizeof(*(hypergraph->edgesdata))) ); /*lint --e{737}*/

if( hypergraph->edgesverticesbeg )
{
Expand Down Expand Up @@ -161,14 +163,15 @@ SCIP_RETCODE ensureNumOverlaps(
}
if( hypergraph->overlapsdata )
{
assert( hypergraph->memoverlaps >= 0 );
SCIP_ALLOC( BMSreallocBlockMemoryArray(hypergraph->blkmem, &hypergraph->overlapsdata,
hypergraph->memoverlaps * hypergraph->sizeoverlapdata / sizeof(*(hypergraph->overlapsdata)),
newcapacity * hypergraph->sizeoverlapdata / sizeof(*(hypergraph->overlapsdata))) );
newcapacity * hypergraph->sizeoverlapdata / sizeof(*(hypergraph->overlapsdata))) ); /*lint --e{737}*/
}
else
{
SCIP_ALLOC( BMSallocBlockMemoryArray(hypergraph->blkmem, &hypergraph->overlapsdata,
newcapacity * hypergraph->sizeoverlapdata / sizeof(*(hypergraph->overlapsdata))) );
newcapacity * hypergraph->sizeoverlapdata / sizeof(*(hypergraph->overlapsdata))) ); /*lint --e{737}*/
}
hypergraph->memoverlaps = newcapacity;
SCIPdebugMessage("ensuring memory for %d overlaps.\n", newcapacity);
Expand Down Expand Up @@ -394,8 +397,9 @@ SCIP_RETCODE SCIPhypergraphAddVertex(
*pvertex = hypergraph->nvertices;
if( pvertexdata != NULL )
{
assert( hypergraph->nvertices >= 0 );
*pvertexdata = (SCIP_HYPERGRAPH_VERTEXDATA*)(hypergraph->verticesdata
+ hypergraph->nvertices * hypergraph->sizevertexdata / sizeof(*(hypergraph->verticesdata)) );
+ hypergraph->nvertices * hypergraph->sizevertexdata / sizeof(*(hypergraph->verticesdata)) ); /*lint --e{737}*/
}

hypergraph->nvertices++;
Expand Down Expand Up @@ -437,8 +441,9 @@ SCIP_RETCODE SCIPhypergraphAddEdge(
*pedge = hypergraph->nedges;
if( pedgedata != NULL )
{
assert( hypergraph->nedges >= 0 );
*pedgedata = (SCIP_HYPERGRAPH_EDGEDATA*)(hypergraph->edgesdata +
hypergraph->nedges * hypergraph->sizeedgedata / sizeof(*(hypergraph->edgesdata)));
hypergraph->nedges * hypergraph->sizeedgedata / sizeof(*(hypergraph->edgesdata))); /*lint --e{737}*/
}
hypergraph->nedges++;
hypergraph->hasvertexedges = FALSE;
Expand Down Expand Up @@ -1814,7 +1819,7 @@ SCIP_HYPERGRAPH_VERTEXDATA* SCIPhypergraphVertexData(
assert(hypergraph != NULL);

return (SCIP_HYPERGRAPH_VERTEXDATA*)(hypergraph->verticesdata
+ vertex * hypergraph->sizevertexdata / sizeof(*(hypergraph->verticesdata)));
+ vertex * hypergraph->sizevertexdata / sizeof(*(hypergraph->verticesdata))); /*lint --e{737}*/
}

/** @brief returns additional data of \p edge */
Expand All @@ -1826,7 +1831,7 @@ SCIP_HYPERGRAPH_EDGEDATA* SCIPhypergraphEdgeData(
assert(hypergraph != NULL);

return (SCIP_HYPERGRAPH_EDGEDATA*)(hypergraph->edgesdata
+ edge * hypergraph->sizeedgedata / sizeof(*(hypergraph->edgesdata)));
+ edge * hypergraph->sizeedgedata / sizeof(*(hypergraph->edgesdata))); /*lint --e{737}*/
}

/** @brief returns additional data of \p overlap */
Expand All @@ -1838,7 +1843,7 @@ SCIP_HYPERGRAPH_OVERLAPDATA* SCIPhypergraphOverlapData(
assert(hypergraph != NULL);

return (SCIP_HYPERGRAPH_OVERLAPDATA*)(hypergraph->overlapsdata
+ overlap * hypergraph->sizeoverlapdata / sizeof(*(hypergraph->overlapsdata)));
+ overlap * hypergraph->sizeoverlapdata / sizeof(*(hypergraph->overlapsdata))); /*lint --e{737}*/
}

/** @brief returns the number of vertices of \p edge */
Expand Down
47 changes: 27 additions & 20 deletions src/scip/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -2416,8 +2416,10 @@ int decompositionGetFundamentalCycleRows(
}
break;
}
case SPQR_MEMBERTYPE_UNASSIGNED:
assert(FALSE);
case SPQR_MEMBERTYPE_UNASSIGNED:{
SCIPABORT();
return -1;
}
}
}
BMSfreeBlockMemoryArray(dec->env, &pathSearchCallStack, dec->numNodes);
Expand Down Expand Up @@ -4465,7 +4467,8 @@ void determineSingleComponentType(
}
case SPQR_MEMBERTYPE_UNASSIGNED:
{
assert(FALSE);
SCIPABORT();
newCol->reducedMembers[reducedMember].type = REDUCEDMEMBER_TYPE_NOT_NETWORK;
break;
}
}
Expand Down Expand Up @@ -4574,14 +4577,12 @@ void determinePathSeriesType(
break;
}
case OUT_TAIL:
default:
{
assert(previousType == OUT_TAIL);
currentType = inSameDirection ? OUT_HEAD : OUT_TAIL;
break;
}
default:
{
assert(FALSE);
}
}
redMem->pathType = currentType;
return;
Expand Down Expand Up @@ -5047,7 +5048,7 @@ void determinePathMemberType(
{
//In release
newCol->remainsNetwork = FALSE;
assert(FALSE);
SCIPABORT();
break;
}
}
Expand Down Expand Up @@ -5271,7 +5272,8 @@ ReducedMemberType checkLeaf(
}
case SPQR_MEMBERTYPE_UNASSIGNED:
{
assert(FALSE);
SCIPABORT();
newCol->reducedMembers[leaf].type = REDUCEDMEMBER_TYPE_NOT_NETWORK;
break;
}
}
Expand Down Expand Up @@ -6372,8 +6374,8 @@ SCIP_RETCODE transformAndMerge(
case SPQR_MEMBERTYPE_LOOP:
case SPQR_MEMBERTYPE_UNASSIGNED:
{
assert(FALSE);
break;
SCIPABORT();
return SCIP_ERROR;
}
}
return SCIP_OKAY;
Expand Down Expand Up @@ -6637,8 +6639,8 @@ SCIP_RETCODE transformComponent(
case SPQR_MEMBERTYPE_UNASSIGNED:
default:
{
assert(FALSE);
break;
SCIPABORT();
return SCIP_ERROR;
}
}
return SCIP_OKAY;
Expand Down Expand Up @@ -8574,7 +8576,7 @@ RowReducedMemberType determineType(
case SPQR_MEMBERTYPE_UNASSIGNED:
default:
newRow->reducedMembers[toCheckMember].type = TYPE_NOT_NETWORK;
assert(FALSE);
SCIPABORT();
}

return newRow->reducedMembers[toCheckMember].type;
Expand Down Expand Up @@ -9211,7 +9213,7 @@ SplitOrientation getRelativeOrientation(
case SPQR_MEMBERTYPE_UNASSIGNED:
default:
{
assert(FALSE);
SCIPABORT();
SplitOrientation orientation; /*lint !e527*/
orientation.headSplit = FALSE; /*lint !e527*/
orientation.otherIsSource = FALSE;
Expand Down Expand Up @@ -9485,7 +9487,7 @@ void determineSplitTypeNext(
case SPQR_MEMBERTYPE_UNASSIGNED:
default:
newRow->remainsNetwork = FALSE;
assert(FALSE);
SCIPABORT();
}
}

Expand Down Expand Up @@ -9519,7 +9521,7 @@ void determineMergeableTypes(
case SPQR_MEMBERTYPE_UNASSIGNED:
default:
newRow->remainsNetwork = FALSE;
assert(FALSE);
SCIPABORT();
}
}
return;
Expand Down Expand Up @@ -11117,8 +11119,11 @@ SCIP_RETCODE splitAndMerge(
case SPQR_MEMBERTYPE_LOOP:
case SPQR_MEMBERTYPE_UNASSIGNED:
default:
{
newRow->remainsNetwork = FALSE;
assert(FALSE);
SCIPABORT();
return SCIP_ERROR;
}
}
return SCIP_OKAY;
}
Expand Down Expand Up @@ -11248,8 +11253,10 @@ SCIP_RETCODE transformComponentRowAddition(
}
case SPQR_MEMBERTYPE_UNASSIGNED:
default:
assert(FALSE);
break;
{
SCIPABORT();
return SCIP_ERROR;
}
}

return SCIP_OKAY;
Expand Down
2 changes: 2 additions & 0 deletions src/scip/reader_opb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4014,6 +4014,8 @@ SCIP_RETCODE SCIPwriteOpb(
SCIP_CONSHDLR* indicatorhdlr = SCIPfindConshdlr(scip, "indicator");
int nindicatorconss = indicatorhdlr != NULL ? SCIPconshdlrGetNConss(indicatorhdlr) : 0;

assert( nbinvars >= 0 );

/* computes all and-resultants and their corresponding constraint variables */
/* coverity[leaked_storage] */
SCIP_CALL( computeAndConstraintInfos(scip, transformed, &resvars, &nresvars, &andvars, &nandvars, &existandconshdlr, &existands) );
Expand Down
2 changes: 1 addition & 1 deletion src/scip/sepa_multilinear.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ SCIP_RETCODE constructHypergraph(

/* Iterate through all expressions of the nonlinear constraint that we haven't seen so far. */
expr = SCIPgetExprNonlinear(conss[c]);
for( expr = SCIPexpriterRestartDFS(it, expr); !SCIPexpriterIsEnd(it); expr = SCIPexpriterGetNext(it) ) /*lint !e441 */
for( expr = SCIPexpriterRestartDFS(it, expr); !SCIPexpriterIsEnd(it); expr = SCIPexpriterGetNext(it) ) /*lint !e441 *//*lint !e440 */
{
if( SCIPisExprProduct(scip, expr) )
{
Expand Down
Loading

0 comments on commit 346ad2f

Please sign in to comment.