summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Pairing.hs2
-rw-r--r--Assistant/Pairing/Network.hs8
-rw-r--r--Assistant/Threads/Committer.hs2
-rw-r--r--Assistant/Threads/PairListener.hs2
-rw-r--r--Assistant/Threads/XMPPPusher.hs3
-rw-r--r--Command/WebApp.hs4
-rw-r--r--Crypto.hs2
-rw-r--r--Database/Fsck.hs2
-rw-r--r--Git.hs6
-rw-r--r--Git/CatFile.hs2
-rw-r--r--Git/LsFiles.hs13
-rw-r--r--Remote/GCrypt.hs2
-rw-r--r--Remote/Git.hs7
-rw-r--r--Remote/Helper/Chunked.hs2
-rw-r--r--Utility/DirWatcher.hs10
-rw-r--r--Utility/Directory.hs2
-rw-r--r--Utility/FileMode.hs2
-rw-r--r--Utility/Metered.hs2
-rw-r--r--Utility/Touch.hsc6
19 files changed, 42 insertions, 37 deletions
diff --git a/Assistant/Pairing.hs b/Assistant/Pairing.hs
index b24e5fdb6..2390379e2 100644
--- a/Assistant/Pairing.hs
+++ b/Assistant/Pairing.hs
@@ -81,6 +81,8 @@ data PairingInProgress = PairingInProgress
}
deriving (Show)
+data AddrClass = IPv4AddrClass | IPv6AddrClass
+
data SomeAddr = IPv4Addr HostAddress
{- My Android build of the Network library does not currently have IPV6
- support. -}
diff --git a/Assistant/Pairing/Network.hs b/Assistant/Pairing/Network.hs
index 7a4ac3ffe..694dcbbcc 100644
--- a/Assistant/Pairing/Network.hs
+++ b/Assistant/Pairing/Network.hs
@@ -33,9 +33,9 @@ pairingPort = 55556
{- Goal: Reach all hosts on the same network segment.
- Method: Use same address that avahi uses. Other broadcast addresses seem
- to not be let through some routers. -}
-multicastAddress :: SomeAddr -> HostName
-multicastAddress (IPv4Addr _) = "224.0.0.251"
-multicastAddress (IPv6Addr _) = "ff02::fb"
+multicastAddress :: AddrClass -> HostName
+multicastAddress IPv4AddrClass = "224.0.0.251"
+multicastAddress IPv6AddrClass = "ff02::fb"
{- Multicasts a message repeatedly on all interfaces, with a 2 second
- delay between each transmission. The message is repeated forever
@@ -62,7 +62,7 @@ multicastPairMsg repeats secret pairdata stage = go M.empty repeats
sendinterface cache i = void $ tryIO $
withSocketsDo $ bracket setup cleanup use
where
- setup = multicastSender (multicastAddress i) pairingPort
+ setup = multicastSender (multicastAddress IPv4AddrClass) pairingPort
cleanup (sock, _) = sClose sock -- FIXME does not work
use (sock, addr) = do
setInterface sock (showAddr i)
diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs
index 717a99c96..f4af93285 100644
--- a/Assistant/Threads/Committer.hs
+++ b/Assistant/Threads/Committer.hs
@@ -196,7 +196,7 @@ maxCommitSize :: Int
maxCommitSize = 5000
{- Decide if now is a good time to make a commit.
- - Note that the list of changes has an undefined order.
+ - Note that the list of changes has a random order.
-
- Current strategy: If there have been 10 changes within the past second,
- a batch activity is taking place, so wait for later.
diff --git a/Assistant/Threads/PairListener.hs b/Assistant/Threads/PairListener.hs
index e4f87494c..ba2ae955c 100644
--- a/Assistant/Threads/PairListener.hs
+++ b/Assistant/Threads/PairListener.hs
@@ -31,7 +31,7 @@ pairListenerThread urlrenderer = namedThread "PairListener" $ do
where
{- Note this can crash if there's no network interface,
- or only one like lo that doesn't support multicast. -}
- getsock = multicastReceiver (multicastAddress $ IPv4Addr undefined) pairingPort
+ getsock = multicastReceiver (multicastAddress IPv4AddrClass) pairingPort
go reqs cache sock = liftIO (getmsg sock []) >>= \msg -> case readish msg of
Nothing -> go reqs cache sock
diff --git a/Assistant/Threads/XMPPPusher.hs b/Assistant/Threads/XMPPPusher.hs
index ec11b9b94..bff17356d 100644
--- a/Assistant/Threads/XMPPPusher.hs
+++ b/Assistant/Threads/XMPPPusher.hs
@@ -78,4 +78,5 @@ selectNextPush lastpushedto l = go [] l
(Pushing clientid _)
| Just clientid /= lastpushedto -> (m, rejected ++ ms)
_ -> go (m:rejected) ms
- go [] [] = undefined
+ go [] [] = error "empty push queue"
+
diff --git a/Command/WebApp.hs b/Command/WebApp.hs
index 46ba556a3..e872d4be0 100644
--- a/Command/WebApp.hs
+++ b/Command/WebApp.hs
@@ -143,10 +143,10 @@ firstRun :: Maybe HostName -> IO ()
firstRun listenhost = do
checkEnvironmentIO
{- Without a repository, we cannot have an Annex monad, so cannot
- - get a ThreadState. Using undefined is only safe because the
+ - get a ThreadState. This is only safe because the
- webapp checks its noAnnex field before accessing the
- threadstate. -}
- let st = undefined
+ let st = error "annex state not available"
{- Get a DaemonStatus without running in the Annex monad. -}
dstatus <- atomically . newTMVar =<< newDaemonStatus
d <- newAssistantData st dstatus
diff --git a/Crypto.hs b/Crypto.hs
index c2076f461..4e3741715 100644
--- a/Crypto.hs
+++ b/Crypto.hs
@@ -93,7 +93,7 @@ genSharedCipher highQuality =
{- Updates an existing Cipher, re-encrypting it to add or remove keyids,
- depending on whether the first component is True or False. -}
updateEncryptedCipher :: [(Bool, String)] -> StorableCipher -> IO StorableCipher
-updateEncryptedCipher _ SharedCipher{} = undefined
+updateEncryptedCipher _ SharedCipher{} = error "Cannot update shared cipher"
updateEncryptedCipher [] encipher = return encipher
updateEncryptedCipher newkeys encipher@(EncryptedCipher _ variant (KeyIds ks)) = do
dropKeys <- listKeyIds [ k | (False, k) <- newkeys ]
diff --git a/Database/Fsck.hs b/Database/Fsck.hs
index bf0c72f6d..8de0a8f3d 100644
--- a/Database/Fsck.hs
+++ b/Database/Fsck.hs
@@ -55,7 +55,7 @@ Fscked
-
- This may fail, if other fsck processes are currently running using the
- database. Removing the database in that situation would lead to crashes
- - or undefined behavior.
+ - or unknown behavior.
-}
newPass :: UUID -> Annex Bool
newPass u = isJust <$> tryExclusiveLock (gitAnnexFsckDbLock u) go
diff --git a/Git.hs b/Git.hs
index 6e270815e..1bc789f85 100644
--- a/Git.hs
+++ b/Git.hs
@@ -60,7 +60,7 @@ repoLocation Repo { location = Url url } = show url
repoLocation Repo { location = Local { worktree = Just dir } } = dir
repoLocation Repo { location = Local { gitdir = dir } } = dir
repoLocation Repo { location = LocalUnknown dir } = dir
-repoLocation Repo { location = Unknown } = undefined
+repoLocation Repo { location = Unknown } = error "unknown repoLocation"
{- Path to a repository. For non-bare, this is the worktree, for bare,
- it's the gitdir, and for URL repositories, is the path on the remote
@@ -70,12 +70,12 @@ repoPath Repo { location = Url u } = unEscapeString $ uriPath u
repoPath Repo { location = Local { worktree = Just d } } = d
repoPath Repo { location = Local { gitdir = d } } = d
repoPath Repo { location = LocalUnknown dir } = dir
-repoPath Repo { location = Unknown } = undefined
+repoPath Repo { location = Unknown } = error "unknown repoPath"
{- Path to a local repository's .git directory. -}
localGitDir :: Repo -> FilePath
localGitDir Repo { location = Local { gitdir = d } } = d
-localGitDir _ = undefined
+localGitDir _ = error "unknown localGitDir"
{- Some code needs to vary between URL and normal repos,
- or bare and non-bare, these functions help with that. -}
diff --git a/Git/CatFile.hs b/Git/CatFile.hs
index a1a0a0d28..c63a0647c 100644
--- a/Git/CatFile.hs
+++ b/Git/CatFile.hs
@@ -110,4 +110,4 @@ catTree h treeref = go <$> catObjectDetails h treeref
parsemodefile b =
let (modestr, file) = separate (== ' ') (decodeBS b)
in (file, readmode modestr)
- readmode = fst . fromMaybe (0, undefined) . headMaybe . readOct
+ readmode = fromMaybe 0 . fmap fst . headMaybe . readOct
diff --git a/Git/LsFiles.hs b/Git/LsFiles.hs
index c23c282d0..e80c1b288 100644
--- a/Git/LsFiles.hs
+++ b/Git/LsFiles.hs
@@ -181,12 +181,13 @@ parseUnmerged s
| otherwise = case words metadata of
(rawblobtype:rawsha:rawstage:_) -> do
stage <- readish rawstage :: Maybe Int
- unless (stage == 2 || stage == 3) $
- fail undefined -- skip stage 1
- blobtype <- readBlobType rawblobtype
- sha <- extractSha rawsha
- return $ InternalUnmerged (stage == 2) file
- (Just blobtype) (Just sha)
+ if stage /= 2 && stage /= 3
+ then Nothing
+ else do
+ blobtype <- readBlobType rawblobtype
+ sha <- extractSha rawsha
+ return $ InternalUnmerged (stage == 2) file
+ (Just blobtype) (Just sha)
_ -> Nothing
where
(metadata, file) = separate (== '\t') s
diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs
index c27519825..01efc6060 100644
--- a/Remote/GCrypt.hs
+++ b/Remote/GCrypt.hs
@@ -397,7 +397,7 @@ getGCryptId fast r gc
| Git.repoIsLocal r || Git.repoIsLocalUnknown r = extract <$>
liftIO (catchMaybeIO $ Git.Config.read r)
| not fast = extract . liftM fst <$> getM (eitherToMaybe <$>)
- [ Ssh.onRemote r (Git.Config.fromPipe r, return (Left undefined)) "configlist" [] []
+ [ Ssh.onRemote r (Git.Config.fromPipe r, return (Left $ error "configlist failed")) "configlist" [] []
, getConfigViaRsync r gc
]
| otherwise = return (Nothing, r)
diff --git a/Remote/Git.hs b/Remote/Git.hs
index fdd0049ca..4804cb10e 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -199,7 +199,7 @@ tryGitConfigRead :: Git.Repo -> Annex Git.Repo
tryGitConfigRead r
| haveconfig r = return r -- already read
| Git.repoIsSsh r = store $ do
- v <- Ssh.onRemote r (pipedconfig, return (Left undefined)) "configlist" [] []
+ v <- Ssh.onRemote r (pipedconfig, return (Left $ error "configlist failed")) "configlist" [] []
case v of
Right r'
| haveconfig r' -> return r'
@@ -228,9 +228,10 @@ tryGitConfigRead r
uo <- Url.getUrlOptions
v <- liftIO $ withTmpFile "git-annex.tmp" $ \tmpfile h -> do
hClose h
- ifM (Url.downloadQuiet (Git.repoLocation r ++ "/config") tmpfile uo)
+ let url = Git.repoLocation r ++ "/config"
+ ifM (Url.downloadQuiet url tmpfile uo)
( pipedconfig "git" [Param "config", Param "--null", Param "--list", Param "--file", File tmpfile]
- , return $ Left undefined
+ , return $ Left $ error $ "unable to load config from " ++ url
)
case v of
Left _ -> do
diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs
index 2f21ba66c..23ed3dbf8 100644
--- a/Remote/Helper/Chunked.hs
+++ b/Remote/Helper/Chunked.hs
@@ -72,7 +72,7 @@ chunkKeyStream basek chunksize = ChunkKeyStream $ map mk [1..]
nextChunkKeyStream :: ChunkKeyStream -> (Key, ChunkKeyStream)
nextChunkKeyStream (ChunkKeyStream (k:l)) = (k, ChunkKeyStream l)
-nextChunkKeyStream (ChunkKeyStream []) = undefined -- stream is infinite!
+nextChunkKeyStream (ChunkKeyStream []) = error "expected infinite ChunkKeyStream"
takeChunkKeyStream :: ChunkCount -> ChunkKeyStream -> [Key]
takeChunkKeyStream n (ChunkKeyStream l) = genericTake n l
diff --git a/Utility/DirWatcher.hs b/Utility/DirWatcher.hs
index 3d3c14619..bde710626 100644
--- a/Utility/DirWatcher.hs
+++ b/Utility/DirWatcher.hs
@@ -57,7 +57,7 @@ eventsCoalesce = False
#if (WITH_KQUEUE || WITH_FSEVENTS)
eventsCoalesce = True
#else
-eventsCoalesce = undefined
+eventsCoalesce = error "eventsCoalesce not defined"
#endif
#endif
@@ -78,7 +78,7 @@ closingTracked = True
#if WITH_KQUEUE
closingTracked = False
#else
-closingTracked = undefined
+closingTracked = error "closingTracked not defined"
#endif
#endif
@@ -93,7 +93,7 @@ modifyTracked = True
#if WITH_KQUEUE
modifyTracked = False
#else
-modifyTracked = undefined
+modifyTracked = error "modifyTracked not defined"
#endif
#endif
@@ -131,7 +131,7 @@ watchDir dir prune scanevents hooks runstartup =
#else
type DirWatcherHandle = ()
watchDir :: FilePath -> Pruner -> Bool -> WatchHooks -> (IO () -> IO ()) -> IO DirWatcherHandle
-watchDir = undefined
+watchDir = error "watchDir not defined"
#endif
#endif
#endif
@@ -150,7 +150,7 @@ stopWatchDir = FSEvents.eventStreamDestroy
#if WITH_WIN32NOTIFY
stopWatchDir = Win32Notify.killWatchManager
#else
-stopWatchDir = undefined
+stopWatchDir = error "stopWatchDir not defined"
#endif
#endif
#endif
diff --git a/Utility/Directory.hs b/Utility/Directory.hs
index 85ec8bf45..2e037fdda 100644
--- a/Utility/Directory.hs
+++ b/Utility/Directory.hs
@@ -111,7 +111,7 @@ moveFile src dest = tryIO (rename src dest) >>= onrename
-- But, mv will move into a directory if
-- dest is one, which is not desired.
whenM (isdir dest) rethrow
- viaTmp mv dest undefined
+ viaTmp mv dest ""
where
rethrow = throwM e
mv tmp _ = do
diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs
index 5c4001ed8..f98e1bc87 100644
--- a/Utility/FileMode.hs
+++ b/Utility/FileMode.hs
@@ -124,7 +124,7 @@ withUmask _ a = a
#endif
combineModes :: [FileMode] -> FileMode
-combineModes [] = undefined
+combineModes [] = 0
combineModes [m] = m
combineModes (m:ms) = foldl unionFileModes m ms
diff --git a/Utility/Metered.hs b/Utility/Metered.hs
index f94b5d121..c34e931a4 100644
--- a/Utility/Metered.hs
+++ b/Utility/Metered.hs
@@ -144,7 +144,7 @@ defaultChunkSize :: Int
defaultChunkSize = 32 * k - chunkOverhead
where
k = 1024
- chunkOverhead = 2 * sizeOf (undefined :: Int) -- GHC specific
+ chunkOverhead = 2 * sizeOf (1 :: Int) -- GHC specific
data OutputHandler = OutputHandler
{ quietMode :: Bool
diff --git a/Utility/Touch.hsc b/Utility/Touch.hsc
index f87bb62d6..c3318e6da 100644
--- a/Utility/Touch.hsc
+++ b/Utility/Touch.hsc
@@ -54,8 +54,8 @@ instance Storable TimeSpec where
-- use the larger alignment of the two types in the struct
alignment _ = max sec_alignment nsec_alignment
where
- sec_alignment = alignment (undefined::CTime)
- nsec_alignment = alignment (undefined::CLong)
+ sec_alignment = alignment (1::CTime)
+ nsec_alignment = alignment (1::CLong)
sizeOf _ = #{size struct timespec}
peek ptr = do
sec <- #{peek struct timespec, tv_sec} ptr
@@ -92,7 +92,7 @@ touchBoth file atime mtime follow =
-}
instance Storable TimeSpec where
- alignment _ = alignment (undefined::CLong)
+ alignment _ = alignment (1::CLong)
sizeOf _ = #{size struct timeval}
peek ptr = do
sec <- #{peek struct timeval, tv_sec} ptr