Commit e968172c authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Make `-Wall` clean and drop `-fno-warn-unused-imports`



CPP conditional code sections have been carefully taken into account
while performing this warning cleanup. Most `OPTIONS_GHC` declarations
could be dropped (now only a lonely `{-# OPTIONS_GHC -fno-cse #-}`
remains in `Posix.Signals`).
Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
parent 7b9044ab
{-# LANGUAGE NondecreasingIndentation #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......
{-# LANGUAGE NondecreasingIndentation #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -32,8 +31,6 @@ module System.Posix.Directory.Common (
changeWorkingDirectoryFd,
) where
import System.IO.Error
import System.Posix.Error
import System.Posix.Types
import Foreign
import Foreign.C
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -95,12 +94,9 @@ module System.Posix.Files (
import Foreign
import Foreign.C
import System.Posix.Error
import System.Posix.Types
import System.Posix.Internals
import System.Posix.Files.Common
import System.Posix.Internals (withFilePath, peekFilePath)
import System.Posix.Internals
import Data.Time.Clock.POSIX
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -81,17 +80,22 @@ module System.Posix.Files.Common (
#endif
) where
import System.Posix.Error
import System.Posix.Types
import System.IO.Unsafe
import Data.Bits
#if defined(HAVE_STRUCT_STAT_ST_CTIM) || \
defined(HAVE_STRUCT_STAT_ST_MTIM) || \
defined(HAVE_STRUCT_STAT_ST_ATIM)
import Data.Int
import Data.Time.Clock.POSIX
import Data.Ratio
#endif
import Data.Time.Clock.POSIX
import System.Posix.Internals
import Foreign.C
import Foreign.ForeignPtr
import Foreign.Marshal
#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMENS)
import Foreign.Marshal (withArray)
#endif
import Foreign.Ptr
import Foreign.Storable
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -68,17 +67,9 @@ module System.Posix.IO.ByteString (
import System.Posix.Types
import System.Posix.IO.Common
import Foreign.C hiding (
throwErrnoPath,
throwErrnoPathIf,
throwErrnoPathIf_,
throwErrnoPathIfNull,
throwErrnoPathIfMinus1,
throwErrnoPathIfMinus1_ )
import System.Posix.ByteString.FilePath
-- |Open and optionally create this file. See 'System.Posix.Files'
-- for information on how to use the 'FileMode' type.
openFd :: RawFilePath
......
{-# LANGUAGE NondecreasingIndentation, RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -63,15 +62,12 @@ module System.Posix.IO.Common (
import System.IO
import System.IO.Error
import System.Posix.Types
import System.Posix.Error
import qualified System.Posix.Internals as Base
import Foreign
import Foreign.C
import Data.Bits
#ifdef __GLASGOW_HASKELL__
import GHC.IO.Handle
import GHC.IO.Handle.Internals
import GHC.IO.Handle.Types
import qualified GHC.IO.FD as FD
......
{-# OPTIONS_GHC -w #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
-- The above warning supression flag is a temporary kludge.
-- While working on this module you are encouraged to remove it and fix
-- any warnings in the module. See
-- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
-- for details
-----------------------------------------------------------------------------
-- |
-- Module : System.Posix.Resource
......@@ -70,7 +64,7 @@ foreign import ccall unsafe "HsUnix.h __hscore_setrlimit"
getResourceLimit :: Resource -> IO ResourceLimits
getResourceLimit res = do
allocaBytes (#const sizeof(struct rlimit)) $ \p_rlimit -> do
throwErrnoIfMinus1 "getResourceLimit" $
throwErrnoIfMinus1_ "getResourceLimit" $
c_getrlimit (packResource res) p_rlimit
soft <- (#peek struct rlimit, rlim_cur) p_rlimit
hard <- (#peek struct rlimit, rlim_max) p_rlimit
......@@ -84,7 +78,7 @@ setResourceLimit res ResourceLimits{softLimit=soft,hardLimit=hard} = do
allocaBytes (#const sizeof(struct rlimit)) $ \p_rlimit -> do
(#poke struct rlimit, rlim_cur) p_rlimit (packRLimit soft True)
(#poke struct rlimit, rlim_max) p_rlimit (packRLimit hard False)
throwErrnoIfMinus1 "setResourceLimit" $
throwErrnoIfMinus1_ "setResourceLimit" $
c_setrlimit (packResource res) p_rlimit
return ()
......@@ -101,16 +95,20 @@ packResource ResourceTotalMemory = (#const RLIMIT_AS)
unpackRLimit :: CRLim -> ResourceLimit
unpackRLimit (#const RLIM_INFINITY) = ResourceLimitInfinity
#ifdef RLIM_SAVED_MAX
#if defined(RLIM_SAVED_MAX) && (RLIM_SAVED_MAX != RLIM_INFINITY)
unpackRLimit (#const RLIM_SAVED_MAX) = ResourceLimitUnknown
#endif
#if defined(RLIM_SAVED_CUR) && (RLIM_SAVED_CUR != RLIM_INFINITY)
unpackRLimit (#const RLIM_SAVED_CUR) = ResourceLimitUnknown
#endif
unpackRLimit other = ResourceLimit (fromIntegral other)
packRLimit :: ResourceLimit -> Bool -> CRLim
packRLimit ResourceLimitInfinity _ = (#const RLIM_INFINITY)
#ifdef RLIM_SAVED_MAX
#ifdef RLIM_SAVED_CUR
packRLimit ResourceLimitUnknown True = (#const RLIM_SAVED_CUR)
#endif
#ifdef RLIM_SAVED_MAX
packRLimit ResourceLimitUnknown False = (#const RLIM_SAVED_MAX)
#endif
packRLimit (ResourceLimit other) _ = fromIntegral other
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -27,9 +26,12 @@ module System.Posix.SharedMem
#include "HsUnix.h"
import System.Posix.Types
import System.Posix.Error
#if defined(HAVE_SHM_OPEN) || defined(HAVE_SHM_UNLINK)
import Foreign.C
#endif
#ifdef HAVE_SHM_OPEN
import Data.Bits
#endif
data ShmOpenFlags = ShmOpenFlags
{ shmReadWrite :: Bool,
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -76,9 +75,11 @@ import Foreign
import Foreign.C
import System.Posix.Terminal.Common
import System.Posix.Types
#ifndef HAVE_OPENPTY
import System.Posix.IO
#endif
import System.Posix.Internals (withFilePath, peekFilePath)
import System.Posix.Internals (peekFilePath)
-- | @getTerminalName fd@ calls @ttyname@ to obtain a name associated
-- with the terminal for @Fd@ @fd@. If @fd@ is associated
......
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -75,8 +74,10 @@ module System.Posix.Terminal.ByteString (
import Foreign
import System.Posix.Types
import System.Posix.Terminal.Common
import System.Posix.IO.ByteString
import Data.ByteString.Char8 as B
#ifndef HAVE_OPENPTY
import System.Posix.IO.ByteString (defaultFileFlags, openFd, noctty, OpenMode(ReadWrite))
import Data.ByteString.Char8 as B ( pack, )
#endif
import Foreign.C hiding (
throwErrnoPath,
......@@ -185,9 +186,9 @@ foreign import ccall unsafe "__hsunix_unlockpt"
c_unlockpt :: CInt -> IO CInt
#else
c_grantpt :: CInt -> IO CInt
c_grantpt _ = return (fromIntegral 0)
c_grantpt _ = return (fromIntegral (0::Int))
c_unlockpt :: CInt -> IO CInt
c_unlockpt _ = return (fromIntegral 0)
c_unlockpt _ = return (fromIntegral (0::Int))
#endif /* HAVE_PTSNAME */
#endif /* !HAVE_OPENPTY */
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -69,22 +68,13 @@ module System.Posix.Terminal.Common (
import Data.Bits
import Data.Char
import Foreign.C.Error ( errnoToIOError, throwErrnoIfMinus1,
throwErrnoIfMinus1_, throwErrnoIfNull )
#ifndef HAVE_PTSNAME
import Foreign.C.Error ( eNOSYS )
#endif
import Foreign.C.String ( CString, peekCString, withCString )
import Foreign.C.Error ( throwErrnoIfMinus1, throwErrnoIfMinus1_ )
import Foreign.C.Types
import Foreign.ForeignPtr ( ForeignPtr, withForeignPtr, mallocForeignPtrBytes )
import Foreign.Marshal.Alloc ( alloca )
import Foreign.Marshal.Utils ( copyBytes )
import Foreign.Ptr ( Ptr, nullPtr, plusPtr )
import Foreign.Ptr ( Ptr, plusPtr )
import Foreign.Storable ( Storable(..) )
import System.IO.Error ( ioError )
import System.IO.Unsafe ( unsafePerformIO )
import System.Posix.IO ( OpenFileFlags(..), OpenMode(..), defaultFileFlags,
openFd )
import System.Posix.Types
-- -----------------------------------------------------------------------------
......
{-# LANGUAGE NondecreasingIndentation #-}
{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-unused-binds #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Trustworthy #-}
#endif
......@@ -56,7 +55,6 @@ import Foreign.C.Error
import Foreign.C.String ( peekCString )
import Foreign.C.Types
import Foreign
import System.Posix.Types
import System.Posix.Internals
-- -----------------------------------------------------------------------------
......
......@@ -117,6 +117,8 @@ library
System.Posix.Process.Common
System.Posix.Terminal.Common
ghc-options: -Wall
include-dirs: include
includes: HsUnix.h execvpe.h
install-includes:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment