diff --git a/src/host/Host.cc b/src/host/Host.cc index 6ad778b7e7..804b34a87f 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -173,7 +173,6 @@ int Host::update_info(string &parse_str) { char * error_msg; int rc; - float fv; rc = obj_template->parse(parse_str, &error_msg); @@ -185,20 +184,14 @@ int Host::update_info(string &parse_str) return -1; } - get_template_attribute("TOTALCPU", fv); - host_share.max_cpu = static_cast(fv); - get_template_attribute("TOTALMEMORY", fv); - host_share.max_mem = static_cast(fv); + get_template_attribute("TOTALCPU",host_share.max_cpu); + get_template_attribute("TOTALMEMORY",host_share.max_mem); - get_template_attribute("FREECPU", fv); - host_share.free_cpu = static_cast(fv); - get_template_attribute("FREEMEMORY", fv); - host_share.free_mem = static_cast(fv); + get_template_attribute("FREECPU",host_share.free_cpu); + get_template_attribute("FREEMEMORY",host_share.free_mem); - get_template_attribute("USEDCPU", fv); - host_share.used_cpu = static_cast(fv); - get_template_attribute("USEDMEMORY", fv); - host_share.used_mem = static_cast(fv); + get_template_attribute("USEDCPU",host_share.used_cpu); + get_template_attribute("USEDMEMORY",host_share.used_mem); return 0; } diff --git a/src/template/Template.cc b/src/template/Template.cc index e461a4afbe..f77aacd62b 100644 --- a/src/template/Template.cc +++ b/src/template/Template.cc @@ -417,27 +417,13 @@ bool Template::get( const string& name, int& value) const { - string sval; + float fvalue; + bool rc; - get(name, sval); + rc = get(name, fvalue); + value = static_cast(fvalue); - if ( sval == "" ) - { - value = 0; - return false; - } - - istringstream iss(sval); - - iss >> value; - - if (iss.fail() || !iss.eof()) - { - value = 0; - return false; - } - - return true; + return rc; } /* -------------------------------------------------------------------------- */