Skip to content

Commit

Permalink
address reasonable Hlint suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptival committed Jan 15, 2024
1 parent fa665fa commit e67fd70
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 @@ -178,7 +178,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:)

$(pure [])

Expand All @@ -189,7 +189,7 @@ $(pure [])
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 @@ -594,8 +594,8 @@ $(pure [])
-- 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 @@ -57,7 +57,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 @@ -76,7 +76,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 @@ -426,7 +426,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 @@ -480,7 +480,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 @@ -628,7 +628,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 e67fd70

Please sign in to comment.