]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: prefer std::size to ARRAY_SIZE macro
authorYao Zongyou <yaozongyou@vip.qq.com>
Tue, 23 Oct 2018 04:52:46 +0000 (12:52 +0800)
committerYao Zongyou <yaozongyou@vip.qq.com>
Wed, 24 Oct 2018 02:45:15 +0000 (10:45 +0800)
Signed-off-by: Yao Zongyou <yaozongyou@vip.qq.com>
src/common/cmdparse.h
src/mon/Monitor.cc
src/osd/OSD.cc

index ee3844fb8fbdbeb9249fe5e492e81e02197e99bc..487883e1a4b8ebc8f614581119166ee432504c41 100644 (file)
@@ -13,9 +13,6 @@
 
 class CephContext;
 
-/* this is handy; can't believe it's not standard */
-#define ARRAY_SIZE(a)  (sizeof(a) / sizeof(*a))
-
 typedef boost::variant<std::string,
                       bool,
                       int64_t,
index 096b1e0a889212362d47621ebe2bbee69621d738..485b433fa60c455227de4a62b590522161023f10 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 
+#include <iterator>
 #include <sstream>
 #include <tuple>
 #include <stdlib.h>
@@ -214,8 +215,8 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s,
   exited_quorum = ceph_clock_now();
 
   // prepare local commands
-  local_mon_commands.resize(ARRAY_SIZE(mon_commands));
-  for (unsigned i = 0; i < ARRAY_SIZE(mon_commands); ++i) {
+  local_mon_commands.resize(std::size(mon_commands));
+  for (unsigned i = 0; i < std::size(mon_commands); ++i) {
     local_mon_commands[i] = mon_commands[i];
   }
   MonCommand::encode_vector(local_mon_commands, local_mon_commands_bl);
index 18faaca55c8712b45a250a85c910ead7a323edde..35eef0846e65344b73cbc1ec12a69e87ec1cac3f 100644 (file)
@@ -18,6 +18,7 @@
 #include <cctype>
 #include <fstream>
 #include <iostream>
+#include <iterator>
 
 #include <unistd.h>
 #include <sys/stat.h>
@@ -6090,7 +6091,7 @@ int OSD::_do_command(
     JSONFormatter *f = new JSONFormatter();
     f->open_object_section("command_descriptions");
     for (OSDCommand *cp = osd_commands;
-        cp < &osd_commands[ARRAY_SIZE(osd_commands)]; cp++) {
+        cp < &osd_commands[std::size(osd_commands)]; cp++) {
 
       ostringstream secname;
       secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;