diff --git a/Makefile b/Makefile index 2584671225..1b407e165f 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 ; \ @@ -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 ; \ @@ -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;' diff --git a/pclint/scip.lnt b/pclint/scip.lnt index 6684f4d157..6162ad0088 100644 --- a/pclint/scip.lnt +++ b/pclint/scip.lnt @@ -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 diff --git a/src/scip/cons_benders.c b/src/scip/cons_benders.c index 801d496b2b..a5b9e0ae2b 100644 --- a/src/scip/cons_benders.c +++ b/src/scip/cons_benders.c @@ -556,7 +556,6 @@ SCIP_DECL_CONSCHECK(consCheckBenders) int solindex; int i; SCIP_Bool performcheck; - SCIP_Bool infeasible; SCIP_Bool auxviol; assert(scip != NULL); @@ -565,7 +564,6 @@ SCIP_DECL_CONSCHECK(consCheckBenders) (*result) = SCIP_FEASIBLE; performcheck = TRUE; - infeasible = FALSE; auxviol = FALSE; conshdlrdata = SCIPconshdlrGetData(conshdlr); @@ -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) ); } diff --git a/src/scip/cons_fixedvar.c b/src/scip/cons_fixedvar.c index bba201dcf0..55d9545da5 100644 --- a/src/scip/cons_fixedvar.c +++ b/src/scip/cons_fixedvar.c @@ -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 * diff --git a/src/scip/heur_alns.c b/src/scip/heur_alns.c index 09a4da8ac0..7eb2c1113b 100644 --- a/src/scip/heur_alns.c +++ b/src/scip/heur_alns.c @@ -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 }; /* diff --git a/src/scip/hypergraph.c b/src/scip/hypergraph.c index 6309f46b71..126aeb971b 100644 --- a/src/scip/hypergraph.c +++ b/src/scip/hypergraph.c @@ -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); } @@ -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 ) { @@ -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); @@ -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++; @@ -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; @@ -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 */ @@ -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 */ @@ -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 */ diff --git a/src/scip/network.c b/src/scip/network.c index ac07a3dfaa..1a88fbd201 100644 --- a/src/scip/network.c +++ b/src/scip/network.c @@ -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); @@ -4465,7 +4467,8 @@ void determineSingleComponentType( } case SPQR_MEMBERTYPE_UNASSIGNED: { - assert(FALSE); + SCIPABORT(); + newCol->reducedMembers[reducedMember].type = REDUCEDMEMBER_TYPE_NOT_NETWORK; break; } } @@ -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; @@ -5047,7 +5048,7 @@ void determinePathMemberType( { //In release newCol->remainsNetwork = FALSE; - assert(FALSE); + SCIPABORT(); break; } } @@ -5271,7 +5272,8 @@ ReducedMemberType checkLeaf( } case SPQR_MEMBERTYPE_UNASSIGNED: { - assert(FALSE); + SCIPABORT(); + newCol->reducedMembers[leaf].type = REDUCEDMEMBER_TYPE_NOT_NETWORK; break; } } @@ -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; @@ -6637,8 +6639,8 @@ SCIP_RETCODE transformComponent( case SPQR_MEMBERTYPE_UNASSIGNED: default: { - assert(FALSE); - break; + SCIPABORT(); + return SCIP_ERROR; } } return SCIP_OKAY; @@ -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; @@ -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; @@ -9485,7 +9487,7 @@ void determineSplitTypeNext( case SPQR_MEMBERTYPE_UNASSIGNED: default: newRow->remainsNetwork = FALSE; - assert(FALSE); + SCIPABORT(); } } @@ -9519,7 +9521,7 @@ void determineMergeableTypes( case SPQR_MEMBERTYPE_UNASSIGNED: default: newRow->remainsNetwork = FALSE; - assert(FALSE); + SCIPABORT(); } } return; @@ -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; } @@ -11248,8 +11253,10 @@ SCIP_RETCODE transformComponentRowAddition( } case SPQR_MEMBERTYPE_UNASSIGNED: default: - assert(FALSE); - break; + { + SCIPABORT(); + return SCIP_ERROR; + } } return SCIP_OKAY; diff --git a/src/scip/reader_opb.c b/src/scip/reader_opb.c index 0c6208d00a..6aec06fff1 100644 --- a/src/scip/reader_opb.c +++ b/src/scip/reader_opb.c @@ -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) ); diff --git a/src/scip/sepa_multilinear.c b/src/scip/sepa_multilinear.c index f074d010f7..185200b626 100644 --- a/src/scip/sepa_multilinear.c +++ b/src/scip/sepa_multilinear.c @@ -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) ) { diff --git a/src/tinycthread/tinycthread.c b/src/tinycthread/tinycthread.c index 195e413fe3..7d87e56148 100644 --- a/src/tinycthread/tinycthread.c +++ b/src/tinycthread/tinycthread.c @@ -41,12 +41,14 @@ freely, subject to the following restrictions: #ifndef NULL #define NULL (void*)0 #endif +#if defined(_TTHREAD_WIN32_) #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif +#endif #ifdef __cplusplus extern "C" { @@ -75,13 +77,13 @@ int mtx_init(mtx_t *mtx, int type) #else int ret; pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); + (void) pthread_mutexattr_init(&attr); if (type & mtx_recursive) { - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + (void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); } ret = pthread_mutex_init(mtx, &attr); - pthread_mutexattr_destroy(&attr); + (void) pthread_mutexattr_destroy(&attr); return ret == 0 ? thrd_success : thrd_error; #endif } @@ -98,7 +100,7 @@ void mtx_destroy(mtx_t *mtx) CloseHandle(mtx->mHandle.mut); } #else - pthread_mutex_destroy(mtx); + (void) pthread_mutex_destroy(mtx); #endif } @@ -128,7 +130,7 @@ int mtx_lock(mtx_t *mtx) } return thrd_success; #else - return pthread_mutex_lock(mtx) == 0 ? thrd_success : thrd_error; + return pthread_mutex_lock(mtx) == 0 ? thrd_success : thrd_error; /*lint !e454*/ #endif } @@ -276,7 +278,7 @@ int mtx_unlock(mtx_t *mtx) } return thrd_success; #else - return pthread_mutex_unlock(mtx) == 0 ? thrd_success : thrd_error;; + return pthread_mutex_unlock(mtx) == 0 ? thrd_success : thrd_error; /*lint !e455*/ #endif } @@ -327,7 +329,7 @@ void cnd_destroy(cnd_t *cond) } DeleteCriticalSection(&cond->mWaitersCountLock); #else - pthread_cond_destroy(cond); + (void) pthread_cond_destroy(cond); #endif } @@ -617,7 +619,7 @@ int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) return thrd_error; } - return thrd_success; + return thrd_success; /*lint !e429*/ } thrd_t thrd_current(void) @@ -743,7 +745,7 @@ void thrd_yield(void) #if defined(_TTHREAD_WIN32_) Sleep(0); #else - sched_yield(); + (void) sched_yield(); #endif } @@ -798,7 +800,7 @@ void tss_delete(tss_t key) _tinycthread_tss_dtors[key] = NULL; TlsFree(key); #else - pthread_key_delete(key); + (void) pthread_key_delete(key); #endif }