Fix lint errors in the htools code
authorIustin Pop <iustin@google.com>
Wed, 23 Mar 2011 12:25:22 +0000 (13:25 +0100)
committerIustin Pop <iustin@google.com>
Wed, 23 Mar 2011 16:35:07 +0000 (17:35 +0100)
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
htools/Ganeti/HTools/Luxi.hs
htools/Ganeti/HTools/Node.hs
htools/Ganeti/HTools/Rapi.hs
htools/Ganeti/HTools/Text.hs
htools/hail.hs
htools/hbal.hs
htools/hscan.hs

index 68ea006..ca7cfb2 100644 (file)
@@ -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
index 0fbd798..15dc6c3 100644 (file)
@@ -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)
 
index 0384923..9c4fd91 100644 (file)
@@ -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
index eb30076..f77e859 100644 (file)
@@ -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
index 1f446ac..964fd8a 100644 (file)
@@ -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 ++ "'"
 
index 541e1a9..1831837 100644 (file)
@@ -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 ()
index 46cccf8..2b0f847 100644 (file)
@@ -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))
index c14846f..6960133 100644 (file)
@@ -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"