From ac71ab7bd7dded89202fde4a1f725dac32c7cd3c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 5 Aug 2012 15:08:58 -0400 Subject: [PATCH] avoid head --- Assistant/Threads/MountWatcher.hs | 8 ++++---- Utility/WebApp.hs | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Assistant/Threads/MountWatcher.hs b/Assistant/Threads/MountWatcher.hs index 51c7590ea7..2cde0f1831 100644 --- a/Assistant/Threads/MountWatcher.hs +++ b/Assistant/Threads/MountWatcher.hs @@ -98,11 +98,11 @@ checkMountMonitor :: Client -> IO Bool checkMountMonitor client = do running <- filter (`elem` usableservices) <$> listServiceNames client - if null running - then startOneService client startableservices - else do + case running of + [] -> startOneService client startableservices + (service:_) -> do debug thisThread [ "Using running DBUS service" - , Prelude.head running + , service , "to monitor mount events." ] return True diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs index 971422e369..be186baa20 100644 --- a/Utility/WebApp.hs +++ b/Utility/WebApp.hs @@ -67,7 +67,9 @@ runWebApp app observer = do localSocket :: IO Socket localSocket = do addrs <- getAddrInfo (Just hints) (Just localhost) Nothing - go $ Prelude.head addrs + case addrs of + [] -> error "unable to bind to a local socket" + (addr:_) -> go addr where hints = defaultHints { addrFlags = [AI_ADDRCONFIG]