So we can distinguish between a bad type name and type 0.
Fix both callers, too.
Signed-off-by: Sage Weil <sage@inktank.com>
int type = 0;
if (failure_domain_name.length()) {
type = get_type_id(failure_domain_name);
- if (type <= 0) // bah, returns 0 on error; but its ok, device isn't a domain really
+ if (type < 0) {
return -EINVAL;
+ }
}
int ruleset = 0;
build_rmaps();
if (type_rmap.count(name))
return type_rmap[name];
- return 0;
+ return -1;
}
const char *get_type_name(int t) const {
std::map<int,string>::const_iterator p = type_map.find(t);
err = 0;
} else {
int type = newcrush.get_type_id(m->cmd[4]);
- if (type <= 0) {
+ if (type < 0) {
ss << "type '" << m->cmd[4] << "' does not exist";
err = -EINVAL;
break;