From 7b1bcae879305da138bb3e08d04735b54266c537 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Fri, 9 Sep 2016 13:09:46 +0100 Subject: regtools: rename error_t to err_t to avoid name clash Change-Id: Ib8d34e4f58f3225b1dafc533ce7e1b7867ad053b --- utils/regtools/headergen_v2.cpp | 8 +++---- utils/regtools/include/soc_desc.hpp | 10 ++++----- utils/regtools/lib/formula.cpp | 2 +- utils/regtools/lib/soc_desc.cpp | 13 +++++------ utils/regtools/swiss_knife.cpp | 44 ++++++++++++++++++------------------- 5 files changed, 38 insertions(+), 39 deletions(-) diff --git a/utils/regtools/headergen_v2.cpp b/utils/regtools/headergen_v2.cpp index bc056aaeb5..22a99b7df4 100644 --- a/utils/regtools/headergen_v2.cpp +++ b/utils/regtools/headergen_v2.cpp @@ -87,12 +87,12 @@ void print_context(const error_context_t& ctx) { for(size_t j = 0; j < ctx.count(); j++) { - error_t e = ctx.get(j); + err_t e = ctx.get(j); switch(e.level()) { - case error_t::INFO: printf("[INFO]"); break; - case error_t::WARNING: printf("[WARN]"); break; - case error_t::FATAL: printf("[FATAL]"); break; + case err_t::INFO: printf("[INFO]"); break; + case err_t::WARNING: printf("[WARN]"); break; + case err_t::FATAL: printf("[FATAL]"); break; default: printf("[UNK]"); break; } if(e.location().size() != 0) diff --git a/utils/regtools/include/soc_desc.hpp b/utils/regtools/include/soc_desc.hpp index b8d16b423e..3d8481f963 100644 --- a/utils/regtools/include/soc_desc.hpp +++ b/utils/regtools/include/soc_desc.hpp @@ -43,7 +43,7 @@ typedef int soc_id_t; const soc_id_t DEFAULT_ID = 0xcafebabe; /** Error class */ -class error_t +class err_t { public: enum level_t @@ -52,7 +52,7 @@ public: WARNING, FATAL }; - error_t(level_t lvl, const std::string& loc, const std::string& msg) + err_t(level_t lvl, const std::string& loc, const std::string& msg) :m_level(lvl), m_loc(loc), m_msg(msg) {} level_t level() const { return m_level; } std::string location() const { return m_loc; } @@ -66,11 +66,11 @@ protected: class error_context_t { public: - void add(const error_t& err) { m_list.push_back(err); } + void add(const err_t& err) { m_list.push_back(err); } size_t count() const { return m_list.size(); } - error_t get(size_t i) const { return m_list[i]; } + err_t get(size_t i) const { return m_list[i]; } protected: - std::vector< error_t > m_list; + std::vector< err_t > m_list; }; /** diff --git a/utils/regtools/lib/formula.cpp b/utils/regtools/lib/formula.cpp index 1a6b16c773..dbde20a321 100644 --- a/utils/regtools/lib/formula.cpp +++ b/utils/regtools/lib/formula.cpp @@ -24,7 +24,7 @@ struct formula_evaluator va_start(args, fmt); vsnprintf(buffer,sizeof(buffer), fmt, args); va_end(args); - ctx.add(error_t(error_t::FATAL, m_loc, buffer)); + ctx.add(err_t(err_t::FATAL, m_loc, buffer)); return false; } diff --git a/utils/regtools/lib/soc_desc.cpp b/utils/regtools/lib/soc_desc.cpp index b52201672f..3238c4de73 100644 --- a/utils/regtools/lib/soc_desc.cpp +++ b/utils/regtools/lib/soc_desc.cpp @@ -149,23 +149,23 @@ std::string xml_loc(xmlAttr *attr) } template -bool add_error(error_context_t& ctx, error_t::level_t lvl, T *node, +bool add_error(error_context_t& ctx, err_t::level_t lvl, T *node, const std::string& msg) { - ctx.add(error_t(lvl, xml_loc(node), msg)); + ctx.add(err_t(lvl, xml_loc(node), msg)); return false; } template bool add_fatal(error_context_t& ctx, T *node, const std::string& msg) { - return add_error(ctx, error_t::FATAL, node, msg); + return add_error(ctx, err_t::FATAL, node, msg); } template bool add_warning(error_context_t& ctx, T *node, const std::string& msg) { - return add_error(ctx, error_t::WARNING, node, msg); + return add_error(ctx, err_t::WARNING, node, msg); } bool parse_wrong_version_error(xmlNode *node, error_context_t& ctx) @@ -529,7 +529,7 @@ bool parse_root_elem(xmlNode *node, soc_t& soc, error_context_t& ctx) END_ATTR_MATCH() if(!has_version) { - ctx.add(error_t(error_t::FATAL, xml_loc(node), "no version attribute, is this a v1 file ?")); + ctx.add(err_t(err_t::FATAL, xml_loc(node), "no version attribute, is this a v1 file ?")); return false; } if(ver != MAJOR_VERSION) @@ -660,7 +660,7 @@ namespace if((x) < 0) { \ std::ostringstream oss; \ oss << __FILE__ << ":" << __LINE__; \ - ctx.add(error_t(error_t::FATAL, oss.str(), "write error")); \ + ctx.add(err_t(err_t::FATAL, oss.str(), "write error")); \ return -1; \ } \ }while(0) @@ -1576,7 +1576,6 @@ node_inst_t node_inst_t::child(const std::string& name) const return child(name, INST_NO_INDEX); } - node_inst_t node_inst_t::child(const std::string& name, size_t index) const { std::vector< node_t > *nodes = get_children(m_node); diff --git a/utils/regtools/swiss_knife.cpp b/utils/regtools/swiss_knife.cpp index fb65b5ca24..2ea1fc4ad3 100644 --- a/utils/regtools/swiss_knife.cpp +++ b/utils/regtools/swiss_knife.cpp @@ -35,12 +35,12 @@ void print_context(const error_context_t& ctx) { for(size_t j = 0; j < ctx.count(); j++) { - error_t e = ctx.get(j); + err_t e = ctx.get(j); switch(e.level()) { - case error_t::INFO: printf("[INFO]"); break; - case error_t::WARNING: printf("[WARN]"); break; - case error_t::FATAL: printf("[FATAL]"); break; + case err_t::INFO: printf("[INFO]"); break; + case err_t::WARNING: printf("[WARN]"); break; + case err_t::FATAL: printf("[FATAL]"); break; default: printf("[UNK]"); break; } if(e.location().size() != 0) @@ -110,7 +110,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_reg_t& in, node_t& out, error_conte soc_word_t base = 0, stride = 0; if(in.addr.size() <= 1) { - ctx.add(error_t(error_t::WARNING, loc, + ctx.add(err_t(err_t::WARNING, loc, "register uses a formula but has only one instance")); is_stride = false; } @@ -125,7 +125,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_reg_t& in, node_t& out, error_conte if(is_stride) { - ctx.add(error_t(error_t::INFO, loc, "promoted formula to base/stride")); + ctx.add(err_t(err_t::INFO, loc, "promoted formula to base/stride")); out.instance[0].range.type = range_t::STRIDE; out.instance[0].range.base = base; out.instance[0].range.stride = stride; @@ -167,7 +167,7 @@ bool convert_v1_to_v2(const soc_desc_v1::soc_dev_t& in, node_t& out, error_conte { std::string loc = _loc + "." + in.name; if(!in.version.empty()) - ctx.add(error_t(error_t::INFO, loc, "dropped version")); + ctx.add(err_t(err_t::INFO, loc, "dropped version")); out.name = in.name; out.title = in.long_name; out.desc = in.desc; @@ -330,10 +330,10 @@ int do_write(int argc, char **argv) void check_name(const std::string& path, const std::string& name, error_context_t& ctx) { if(name.empty()) - ctx.add(error_t(error_t::FATAL, path, "name is empty")); + ctx.add(err_t(err_t::FATAL, path, "name is empty")); for(size_t i = 0; i < name.size(); i++) if(!isalnum(name[i]) && name[i] != '_') - ctx.add(error_t(error_t::FATAL, path, "name '" + name + + ctx.add(err_t(err_t::FATAL, path, "name '" + name + "' must only contain alphanumeric characters or '_'")); } @@ -351,7 +351,7 @@ void check_instance(const std::string& _path, const instance_t& inst, error_cont var[inst.range.variable] = inst.range.first; soc_word_t res; if(!evaluate_formula(inst.range.formula, var, res, path + ".", ctx)) - ctx.add(error_t(error_t::FATAL, path + ".", + ctx.add(err_t(err_t::FATAL, path + ".", "cannot evaluate formula")); } } @@ -362,7 +362,7 @@ void check_field(const std::string& _path, const field_t& field, error_context_t std::string path = _path + "." + field.name; check_name(path, field.name, ctx); if(field.width == 0) - ctx.add(error_t(error_t::WARNING, path, "field has width 0")); + ctx.add(err_t(err_t::WARNING, path, "field has width 0")); soc_word_t max = field.bitmask() >> field.pos; std::set< std::string > names; std::map< soc_word_t, std::string > map; @@ -373,12 +373,12 @@ void check_field(const std::string& _path, const field_t& field, error_context_t std::string path_ = path + "." + n; check_name(path_, n, ctx); if(v > max) - ctx.add(error_t(error_t::FATAL, path_, "value does not fit into the field")); + ctx.add(err_t(err_t::FATAL, path_, "value does not fit into the field")); if(names.find(n) != names.end()) - ctx.add(error_t(error_t::FATAL, path, "duplicate name '" + n + "' in enums")); + ctx.add(err_t(err_t::FATAL, path, "duplicate name '" + n + "' in enums")); names.insert(n); if(map.find(v) != map.end()) - ctx.add(error_t(error_t::WARNING, path, "'" + n + "' and '" + map[v] + "' have the same value")); + ctx.add(err_t(err_t::WARNING, path, "'" + n + "' and '" + map[v] + "' have the same value")); map[v] = n; } } @@ -387,7 +387,7 @@ void check_register(const std::string& _path, const soc_desc::register_t& reg, e { std::string path = _path + "."; if(reg.width != 8 && reg.width != 16 && reg.width != 32) - ctx.add(error_t(error_t::WARNING, path, "width is not 8, 16 or 32")); + ctx.add(err_t(err_t::WARNING, path, "width is not 8, 16 or 32")); for(size_t i = 0; i < reg.field.size(); i++) check_field(path, reg.field[i], ctx); std::set< std::string > names; @@ -396,16 +396,16 @@ void check_register(const std::string& _path, const soc_desc::register_t& reg, e { std::string n = reg.field[i].name; if(names.find(n) != names.end()) - ctx.add(error_t(error_t::FATAL, path, "duplicate name '" + n + "' in fields")); + ctx.add(err_t(err_t::FATAL, path, "duplicate name '" + n + "' in fields")); if(reg.field[i].pos + reg.field[i].width > reg.width) - ctx.add(error_t(error_t::FATAL, path, "field '" + n + "' does not fit into the register")); + ctx.add(err_t(err_t::FATAL, path, "field '" + n + "' does not fit into the register")); names.insert(n); if(bitmap & reg.field[i].bitmask()) { /* find the duplicate to ease debugging */ for(size_t j = 0; j < i; j++) if(reg.field[j].bitmask() & reg.field[i].bitmask()) - ctx.add(error_t(error_t::FATAL, path, "overlap between fields '" + + ctx.add(err_t(err_t::FATAL, path, "overlap between fields '" + reg.field[j].name + "' and '" + n + "'")); } bitmap |= reg.field[i].bitmask(); @@ -420,7 +420,7 @@ void check_node(const std::string& _path, const node_t& node, error_context_t& c std::string path = _path + "." + node.name; check_name(_path, node.name, ctx); if(node.instance.empty()) - ctx.add(error_t(error_t::WARNING, path, "subnode with no instances")); + ctx.add(err_t(err_t::WARNING, path, "subnode with no instances")); for(size_t j = 0; j < node.instance.size(); j++) check_instance(path, node.instance[j], ctx); for(size_t i = 0; i < node.register_.size(); i++) @@ -440,7 +440,7 @@ void check_nodes(const std::string& path, const std::vector< node_t >& nodes, { std::string n = nodes[i].instance[j].name; if(names.find(n) != names.end()) - ctx.add(error_t(error_t::FATAL, path, "duplicate instance name '" + + ctx.add(err_t(err_t::FATAL, path, "duplicate instance name '" + n + "' in subnodes")); names.insert(n); } @@ -450,7 +450,7 @@ void check_nodes(const std::string& path, const std::vector< node_t >& nodes, { std::string n = nodes[i].name; if(names.find(n) != names.end()) - ctx.add(error_t(error_t::FATAL, path, "duplicate node name '" + n + + ctx.add(err_t(err_t::FATAL, path, "duplicate node name '" + n + "' in subnodes")); names.insert(n); } @@ -832,4 +832,4 @@ int main(int argc, char **argv) else usage(); return 0; -} \ No newline at end of file +} -- cgit v1.2.3