From e67fd7059268a74b328bcd653556b545745e224e Mon Sep 17 00:00:00 2001 From: Valentin Robert Date: Mon, 15 Jan 2024 11:36:07 -0800 Subject: [PATCH] address reasonable Hlint suggestions --- src/Data/ElfEdit/HighLevel/Get.hs | 10 +++++----- src/Data/ElfEdit/HighLevel/Layout.hs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Data/ElfEdit/HighLevel/Get.hs b/src/Data/ElfEdit/HighLevel/Get.hs index 4a81f5e..8dc944e 100644 --- a/src/Data/ElfEdit/HighLevel/Get.hs +++ b/src/Data/ElfEdit/HighLevel/Get.hs @@ -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 @@ -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 []) @@ -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 @@ -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. -- diff --git a/src/Data/ElfEdit/HighLevel/Layout.hs b/src/Data/ElfEdit/HighLevel/Layout.hs index 60a4d12..a365e92 100644 --- a/src/Data/ElfEdit/HighLevel/Layout.hs +++ b/src/Data/ElfEdit/HighLevel/Layout.hs @@ -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) @@ -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. @@ -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." @@ -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) @@ -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