diff options
author | Baylac-Jacqué Félix <felix@alternativebit.fr> | 2017-09-16 16:11:04 +0200 |
---|---|---|
committer | Baylac-Jacqué Félix <felix@alternativebit.fr> | 2017-09-16 17:11:53 +0200 |
commit | 0b2de17e8bb5ca5c2f709f150fd73153ef670fd0 (patch) | |
tree | 1376cb18d011492da599a8d2a80f01e164a3a847 /src/Network/WireGuard/Internal/Util.hs | |
parent | Plumbed RPC set parser to STM state. (diff) | |
download | wireguard-hs-0b2de17e8bb5ca5c2f709f150fd73153ef670fd0.tar.xz wireguard-hs-0b2de17e8bb5ca5c2f709f150fd73153ef670fd0.zip |
Fix GHC and HLINT warnings.
Diffstat (limited to '')
-rw-r--r-- | src/Network/WireGuard/Internal/Util.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Network/WireGuard/Internal/Util.hs b/src/Network/WireGuard/Internal/Util.hs index 6aefee7..fa48d24 100644 --- a/src/Network/WireGuard/Internal/Util.hs +++ b/src/Network/WireGuard/Internal/Util.hs @@ -18,6 +18,7 @@ import Control.Exception (Exception (..), SomeAsyncException, SomeException, throwIO) import Control.Monad.Catch (MonadCatch (..)) +import Data.Foldable (forM_) import System.IO (hPutStrLn, stderr) import Foreign @@ -49,9 +50,7 @@ catchSomeExceptionAnd what m = catch m $ \(_ :: SomeException) -> what withJust :: Monad m => m (Maybe a) -> (a -> m ()) -> m () withJust mma func = do ma <- mma - case ma of - Nothing -> return () - Just a -> func a + forM_ ma func dropUntilM :: Monad m => (a -> Bool) -> m a -> m a dropUntilM cond ma = loop @@ -66,7 +65,7 @@ zeroMemory :: Ptr a -> CSize -> IO () zeroMemory dest nbytes = memset dest 0 (fromIntegral nbytes) copyMemory :: Ptr a -> Ptr b -> CSize -> IO () -copyMemory dest src nbytes = memcpy dest src nbytes +copyMemory = memcpy foreign import ccall unsafe "string.h" memset :: Ptr a -> CInt -> CSize -> IO () foreign import ccall unsafe "string.h" memcpy :: Ptr a -> Ptr b -> CSize -> IO () |