[commit: packages/time] master: use throwErrnoIfMinus1 gettimeofday for consistency in error handling (d575902)

git at git.haskell.org git at git.haskell.org
Sun Dec 20 07:54:22 UTC 2015


Repository : ssh://git@git.haskell.org/time

On branch  : master
Link       : http://git.haskell.org/packages/time.git/commitdiff/d575902c77c2697cc03e28a0f3e81fffbae7c7b6

>---------------------------------------------------------------

commit d575902c77c2697cc03e28a0f3e81fffbae7c7b6
Author: Dylan Simon <dylan at dylex.net>
Date:   Fri Jan 25 18:59:54 2013 -0800

    use throwErrnoIfMinus1 gettimeofday for consistency in error handling
    
    Ignore-this: fc81b9dd998c4e7c01a58d3e3a104cb8
    
    darcs-hash:20130126025954-56c21-c94b312b53512f2202f5012b2abab5b2b8f4c05d


>---------------------------------------------------------------

d575902c77c2697cc03e28a0f3e81fffbae7c7b6
 Data/Time/Clock/CTimeval.hs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/Data/Time/Clock/CTimeval.hs b/Data/Time/Clock/CTimeval.hs
index 5e0ffdf..b0d8920 100644
--- a/Data/Time/Clock/CTimeval.hs
+++ b/Data/Time/Clock/CTimeval.hs
@@ -25,10 +25,8 @@ foreign import ccall unsafe "time.h gettimeofday" gettimeofday :: Ptr CTimeval -
 -- | Get the current POSIX time from the system clock.
 getCTimeval :: IO CTimeval
 getCTimeval = with (MkCTimeval 0 0) (\ptval -> do
-	result <- gettimeofday ptval nullPtr
-	if (result == 0)
-	 then peek ptval
-	 else fail ("error in gettimeofday: " ++ (show result))
+	throwErrnoIfMinus1_ "gettimeofday" $ gettimeofday ptval nullPtr
+	peek ptval
 	)
 
 #endif



More information about the ghc-commits mailing list