]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: return -1 on error from get_type_id
authorSage Weil <sage@inktank.com>
Fri, 3 May 2013 22:26:22 +0000 (15:26 -0700)
committerSage Weil <sage@inktank.com>
Fri, 3 May 2013 22:53:40 +0000 (15:53 -0700)
So we can distinguish between a bad type name and type 0.

Fix both callers, too.

Signed-off-by: Sage Weil <sage@inktank.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/mon/OSDMonitor.cc

index 1fc86893e1d0421f05f5fba10230b949ae7986bb..e8058d60a57efa3f844b7f2b18a06a0e5b2d814f 100644 (file)
@@ -641,8 +641,9 @@ int CrushWrapper::add_simple_rule(string name, string root_name, string failure_
   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;
index 9109156d066d3ae8ced697964203ee0826b6e0af..ac936336125ccebde4641b3127f9c55dd3e28e59 100644 (file)
@@ -166,7 +166,7 @@ public:
     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);
index d46c28f6ff277b9b2625d50b2f415c578fcf3815..75105cadadf9221884580394838d347ca73d0dee 100644 (file)
@@ -2557,7 +2557,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
          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;