Skip to content

Commit

Permalink
Merge pull request #43 from GaloisInc/vr/hlint
Browse files Browse the repository at this point in the history
address reasonable Hlint suggestions
  • Loading branch information
Ptival authored Jan 18, 2024
2 parents 3679829 + e67fd70 commit 12b6254
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Data/ElfEdit/HighLevel/Get.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ transShdr file strtab idx shdr = do
, elfSectionEntSize = shdrEntSize shdr
, elfSectionData = slice (shdrFileRange shdr) file
}
seq s $ pure $ (shdrFileRange shdr, s)
seq s $ pure (shdrFileRange shdr, s)

-- | Get list of sections from Elf parse info.
-- This includes the initial section
Expand Down Expand Up @@ -176,7 +176,7 @@ errorPair c =

-- | Add a warning to get result
warn :: ElfParseError -> GetResult ()
warn e = seq e $ GetResult $ MTL.modify' $ (e:)
warn e = seq e $ GetResult $ MTL.modify' (e:)

------------------------------------------------------------------------
-- CollectedRegion
Expand All @@ -185,7 +185,7 @@ warn e = seq e $ GetResult $ MTL.modify' $ (e:)
data CollectedRegion w
= AtomicRegion !B.ByteString !(FileOffset (ElfWordType w)) !(FileOffset (ElfWordType w)) !(ElfDataRegion w)
-- ^ A region with the name, start offset, one past the end, and contents.
| SegmentRegion !(Phdr w) !([CollectedRegion w])
| SegmentRegion !(Phdr w) ![CollectedRegion w]
-- ^ A Program header and additional regions.

-- | Return the starting offset of the region
Expand Down Expand Up @@ -582,8 +582,8 @@ getElf ehi = elfClassInstances (headerClass (header ehi)) $ errorPair $ do
-- parseElf

data ElfGetResult
= Elf32Res !([ElfParseError]) (Elf 32)
| Elf64Res !([ElfParseError]) (Elf 64)
= Elf32Res ![ElfParseError] (Elf 32)
| Elf64Res ![ElfParseError] (Elf 64)
| ElfHeaderError !Get.ByteOffset !String
-- ^ Attempt to parse header failed.
--
Expand Down
10 changes: 5 additions & 5 deletions src/Data/ElfEdit/HighLevel/Layout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ updateSegments fn = elfFileData (updateSeq impl)
let inner = updateSeq impl (elfSegmentData seg)
updateData s d = s { elfSegmentData = d }
newSeg :: f (Maybe (ElfSegment w))
newSeg = fn =<< (fmap (updateData seg) inner)
newSeg = (fn . updateData seg) =<< inner
in fmap ElfDataSegment <$> newSeg
impl d = pure (Just d)

Expand All @@ -74,7 +74,7 @@ updateDataRegions fn = elfFileData (updateSeq impl)
impl (ElfDataSegment seg) =
let inner = updateSeq impl (elfSegmentData seg)
updateData s d = s { elfSegmentData = d }
in fmap (updateData seg) inner >>= (fn . ElfDataSegment)
in (fn . ElfDataSegment . updateData seg) =<< inner
impl d = fn d

-- | Traverse all data regions including nested.
Expand Down Expand Up @@ -416,7 +416,7 @@ gnuRelroPhdr r foff =

addRelroToLayout :: ElfLayout w -> GnuRelroRegion w -> ElfLayout w
addRelroToLayout l r
| otherwise = elfClassInstances (elfLayoutClass l) $ do
= elfClassInstances (elfLayoutClass l) $ do
let refIdx = relroRefSegmentIndex r
case Map.lookup refIdx (l^.phdrs) of
Nothing -> error $ "Error segment index " ++ show refIdx ++ " could not be found."
Expand Down Expand Up @@ -470,7 +470,7 @@ buildRegions l o ((reg,inLoad):rest) = do
<> doRest (fromIntegral (ehdrSize cl))
ElfDataSegmentHeaders
| not (isAligned o (phdrTableAlign cl)) ->
error $ "internal error: buildRegions phdr alignment check failed; Fix layoutRegion."
error "internal error: buildRegions phdr alignment check failed; Fix layoutRegion."
| otherwise ->
let phdrSize = fromIntegral (phnum l) * fromIntegral (phdrEntrySize cl)
in encodePhdrTable cl d (allPhdrs l)
Expand Down Expand Up @@ -618,7 +618,7 @@ layoutRegion inLoad l reg = do
l2 & phdrs %~ Map.insert idx phdr
ElfDataSectionHeaders
| inLoad ->
error $ "Section headers should not be within a segment."
error "Section headers should not be within a segment."
| otherwise -> addSectionHeadersToLayout l
ElfDataSectionNameTable idx ->
let l' = l & shstrndx .~ idx
Expand Down

0 comments on commit 12b6254

Please sign in to comment.