@@ -203,7 +203,8 @@ dsn::host_port diagnose_recommend(const dsn::replication::ddd_partition_info &pi
203203 // - choose the node with the largest last committed decree
204204 // - if last committed decree is the same, choose node with the largest ballot
205205
206- dsn::host_port latest_node, secondary_node;
206+ dsn::host_port latest_node;
207+ dsn::host_port secondary_node;
207208 GET_HOST_PORT (latest, node, latest_node);
208209 GET_HOST_PORT (secondary, node, secondary_node);
209210
@@ -308,8 +309,9 @@ bool ddd_diagnose(command_executor *e, shell_context *sc, arguments args)
308309 std::vector<dsn::host_port> last_drops;
309310 GET_HOST_PORTS (pinfo.config , last_drops, last_drops);
310311
311- dsn::host_port latest_dropped, secondary_latest_dropped;
312- if (last_drops.size () > 0 ) {
312+ dsn::host_port latest_dropped;
313+ dsn::host_port secondary_latest_dropped;
314+ if (!last_drops.empty ()) {
313315 latest_dropped = last_drops[last_drops.size () - 1 ];
314316 }
315317 if (last_drops.size () > 1 ) {
@@ -329,21 +331,23 @@ bool ddd_diagnose(command_executor *e, shell_context *sc, arguments args)
329331 << " ballot(" << n.ballot << " ), "
330332 << " last_committed(" << n.last_committed_decree << " ), "
331333 << " last_prepared(" << n.last_prepared_decree << " )" ;
332- if (node == latest_dropped)
334+ if (node == latest_dropped) {
333335 out << " <== the latest" ;
334- else if (node == secondary_latest_dropped)
336+ } else if (node == secondary_latest_dropped) {
335337 out << " <== the secondary latest" ;
338+ }
336339 out << std::endl;
337340 }
338341 out << " ----" << std::endl;
339342 j = 0 ;
340343 for (const auto &r : last_drops) {
341344 out << " last_drops[" << j++ << " ]: "
342345 << " node(" << r.to_string () << " )" ;
343- if (j == ( int ) last_drops.size () - 1 )
346+ if (j == static_cast < int >( last_drops.size ()) - 1 ) {
344347 out << " <== the secondary latest" ;
345- else if (j == ( int ) last_drops.size ())
348+ } else if (j == static_cast < int >( last_drops.size ())) {
346349 out << " <== the latest" ;
350+ }
347351 out << std::endl;
348352 }
349353 out << " ----" << std::endl;
0 commit comments