]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PGMonitor: fix uninitialized scalar variable
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Sat, 1 Mar 2014 12:33:18 +0000 (13:33 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Sat, 1 Mar 2014 12:33:18 +0000 (13:33 +0100)
Fix type handling in dump_stuck_pg_stats. If type is type doesn't
match to known PGMap::STUCK_* type print out a message and return
directly from function.

CID 1030132 (#2 of 2): Uninitialized scalar variable (UNINIT)
 uninit_use_in_call: Using uninitialized value "stuck_type" when calling
 "PGMap::dump_stuck(ceph::Formatter *, PGMap::StuckPG, utime_t) const"

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/mon/PGMonitor.cc

index 6dea1c9369b04851aca21ae811e3536b6f7ae1ff..1c64cdc8ec5ae9ea3f1c2e31ca7483b6c051ddc5 100644 (file)
@@ -1978,12 +1978,17 @@ int PGMonitor::dump_stuck_pg_stats(stringstream &ds,
 {
   PGMap::StuckPG stuck_type;
   string type = args[0];
+
   if (type == "inactive")
     stuck_type = PGMap::STUCK_INACTIVE;
-  if (type == "unclean")
+  else if (type == "unclean")
     stuck_type = PGMap::STUCK_UNCLEAN;
-  if (type == "stale")
+  else if (type == "stale")
     stuck_type = PGMap::STUCK_STALE;
+  else {
+    ds << "Unknown type: " << type << std::endl;
+    return 0;
+  }
 
   utime_t now(ceph_clock_now(g_ceph_context));
   utime_t cutoff = now - utime_t(threshold, 0);