Skip to content

Commit 6e46d86

Browse files
committed
Further cleanup
1 parent b5b724c commit 6e46d86

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/Echidna/Exec.hs

+4-6
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,9 @@ execTxWithCov tx = do
303303
if size == 0 then pure Nothing else do
304304
-- IO for making a new vec
305305
vec <- VMut.new size
306-
-- We use -1 for opIx to indicate that the location was not covered
307306
forM_ [0..size-1] $ \i -> VMut.write vec i (0, 0)
308307
pure $ Just vec
309-
308+
310309
case maybeCovVec of
311310
Nothing -> pure ()
312311
Just vec -> do
@@ -315,14 +314,13 @@ execTxWithCov tx = do
315314
-- bug in another place, investigate.
316315
-- ... this should be fixed now, since we use `codeContract` instead
317316
-- of `contract` for everything; it may be safe to remove this check.
318-
when (pc < VMut.length vec) $
317+
when (pc < VMut.length vec) $ do
318+
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx
319319
VMut.read vec pc >>= \case
320320
(_, depths, results) | depth < 64 && not (depths `testBit` depth) -> do
321321
VMut.write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop)
322-
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx
323322
writeIORef covContextRef (True, Just (vec, pc))
324-
(opIx', depths, results) -> do
325-
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx'
323+
_ -> do
326324
modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc))
327325

328326
-- | Get the VM's current execution location

lib/Echidna/Output/Source.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ srcMapCov sc covMap statMap contracts = do
199199
updateLine (Just (r, q)) = Just ((<> unpackTxResults txResults) r, max q execQty)
200200
updateLine Nothing = Just (unpackTxResults txResults, execQty)
201201
fileStats = Map.lookup c.runtimeCodehash statMap
202-
idxStats | isJust fileStats = (fromJust fileStats) U.! opIx :: StatsInfo
203-
| otherwise = (fromInteger 0, fromInteger 0) :: StatsInfo
202+
idxStats | isJust fileStats = (fromJust fileStats) U.! opIx
203+
| otherwise = (fromInteger 0, fromInteger 0)
204204
execQty = fst idxStats
205205
Nothing -> acc
206206
Nothing -> acc

0 commit comments

Comments
 (0)