]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/FSCommands: avoid unreachable code triggering compiler warning 63621/head
authorPatrick Donnelly <pdonnell@ibm.com>
Sat, 31 May 2025 01:44:32 +0000 (21:44 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Sat, 31 May 2025 01:49:20 +0000 (21:49 -0400)
    In file included from /home/pdonnell/ceph/src/mds/FSMap.h:31,
                     from /home/pdonnell/ceph/src/mon/PaxosFSMap.h:20,
                     from /home/pdonnell/ceph/src/mon/MDSMonitor.h:26,
                     from /home/pdonnell/ceph/src/mon/FSCommands.cc:17:
    /home/pdonnell/ceph/src/mds/MDSMap.h: In member function ‘int FileSystemCommandHandler::set_val(Monitor*, FSMap&, MonOpRequestRef, const cmdmap_t&, std::ostream&, FileSystemCommandHandler::fs_or_fscid, std::string, std::string)’:
    /home/pdonnell/ceph/src/mds/MDSMap.h:223:40: warning: ‘fsp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      223 |   bool test_flag(int f) const { return flags & f; }
          |                                        ^~~~~
    /home/pdonnell/ceph/src/mon/FSCommands.cc:417:21: note: ‘fsp’ was declared here
      417 |   const Filesystem* fsp;
          |                     ^~~

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/mon/FSCommands.cc

index ac5b87a3c715a997a2f6d54e72cb3be157d9c892..4cb50d71fc37c76847b8afe4bbce0ae85e905ad4 100644 (file)
@@ -417,9 +417,10 @@ int FileSystemCommandHandler::set_val(Monitor *mon, FSMap& fsmap, MonOpRequestRe
   const Filesystem* fsp;
   if (std::holds_alternative<Filesystem*>(fsv)) {
     fsp = std::get<Filesystem*>(fsv);
-  } else if (std::holds_alternative<fs_cluster_id_t>(fsv)) {
+  } else {
+    ceph_assert(std::holds_alternative<fs_cluster_id_t>(fsv));
     fsp = &fsmap.get_filesystem(std::get<fs_cluster_id_t>(fsv));
-  } else ceph_assert(0);
+  }
 
   {
     std::string interr;