Commit d5072e4c authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix lint errors in the htools code



These are just changes from hlint suggestions. Still compiles and
passes unittests.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 98ed5092
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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 ++ "'"
......
......@@ -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 ()
......
......@@ -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))
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment