From: Yao Zongyou Date: Tue, 23 Oct 2018 04:52:46 +0000 (+0800) Subject: common: prefer std::size to ARRAY_SIZE macro X-Git-Tag: 3.2-0~87^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=37ca6bef8720b912cff3275d7ca83d91634a4efb;p=ceph-ci.git common: prefer std::size to ARRAY_SIZE macro Signed-off-by: Yao Zongyou --- diff --git a/src/common/cmdparse.h b/src/common/cmdparse.h index ee3844fb8fb..487883e1a4b 100644 --- a/src/common/cmdparse.h +++ b/src/common/cmdparse.h @@ -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 #include #include #include @@ -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); diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 18faaca55c8..35eef0846e6 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -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;