From c43d0a148d0d19bcf2e01ef2547336364a1e5d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csan=C3=A1d=20Telbisz?= <56129746+csanadtelbisz@users.noreply.github.com> Date: Sun, 10 Sep 2023 23:18:14 +0200 Subject: [PATCH] resolve sonarcloud bugs --- .../bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt | 12 +++++++----- .../hu/bme/mit/theta/xcfa/passes/LoopUnrollPass.kt | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt index 8a0749a941..63f7a47d8b 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt @@ -258,7 +258,8 @@ open class XcfaDporLts(private val xcfa: XCFA) : LTS { val action = node.inEdge.get().action if (relevantProcesses.contains(action.pid)) { - if (newLastDependents.containsKey(action.pid) && index <= newLastDependents[action.pid]!!) { + if (newLastDependents.containsKey(action.pid) && index <= checkNotNull( + newLastDependents[action.pid])) { // there is an action a' such that action -> a' -> newaction (->: happens-before) relevantProcesses.remove(action.pid) } else if (dependent(newaction, action)) { @@ -277,7 +278,7 @@ open class XcfaDporLts(private val xcfa: XCFA) : LTS { newLastDependents[action.pid] = index newLastDependents = - max(newLastDependents, stack[index].lastDependents[action.pid]!!) + max(newLastDependents, checkNotNull(stack[index].lastDependents[action.pid])) relevantProcesses.remove(action.pid) } } @@ -442,9 +443,10 @@ open class XcfaDporLts(private val xcfa: XCFA) : LTS { */ private fun noInfluenceOnRealExploration(realStackSize: Int) = last.processLastAction.keys.all { process -> - last.lastDependents.containsKey(process) && last.lastDependents[process]!!.all { (_, index) -> - index >= realStackSize - } + last.lastDependents.containsKey(process) && + checkNotNull(last.lastDependents[process]).all { (_, index) -> + index >= realStackSize + } } } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LoopUnrollPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LoopUnrollPass.kt index 2c0c0a03a8..f8281e686a 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LoopUnrollPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LoopUnrollPass.kt @@ -99,13 +99,13 @@ class LoopUnrollPass : ProcedurePass { } loopEdges.forEach { - val newSource = if (it.source == loopStart) startLocation else locs[it.source]!! + val newSource = if (it.source == loopStart) startLocation else checkNotNull(locs[it.source]) val newLabel = if (it.source == loopStart) it.label.removeCondition() else it.label - val edge = XcfaEdge(newSource, locs[it.target]!!, newLabel, it.metadata) + val edge = XcfaEdge(newSource, checkNotNull(locs[it.target]!!), newLabel, it.metadata) builder.addEdge(edge) } - return locs[loopStart]!! + return checkNotNull(locs[loopStart]) } fun unroll(builder: XcfaProcedureBuilder, transFunc: ExplStmtTransFunc) {