@@ -90,9 +90,8 @@ void ProtocolV1::connect() {
9090
9191 // reset connect state variables
9292 authorizer_buf.clear ();
93- // FIPS zeroization audit 20191115: these memsets are not security related.
94- memset (&connect_msg, 0 , sizeof (connect_msg));
95- memset (&connect_reply, 0 , sizeof (connect_reply));
93+ connect_msg = {};
94+ connect_reply = {};
9695
9796 global_seq = messenger->get_global_seq ();
9897}
@@ -820,7 +819,7 @@ CtPtr ProtocolV1::read_message_data_prepare() {
820819#if 0
821820 // rx_buffers is broken by design... see
822821 // http://tracker.ceph.com/issues/22480
823- map<ceph_tid_t, pair<ceph::buffer::list, int> >::iterator p =
822+ const auto p =
824823 connection->rx_buffers.find(current_header.tid);
825824 if (p != connection->rx_buffers.end()) {
826825 ldout(cct, 10) << __func__ << " seleting rx buffer v " << p->second.second
@@ -1205,7 +1204,7 @@ void ProtocolV1::requeue_sent() {
12051204 return ;
12061205 }
12071206
1208- list< out_q_entry_t > &rq = out_q[CEPH_MSG_PRIO_HIGHEST];
1207+ auto &rq = out_q[CEPH_MSG_PRIO_HIGHEST];
12091208 out_seq -= sent.size ();
12101209 while (!sent.empty ()) {
12111210 Message *m = sent.back ();
@@ -1220,10 +1219,11 @@ void ProtocolV1::requeue_sent() {
12201219uint64_t ProtocolV1::discard_requeued_up_to (uint64_t out_seq, uint64_t seq) {
12211220 ldout (cct, 10 ) << __func__ << " " << seq << dendl;
12221221 std::lock_guard<std::mutex> l (connection->write_lock );
1223- if (out_q.count (CEPH_MSG_PRIO_HIGHEST) == 0 ) {
1222+ const auto it = out_q.find (CEPH_MSG_PRIO_HIGHEST);
1223+ if (it == out_q.end ()) {
12241224 return seq;
12251225 }
1226- list< out_q_entry_t > &rq = out_q[CEPH_MSG_PRIO_HIGHEST] ;
1226+ auto &rq = it-> second ;
12271227 uint64_t count = out_seq;
12281228 while (!rq.empty ()) {
12291229 Message* const m = rq.front ().m ;
@@ -1235,7 +1235,7 @@ uint64_t ProtocolV1::discard_requeued_up_to(uint64_t out_seq, uint64_t seq) {
12351235 rq.pop_front ();
12361236 count++;
12371237 }
1238- if (rq.empty ()) out_q.erase (CEPH_MSG_PRIO_HIGHEST );
1238+ if (rq.empty ()) out_q.erase (it );
12391239 return count;
12401240}
12411241
@@ -1246,18 +1246,16 @@ uint64_t ProtocolV1::discard_requeued_up_to(uint64_t out_seq, uint64_t seq) {
12461246void ProtocolV1::discard_out_queue () {
12471247 ldout (cct, 10 ) << __func__ << " started" << dendl;
12481248
1249- for (list< Message *>::iterator p = sent. begin (); p != sent. end (); ++p ) {
1250- ldout (cct, 20 ) << __func__ << " discard " << *p << dendl;
1251- (*p) ->put ();
1249+ for (Message *msg : sent) {
1250+ ldout (cct, 20 ) << __func__ << " discard " << msg << dendl;
1251+ msg ->put ();
12521252 }
12531253 sent.clear ();
1254- for (map<int , list<out_q_entry_t >>::iterator p =
1255- out_q.begin ();
1256- p != out_q.end (); ++p) {
1257- for (list<out_q_entry_t >::iterator r = p->second .begin ();
1258- r != p->second .end (); ++r) {
1259- ldout (cct, 20 ) << __func__ << " discard " << r->m << dendl;
1260- r->m ->put ();
1254+ for (auto & [ prio, entries ] : out_q) {
1255+ static_cast <void >(prio);
1256+ for (auto & entry : entries) {
1257+ ldout (cct, 20 ) << __func__ << " discard " << entry.m << dendl;
1258+ entry.m ->put ();
12611259 }
12621260 }
12631261 out_q.clear ();
@@ -1296,7 +1294,7 @@ void ProtocolV1::reset_recv_state()
12961294
12971295 // clean read and write callbacks
12981296 connection->pendingReadLen .reset ();
1299- connection->writeCallback . reset () ;
1297+ connection->writeCallback = {} ;
13001298
13011299 if (state > THROTTLE_MESSAGE && state <= READ_FOOTER_AND_DISPATCH &&
13021300 connection->policy .throttler_messages ) {
@@ -1328,14 +1326,12 @@ void ProtocolV1::reset_recv_state()
13281326
13291327ProtocolV1::out_q_entry_t ProtocolV1::_get_next_outgoing () {
13301328 out_q_entry_t out_entry;
1331- if (!out_q.empty ()) {
1332- map<int , list<out_q_entry_t >>::reverse_iterator it =
1333- out_q.rbegin ();
1329+ if (const auto it = out_q.begin (); it != out_q.end ()) {
13341330 ceph_assert (!it->second .empty ());
1335- list< out_q_entry_t >::iterator p = it->second .begin ();
1331+ const auto p = it->second .begin ();
13361332 out_entry = *p;
13371333 it->second .erase (p);
1338- if (it->second .empty ()) out_q.erase (it-> first );
1334+ if (it->second .empty ()) out_q.erase (it);
13391335 }
13401336 return out_entry;
13411337}
@@ -1572,8 +1568,7 @@ CtPtr ProtocolV1::handle_connect_message_write(int r) {
15721568CtPtr ProtocolV1::wait_connect_reply () {
15731569 ldout (cct, 20 ) << __func__ << dendl;
15741570
1575- // FIPS zeroization audit 20191115: this memset is not security related.
1576- memset (&connect_reply, 0 , sizeof (connect_reply));
1571+ connect_reply = {};
15771572 return READ (sizeof (connect_reply), handle_connect_reply_1);
15781573}
15791574
@@ -1923,8 +1918,7 @@ CtPtr ProtocolV1::handle_client_banner(char *buffer, int r) {
19231918CtPtr ProtocolV1::wait_connect_message () {
19241919 ldout (cct, 20 ) << __func__ << dendl;
19251920
1926- // FIPS zeroization audit 20191115: this memset is not security related.
1927- memset (&connect_msg, 0 , sizeof (connect_msg));
1921+ connect_msg = {};
19281922 return READ (sizeof (connect_msg), handle_connect_message_1);
19291923}
19301924
@@ -1988,8 +1982,7 @@ CtPtr ProtocolV1::handle_connect_message_2() {
19881982 ceph_msg_connect_reply reply;
19891983 ceph::buffer::list authorizer_reply;
19901984
1991- // FIPS zeroization audit 20191115: this memset is not security related.
1992- memset (&reply, 0 , sizeof (reply));
1985+ reply = {};
19931986 reply.protocol_version =
19941987 messenger->get_proto_version (connection->peer_type , false );
19951988
@@ -2616,8 +2609,7 @@ CtPtr ProtocolV1::server_ready() {
26162609 << dendl;
26172610
26182611 ldout (cct, 20 ) << __func__ << " accept done" << dendl;
2619- // FIPS zeroization audit 20191115: this memset is not security related.
2620- memset (&connect_msg, 0 , sizeof (connect_msg));
2612+ connect_msg = {};
26212613
26222614 if (connection->delay_state ) {
26232615 ceph_assert (connection->delay_state ->ready ());
0 commit comments