diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-08-09 10:49:25 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-08-09 10:49:25 +0000 |
commit | 56d3b5290ba54231d46d08522db7ea55ab51fe49 (patch) | |
tree | 9ef1dd0247b73f2de7a97d5789da6dd62010b556 /vdslib | |
parent | ed6fba7d937cfe61aacfd8e6796886d08acd4eef (diff) |
Avoid short-circuit optimization trap...
Diffstat (limited to 'vdslib')
-rw-r--r-- | vdslib/src/vespa/vdslib/state/clusterstate.cpp | 14 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/clusterstate.h | 2 |
2 files changed, 8 insertions, 8 deletions
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<T>& 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; |