summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-19 00:38:29 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-19 00:38:29 -0400
commitc5910fd179d374f644ab3c843b243a51a7df9b24 (patch)
tree9623da2ab0411f3862d415a17be7be567688b714 /Assistant
parentbf1bf600fc94f6b95d5723473b148b35ab32073d (diff)
removed all uses of undefined from code base
It's a code smell, can lead to hard to diagnose error messages.
Diffstat (limited to 'Assistant')
-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
5 files changed, 10 insertions, 7 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"
+