From 3763043dc97f9452d130e2a78a69d641d8df4162 Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Thu, 22 Oct 2009 15:46:22 +0200 Subject: [PATCH] default_results attribute in proj/config: Default to empty list if unset, check for proper configuration. Signed-off-by: Gordon Hecker --- local/e2tool.lua | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/local/e2tool.lua b/local/e2tool.lua index 53da7a0..946a507 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -159,6 +159,24 @@ e2tool = e2lib.module("e2tool") -- in the ".fix" array will be stored to the configuration file. -- storing details are described with e2tool.save_user_config below. +--- check if a table is a list of strings +-- @param l table +-- @return bool +local function listofstrings(l) + if type(l) ~= "table" then + return false, new_error("not a table") + end + for i,s in pairs(l) do + if type(i) ~= "number" then + return false, new_error("found non-numeric index") + end + if type(s) ~= "string" then + return false, new_error("found non-string value") + end + end + return true, nil +end + function e2tool.opendebuglogfile(info) local rc, re = e2lib.mkdir(info.root .. "/log", "-p") if not rc then @@ -453,10 +471,16 @@ The newest configuration syntax supported by the tools is %s. if not info.project.name then e:append("key is not set: name") end - if type(info.project.default_results) ~= "table" then + if not info.project.default_results then e2lib.warnf("WDEFAULT", "in project configuration:") - e2lib.warnf("WDEFAULT", - " default_results ist not a table. Defaulting to empty list.") + e2lib.warnf("WDEFAULT", + "default_results ist not set. Defaulting to empty list.") + info.project.default_results = {} + end + rc, re = listofstrings(info.project.default_results) + if not rc then + e:append("default_results ist not a valid list of strings") + e:cat(re) end if not info.project.chroot_arch then e2lib.warnf("WDEFAULT", "in project configuration:") -- 2.39.5