From d5072e4c37a07c5bf0f0544a3990bbc8e7f548dd Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 23 Mar 2011 13:25:22 +0100 Subject: [PATCH] Fix lint errors in the htools code These are just changes from hlint suggestions. Still compiles and passes unittests. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- htools/Ganeti/HTools/Cluster.hs | 4 ++-- htools/Ganeti/HTools/Luxi.hs | 2 +- htools/Ganeti/HTools/Node.hs | 2 +- htools/Ganeti/HTools/Rapi.hs | 4 ++-- htools/Ganeti/HTools/Text.hs | 4 ++-- htools/hail.hs | 13 ++++++------- htools/hbal.hs | 8 ++++---- htools/hscan.hs | 11 ++++------- 8 files changed, 22 insertions(+), 26 deletions(-) diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 68ea006c9..ca7cfb2e1 100644 --- a/htools/Ganeti/HTools/Cluster.hs +++ b/htools/Ganeti/HTools/Cluster.hs @@ -830,8 +830,8 @@ tryMGEvac _ nl il ex_ndx = in do -- that done, we now add the per-group nl/il to the tuple all_insts4 <- - mapM (\(gdx, idxs) -> do - case lookup gdx gni of + mapM (\(gdx, idxs) -> + case lookup gdx gni of Nothing -> fail $ "Can't find group index " ++ show gdx Just (gnl, gil) -> return (gdx, gnl, gil, idxs)) all_insts3 diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs index 0fbd798eb..15dc6c329 100644 --- a/htools/Ganeti/HTools/Luxi.hs +++ b/htools/Ganeti/HTools/Luxi.hs @@ -177,7 +177,7 @@ parseGroup (JSArray [ uuid, name, apol ]) = do let convert a = genericConvert "Group" xname a xuuid <- convert "uuid" uuid xapol <- convert "alloc_policy" apol - return $ (xuuid, Group.create xname xuuid xapol) + return (xuuid, Group.create xname xuuid xapol) parseGroup v = fail ("Invalid group query result: " ++ show v) diff --git a/htools/Ganeti/HTools/Node.hs b/htools/Ganeti/HTools/Node.hs index 03849235d..9c4fd917b 100644 --- a/htools/Ganeti/HTools/Node.hs +++ b/htools/Ganeti/HTools/Node.hs @@ -494,7 +494,7 @@ showField t field = "mload" -> printf "%5.3f" uM "dload" -> printf "%5.3f" uD "nload" -> printf "%5.3f" uN - "ptags" -> intercalate "," . map (\(k, v) -> printf "%s=%d" k v) . + "ptags" -> intercalate "," . map (uncurry (printf "%s=%d")) . Map.toList $ pTags t "peermap" -> show $ peers t _ -> T.unknownField diff --git a/htools/Ganeti/HTools/Rapi.hs b/htools/Ganeti/HTools/Rapi.hs index eb300762d..f77e859ac 100644 --- a/htools/Ganeti/HTools/Rapi.hs +++ b/htools/Ganeti/HTools/Rapi.hs @@ -89,8 +89,8 @@ getGroups body = loadJSArray "Parsing group data" body >>= getFakeGroups :: Result [(String, Group.Group)] getFakeGroups = - return $ [(defaultGroupID, - Group.create "default" defaultGroupID AllocPreferred)] + return [(defaultGroupID, + Group.create "default" defaultGroupID AllocPreferred)] -- | Construct an instance from a JSON object. parseInstance :: NameAssoc diff --git a/htools/Ganeti/HTools/Text.hs b/htools/Ganeti/HTools/Text.hs index 1f446ac89..964fd8a38 100644 --- a/htools/Ganeti/HTools/Text.hs +++ b/htools/Ganeti/HTools/Text.hs @@ -7,7 +7,7 @@ files, as produced by gnt-node and gnt-instance list. {- -Copyright (C) 2009, 2010 Google Inc. +Copyright (C) 2009, 2010, 2011 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -109,7 +109,7 @@ serializeCluster (ClusterData gl nl il ctags) = loadGroup :: (Monad m) => [String] -> m (String, Group.Group) loadGroup [name, gid, apol] = do xapol <- apolFromString apol - return $ (gid, Group.create name gid xapol) + return (gid, Group.create name gid xapol) loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'" diff --git a/htools/hail.hs b/htools/hail.hs index 541e1a93f..1831837c6 100644 --- a/htools/hail.hs +++ b/htools/hail.hs @@ -88,13 +88,12 @@ readRequest opts args = do hPutStrLn stderr $ "Error: " ++ err exitWith $ ExitFailure 1 Ok rq -> return rq - r2 <- if isJust (optDataFile opts) || (not . null . optNodeSim) opts - then do - cdata <- loadExternalData opts - let Request rqt _ = r1 - return $ Request rqt cdata - else return r1 - return r2 + (if isJust (optDataFile opts) || (not . null . optNodeSim) opts + then do + cdata <- loadExternalData opts + let Request rqt _ = r1 + return $ Request rqt cdata + else return r1) -- | Main function. main :: IO () diff --git a/htools/hbal.hs b/htools/hbal.hs index 46cccf8e1..2b0f847c2 100644 --- a/htools/hbal.hs +++ b/htools/hbal.hs @@ -4,7 +4,7 @@ {- -Copyright (C) 2009, 2010 Google Inc. +Copyright (C) 2009, 2010, 2011 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -280,7 +280,7 @@ main = do when (length ngroups > 1 && isNothing (optGroup opts)) $ do hPutStrLn stderr "Found multiple node groups:" mapM_ (hPutStrLn stderr . (" " ++) . Group.name . - (flip Container.find gl) . fst) ngroups + flip Container.find gl . fst) ngroups hPutStrLn stderr "Aborting." exitWith $ ExitFailure 1 @@ -307,7 +307,7 @@ main = do Nothing -> do -- TODO: while this is unlikely to happen, log here the -- actual group data to help debugging - hPutStrLn stderr $ "Internal failure, missing group idx" + hPutStrLn stderr "Internal failure, missing group idx" exitWith $ ExitFailure 1 Just cdata -> return (Group.name grp, cdata) @@ -417,4 +417,4 @@ main = do return False Just master -> runJobSet master fin_nl il cmd_jobs) else return True - when (not eval) (exitWith (ExitFailure 1)) + unless eval (exitWith (ExitFailure 1)) diff --git a/htools/hscan.hs b/htools/hscan.hs index c14846f21..69601338c 100644 --- a/htools/hscan.hs +++ b/htools/hscan.hs @@ -153,15 +153,12 @@ main = do let name = local input_data <- Luxi.loadData lsock result <- writeData nlen name opts input_data - when (not result) $ exitWith $ ExitFailure 2 + unless result $ exitWith $ ExitFailure 2 #ifndef NO_CURL - results <- mapM (\ name -> - do - input_data <- Rapi.loadData name - writeData nlen name opts input_data - ) clusters - when (not $ all id results) $ exitWith (ExitFailure 2) + results <- mapM (\name -> Rapi.loadData name >>= writeData nlen name opts) + clusters + unless (all id results) $ exitWith (ExitFailure 2) #else when (not $ null clusters) $ do putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters" -- GitLab