From 56d3b5290ba54231d46d08522db7ea55ab51fe49 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 9 Aug 2023 10:49:25 +0000 Subject: Avoid short-circuit optimization trap... --- vdslib/src/vespa/vdslib/state/clusterstate.cpp | 14 +++++++------- vdslib/src/vespa/vdslib/state/clusterstate.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'vdslib') diff --git a/vdslib/src/vespa/vdslib/state/clusterstate.cpp b/vdslib/src/vespa/vdslib/state/clusterstate.cpp index 61a41086ef3..e0fb16a5a4b 100644 --- a/vdslib/src/vespa/vdslib/state/clusterstate.cpp +++ b/vdslib/src/vespa/vdslib/state/clusterstate.cpp @@ -432,22 +432,22 @@ std::string getNumberSpec(const std::vector& numbers) { } -bool +size_t ClusterState::printStateGroupwise(std::ostream& out, const Group& group, bool verbose, const std::string& indent, const NodeType& nodeType) const { NodeState defState(nodeType, State::UP); - bool printedAny = false; + size_t printed = 0; for (uint16_t nodeId : group.getNodes()) { Node node(nodeType, nodeId); const NodeState& state(getNodeState(node)); if (state != defState) { out << "\n" << indent << " " << node << ": "; state.print(out, verbose, indent + " "); - printedAny = true; + printed++; } } - return printedAny; + return printed; } void @@ -468,9 +468,9 @@ ClusterState::printStateGroupwise(std::ostream& out, const Group& group, bool ve out << " " << group.getNodes().size() << " node" << (group.getNodes().size() != 1 ? "s" : "") << " [" << getNumberSpec(group.getNodes()) << "] {"; - bool printedAny = printStateGroupwise(out, group, verbose, indent, NodeType::DISTRIBUTOR); - printedAny = printedAny || printStateGroupwise(out, group, verbose, indent, NodeType::STORAGE); - if (!printedAny) { + size_t printed = printStateGroupwise(out, group, verbose, indent, NodeType::DISTRIBUTOR) + + printStateGroupwise(out, group, verbose, indent, NodeType::STORAGE); + if (printed > 0 ) { out << "\n" << indent << " All nodes in group up and available."; } } else { diff --git a/vdslib/src/vespa/vdslib/state/clusterstate.h b/vdslib/src/vespa/vdslib/state/clusterstate.h index 47c7bbfd62f..2630c4a2315 100644 --- a/vdslib/src/vespa/vdslib/state/clusterstate.h +++ b/vdslib/src/vespa/vdslib/state/clusterstate.h @@ -69,7 +69,7 @@ private: void removeExtraElements(const NodeType& type); void printStateGroupwise(std::ostream& out, const Group&, bool verbose, const std::string& indent, bool rootGroup) const; void getTextualDifference(std::ostringstream& builder, const NodeType& type, const ClusterState& other) const; - bool printStateGroupwise(std::ostream& out, const Group&, bool verbose, const std::string& indent, const NodeType& type) const; + size_t printStateGroupwise(std::ostream& out, const Group&, bool verbose, const std::string& indent, const NodeType& type) const; uint32_t _version; NodeCounts _nodeCount; const State* _clusterState; -- cgit v1.2.3