Skip to content

Commit 97007bc

Browse files
committed
Further cleanup
1 parent d09340b commit 97007bc

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Diff for: lib/Echidna/Exec.hs

+4-6
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,9 @@ execTxWithCov tx = do
296296
if size == 0 then pure Nothing else do
297297
-- IO for making a new vec
298298
vec <- VMut.new size
299-
-- We use -1 for opIx to indicate that the location was not covered
300299
forM_ [0..size-1] $ \i -> VMut.write vec i (0, 0)
301300
pure $ Just vec
302-
301+
303302
case maybeCovVec of
304303
Nothing -> pure ()
305304
Just vec -> do
@@ -308,14 +307,13 @@ execTxWithCov tx = do
308307
-- bug in another place, investigate.
309308
-- ... this should be fixed now, since we use `codeContract` instead
310309
-- of `contract` for everything; it may be safe to remove this check.
311-
when (pc < VMut.length vec) $
310+
when (pc < VMut.length vec) $ do
311+
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx
312312
VMut.read vec pc >>= \case
313313
(_, depths, results) | depth < 64 && not (depths `testBit` depth) -> do
314314
VMut.write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop)
315-
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx
316315
writeIORef covContextRef (True, Just (vec, pc))
317-
(opIx', depths, results) -> do
318-
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx'
316+
_ -> do
319317
modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc))
320318

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

Diff for: 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)