From 82b61ac8e14df43f84afc20c6f6691f433f07951 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 10 Jul 2009 00:56:38 +0000 Subject: [PATCH] Fix some "warn-unused-do-bind" warnings where we just want to ignore the result --- Control/Exception/Base.hs | 6 +++--- GHC/IO/Encoding/Iconv.hs | 3 +-- GHC/IO/FD.hs | 21 ++++++++++----------- GHC/IO/Handle/Internals.hs | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Control/Exception/Base.hs b/Control/Exception/Base.hs index d5cac44..06c5390 100644 --- a/Control/Exception/Base.hs +++ b/Control/Exception/Base.hs @@ -474,7 +474,7 @@ tryJust p a = do -- | Like 'finally', but only performs the final action if there was an -- exception raised by the computation. onException :: IO a -> IO b -> IO a -onException io what = io `catch` \e -> do what +onException io what = io `catch` \e -> do _ <- what throw (e :: SomeException) ----------------------------------------------------------------------------- @@ -509,7 +509,7 @@ bracket before after thing = block (do a <- before r <- unblock (thing a) `onException` after a - after a + _ <- after a return r ) #endif @@ -524,7 +524,7 @@ finally :: IO a -- ^ computation to run first a `finally` sequel = block (do r <- unblock a `onException` sequel - sequel + _ <- sequel return r ) diff --git a/GHC/IO/Encoding/Iconv.hs b/GHC/IO/Encoding/Iconv.hs index b8fcfd9..02090d1 100644 --- a/GHC/IO/Encoding/Iconv.hs +++ b/GHC/IO/Encoding/Iconv.hs @@ -151,8 +151,7 @@ newIConv from to fn = withCString from $ \ from_str -> withCString to $ \ to_str -> do iconvt <- throwErrnoIfMinus1 "mkTextEncoding" $ hs_iconv_open to_str from_str - let iclose = do throwErrnoIfMinus1 "Iconv.close" $ hs_iconv_close iconvt - return () + let iclose = throwErrnoIfMinus1_ "Iconv.close" $ hs_iconv_close iconvt return BufferCodec{ encode = fn iconvt, close = iclose, diff --git a/GHC/IO/FD.hs b/GHC/IO/FD.hs index 8e52584..2b21914 100644 --- a/GHC/IO/FD.hs +++ b/GHC/IO/FD.hs @@ -165,7 +165,8 @@ openFile filepath iomode = (fD,fd_type) <- mkFD fd iomode Nothing{-no stat-} False{-not a socket-} True{-is non-blocking-} - `catchAny` \e -> do c_close fd; throwIO e + `catchAny` \e -> do _ <- c_close fd + throwIO e #ifndef mingw32_HOST_OS -- we want to truncate() if this is an open in WriteMode, but only @@ -292,12 +293,12 @@ close fd = c_close (fdFD fd) release :: FD -> IO () -release fd = do -#ifndef mingw32_HOST_OS - unlockFile (fdFD fd) +#ifdef mingw32_HOST_OS +release _ = return () +#else +release fd = do _ <- unlockFile (fdFD fd) + return () #endif - let _ = fd -- warning suppression - return () #ifdef mingw32_HOST_OS foreign import stdcall unsafe "HsBase.h closesocket" @@ -311,9 +312,8 @@ isSeekable fd = do seek :: FD -> SeekMode -> Integer -> IO () seek fd mode off = do - throwErrnoIfMinus1Retry "seek" $ + throwErrnoIfMinus1Retry_ "seek" $ c_lseek (fdFD fd) (fromIntegral off) seektype - return () where seektype :: CInt seektype = case mode of @@ -332,9 +332,8 @@ getSize fd = fdFileSize (fdFD fd) setSize :: FD -> Integer -> IO () setSize fd size = do - throwErrnoIf (/=0) "GHC.IO.FD.setSize" $ + throwErrnoIf_ (/=0) "GHC.IO.FD.setSize" $ c_ftruncate (fdFD fd) (fromIntegral size) - return () devType :: FD -> IO IODeviceType devType fd = do (ty,_,_) <- fdStat (fdFD fd); return ty @@ -347,7 +346,7 @@ dup fd = do dup2 :: FD -> FD -> IO FD dup2 fd fdto = do -- Windows' dup2 does not return the new descriptor, unlike Unix - throwErrnoIfMinus1 "GHC.IO.FD.dup2" $ + throwErrnoIfMinus1_ "GHC.IO.FD.dup2" $ c_dup2 (fdFD fd) (fdFD fdto) return fd{ fdFD = fdFD fdto } -- original FD, with the new fdFD diff --git a/GHC/IO/Handle/Internals.hs b/GHC/IO/Handle/Internals.hs index fc9fbde..6fb66c7 100644 --- a/GHC/IO/Handle/Internals.hs +++ b/GHC/IO/Handle/Internals.hs @@ -334,7 +334,7 @@ handleFinalizer fp m = do _ -> do flushWriteBuffer handle_ `catchAny` \_ -> return () -- ignore errors and async exceptions, and close the -- descriptor anyway... - hClose_handle_ handle_ + _ <- hClose_handle_ handle_ return () putMVar m (ioe_finalizedHandle fp) -- 1.7.10.4