diff options
author | simonpj@microsoft.com <unknown> | 2010-11-16 17:25:36 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2010-11-16 17:25:36 +0000 |
commit | 298d9fd83318c208dc6facf419c03926d65613e0 (patch) | |
tree | 63aa775816bfa9deffe0add88511240ffb40dc4a /System/Posix/IO.hsc | |
parent | 14022b586ca6f7b878481a3a5e05c090a6e21056 (diff) |
Remove unnecessary fromIntegral calls
Diffstat (limited to 'System/Posix/IO.hsc')
-rw-r--r-- | System/Posix/IO.hsc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/System/Posix/IO.hsc b/System/Posix/IO.hsc index 4f993b2..f58b49b 100644 --- a/System/Posix/IO.hsc +++ b/System/Posix/IO.hsc @@ -259,7 +259,7 @@ handleToFd' h h_@Handle__{haType=_,..} = do -- state as a result. flushWriteBuffer h_ FD.release fd - return (Handle__{haType=ClosedHandle,..}, Fd (fromIntegral (FD.fdFD fd))) + return (Handle__{haType=ClosedHandle,..}, Fd (FD.fdFD fd)) fdToHandle fd = FD.fdToHandle (fromIntegral fd) @@ -434,7 +434,7 @@ fdRead _fd 0 = return ("", 0) fdRead fd nbytes = do allocaBytes (fromIntegral nbytes) $ \ buf -> do rc <- fdReadBuf fd buf nbytes - case fromIntegral rc of + case rc of 0 -> ioError (ioeSetErrorString (mkIOError EOF "fdRead" Nothing Nothing) "EOF") n -> do s <- peekCStringLen (castPtr buf, fromIntegral n) @@ -450,7 +450,7 @@ fdReadBuf _fd _buf 0 = return 0 fdReadBuf fd buf nbytes = fmap fromIntegral $ throwErrnoIfMinus1Retry "fdReadBuf" $ - c_safe_read (fromIntegral fd) (castPtr buf) (fromIntegral nbytes) + c_safe_read (fromIntegral fd) (castPtr buf) nbytes foreign import ccall safe "read" c_safe_read :: CInt -> Ptr CChar -> CSize -> IO CSsize @@ -459,9 +459,8 @@ foreign import ccall safe "read" -- the least-significant 8 bits of each character are written). fdWrite :: Fd -> String -> IO ByteCount fdWrite fd str = - withCStringLen str $ \ (buf,len) -> do - rc <- fdWriteBuf fd (castPtr buf) (fromIntegral len) - return (fromIntegral rc) + withCStringLen str $ \ (buf,len) -> + fdWriteBuf fd (castPtr buf) (fromIntegral len) -- | Write data from memory to an 'Fd'. This is exactly equivalent -- to the POSIX @write@ function. @@ -472,7 +471,7 @@ fdWriteBuf :: Fd fdWriteBuf fd buf len = fmap fromIntegral $ throwErrnoIfMinus1Retry "fdWriteBuf" $ - c_safe_write (fromIntegral fd) (castPtr buf) (fromIntegral len) + c_safe_write (fromIntegral fd) (castPtr buf) len foreign import ccall safe "write" c_safe_write :: CInt -> Ptr CChar -> CSize -> IO CSsize |