1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

Fix fmt 10.0.0 related formatting errors.

Signed-off-by: Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
This commit is contained in:
Philipp Jungkamp 2023-09-25 12:40:06 +02:00 committed by Steffen Vogel
parent 86bba9c5e8
commit 33cd6165df
15 changed files with 120 additions and 73 deletions

View file

@ -72,7 +72,6 @@ find_package(OpenMP)
find_package(Opal)
find_package(IBVerbs)
find_package(RDMACM)
find_package(spdlog)
find_package(Etherlab)
find_package(Lua)
find_package(LibDataChannel)

2
common

@ -1 +1 @@
Subproject commit 08fd24b85ec4e5b18f370702eb129b4f1d1e4bca
Subproject commit 785d94caccc1e43853439cb6bd1e1c170fff42a9

2
fpga

@ -1 +1 @@
Subproject commit 1cac3fafde6ef3098a145f9d5d936a2dc6b7d7c0
Subproject commit 4e59f0d04bfe5f741b5a1345c858fa0074190f5d

View file

@ -7,8 +7,8 @@
#pragma once
#include <iostream>
#include <jansson.h>
#include <spdlog/fmt/ostr.h>
#include <uuid/uuid.h>
#include <villas/colors.hpp>
@ -25,6 +25,10 @@
#include <villas/sample.hpp>
#include <villas/stats.hpp>
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
#include <fmt/ostream.h>
#endif
#if defined(LIBNL3_ROUTE_FOUND) && defined(__linux__)
#define WITH_NETEM
#endif // LIBNL3_ROUTE_FOUND
@ -260,9 +264,7 @@ public:
void setEnabled(bool en) { enabled = en; }
// Custom formatter for spdlog
template <typename OStream>
friend OStream &operator<<(OStream &os, const Node &n) {
friend std::ostream &operator<<(std::ostream &os, const Node &n) {
os << n.getName();
return os;
@ -317,9 +319,7 @@ public:
virtual std::string getType() const { return "node"; }
// Custom formatter for spdlog
template <typename OStream>
friend OStream &operator<<(OStream &os, const NodeFactory &f) {
friend std::ostream &operator<<(std::ostream &os, const NodeFactory &f) {
os << f.getName();
return os;
@ -366,3 +366,11 @@ public:
} // namespace node
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<villas::node::Node> : public fmt::ostream_formatter {};
template <>
class fmt::formatter<villas::node::NodeFactory>
: public fmt::ostream_formatter {};
#endif

View file

@ -8,7 +8,6 @@
#pragma once
#include <jansson.h>
#include <spdlog/fmt/ostr.h>
#include <villas/common.hpp>
#include <villas/log.hpp>

View file

@ -26,6 +26,25 @@ namespace node {
enum class RedisMode { KEY, HASH, CHANNEL };
inline std::ostream &operator<<(std::ostream &os, const enum villas::node::RedisMode &m) {
switch (m) {
case villas::node::RedisMode::KEY:
os << "key";
break;
case villas::node::RedisMode::HASH:
os << "hash";
break;
case villas::node::RedisMode::CHANNEL:
os << "channel";
break;
}
return os;
}
class RedisConnection {
public:

View file

@ -9,11 +9,14 @@
#include <chrono>
#include <functional>
#include <spdlog/fmt/ostr.h>
#include <sw/redis++/connection.h>
#include <sw/redis++/redis++.h>
#include <villas/node/config.hpp>
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
#include <fmt/ostream.h>
#endif
namespace std {
template <typename _rep, typename ratio>
@ -52,7 +55,7 @@ template <> struct hash<sw::redis::ConnectionOptions> {
namespace sw {
namespace redis {
bool operator==(const tls::TlsOptions &o1, const tls::TlsOptions &o2) {
inline bool operator==(const tls::TlsOptions &o1, const tls::TlsOptions &o2) {
#ifdef REDISPP_WITH_TLS
return o1.enabled == o2.enabled && o1.cacert == o2.cacert &&
o1.cacertdir == o2.cacertdir && o1.cert == o2.cert &&
@ -62,7 +65,7 @@ bool operator==(const tls::TlsOptions &o1, const tls::TlsOptions &o2) {
#endif // REDISPP_WITH_TLS
}
bool operator==(const ConnectionOptions &o1, const ConnectionOptions &o2) {
inline bool operator==(const ConnectionOptions &o1, const ConnectionOptions &o2) {
return o1.type == o2.type && o1.host == o2.host && o1.port == o2.port &&
o1.path == o2.path && o1.user == o2.user &&
o1.password == o2.password && o1.db == o2.db &&
@ -72,8 +75,8 @@ bool operator==(const ConnectionOptions &o1, const ConnectionOptions &o2) {
}
#ifdef REDISPP_WITH_TLS
template <typename OStream>
OStream &operator<<(OStream &os, const tls::TlsOptions &t) {
namespace tls {
std::ostream &operator<<(std::ostream &os, const TlsOptions &t) {
os << "tls.enabled=" << (t.enabled ? "yes" : "no");
if (t.enabled) {
@ -95,10 +98,10 @@ OStream &operator<<(OStream &os, const tls::TlsOptions &t) {
return os;
}
}
#endif // REDISPP_WITH_TLS
template <typename OStream>
OStream &operator<<(OStream &os, const ConnectionType &t) {
inline std::ostream &operator<<(std::ostream &os, const ConnectionType &t) {
switch (t) {
case ConnectionType::TCP:
os << "tcp";
@ -112,8 +115,7 @@ OStream &operator<<(OStream &os, const ConnectionType &t) {
return os;
}
template <typename OStream>
OStream &operator<<(OStream &os, const ConnectionOptions &o) {
inline std::ostream &operator<<(std::ostream &os, const ConnectionOptions &o) {
os << "type=" << o.type;
switch (o.type) {
@ -139,36 +141,31 @@ OStream &operator<<(OStream &os, const ConnectionOptions &o) {
} // namespace redis
} // namespace sw
template <typename OStream>
OStream &operator<<(OStream &os, const enum villas::node::RedisMode &m) {
switch (m) {
case villas::node::RedisMode::KEY:
os << "key";
break;
case villas::node::RedisMode::HASH:
os << "hash";
break;
case villas::node::RedisMode::CHANNEL:
os << "channel";
break;
}
return os;
}
namespace villas {
namespace node {
#ifdef REDISPP_WITH_URI
sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) {
inline sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) {
auto u = sw::redis::Uri{uri};
return u.connection_options();
}
#else
sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) {
inline sw::redis::ConnectionOptions make_redis_connection_options(char const *uri) {
return sw::redis::ConnectionOptions{uri};
}
#endif
} // namespace node
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<sw::redis::ConnectionType>
: public fmt::ostream_formatter {};
template <>
class fmt::formatter<sw::redis::ConnectionOptions>
: public fmt::ostream_formatter {};
#ifdef REDISPP_WITH_TLS
template <>
class fmt::formatter<sw::redis::tls::TlsOptions>
: public fmt::ostream_formatter {};
#endif
#endif

View file

@ -9,7 +9,9 @@
#pragma once
#include <fmt/ostream.h>
#include <jansson.h>
#include <rtc/peerconnection.hpp>
#include <rtc/rtc.hpp>
#include <villas/log.hpp>
@ -17,6 +19,32 @@
#include <villas/signal_list.hpp>
#include <villas/web.hpp>
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
#include <fmt/ostream.h>
#endif
/*
* libdatachannel defines the operator<< overloads required to format
* rtc::PeerConnection::State and similar in the global namespace.
* But C++ ADL based overload set construction does not find these operators,
* if these are invoked in the spdlog/fmt libraries.
*
* See this issue for a short explaination of ADL errors:
* https://github.com/gabime/spdlog/issues/1227#issuecomment-532009129
*
* Adding the global ::operator<< overload set to the namespace rtc where
* the data structures are defined, allows ADL to pick these up in spdlog/fmt.
*/
namespace rtc {
using ::operator<<;
}
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<rtc::PeerConnection::State>
: public fmt::ostream_formatter {};
#endif
namespace villas {
namespace node {
namespace webrtc {

View file

@ -8,7 +8,6 @@
#pragma once
#include <libwebsockets.h>
#include <spdlog/fmt/ostr.h>
#include <villas/buffer.hpp>
#include <villas/common.hpp>
@ -19,6 +18,10 @@
#include <villas/pool.hpp>
#include <villas/queue_signalled.h>
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
#include <fmt/ostream.h>
#endif
// Forward declarations
struct lws;
@ -75,9 +78,7 @@ struct websocket_connection {
*send; // A buffer for constructing messages before calling lws_write()
} buffers;
// Custom formatter for spdlog
template <typename OStream>
friend OStream &operator<<(OStream &os,
friend std::ostream &operator<<(std::ostream &os,
const struct websocket_connection &c) {
if (c.wsi) {
char name[128];
@ -133,3 +134,9 @@ int websocket_write(NodeCompat *n, struct Sample *const smps[], unsigned cnt);
} // namespace node
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<villas::node::websocket_connection>
: public fmt::ostream_formatter {};
#endif

View file

@ -11,7 +11,6 @@
#include <jansson.h>
#include <pthread.h>
#include <spdlog/fmt/ostr.h>
#include <uuid/uuid.h>
#include <villas/colors.hpp>
@ -26,9 +25,12 @@
#include <villas/queue.h>
#include <villas/signal_list.hpp>
#include <villas/task.hpp>
#include <villas/log.hpp>
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
#include <fmt/ostream.h>
#endif
// Forward declarations
struct pollfd;
@ -99,9 +101,7 @@ public:
std::bitset<MAX_SAMPLE_LENGTH>
received; // A mask of PathSources for which we already received samples.
// Custom formatter for spdlog
template <typename OStream>
friend OStream &operator<<(OStream &os, const Path &p) {
friend std::ostream &operator<<(std::ostream &os, const Path &p) {
if (p.sources.size() > 1)
os << "[ ";
@ -185,3 +185,9 @@ public:
} // namespace node
} // namespace villas
#ifndef FMT_LEGACY_OSTREAM_FORMATTER
template <>
class fmt::formatter<villas::node::Path>
: public fmt::ostream_formatter {};
#endif

View file

@ -39,7 +39,7 @@ void LimitRateHook::parse(json_t *json) {
mode = LIMIT_RATE_LOCAL;
else
throw ConfigError(json, "node-config-hook-limit_rate-mode",
"Invalid value '{}' for setting 'mode'", mode);
"Invalid value '{}' for setting 'mode'", m);
}
deadtime = 1.0 / rate;

View file

@ -576,7 +576,7 @@ bool SlaveNode::onInterrogation(IMasterConnection connection, CS101_ASDU asdu,
bool SlaveNode::onASDU(IMasterConnection connection,
CS101_ASDU asdu) const noexcept {
logger->warn("Ignoring ASDU type {}", CS101_ASDU_getTypeID(asdu));
logger->warn("Ignoring ASDU type {}", (int)CS101_ASDU_getTypeID(asdu));
return true;
}

View file

@ -577,7 +577,7 @@ static void *ib_rdma_cm_event_thread(void *ctx) {
break;
default:
throw RuntimeError("Unknown event occurred: {}", event->event);
throw RuntimeError("Unknown event occurred: {}", (int)event->event);
}
rdma_ack_cm_event(event);
@ -836,7 +836,7 @@ int villas::node::ib_read(NodeCompat *n, struct Sample *const smps[],
n->logger->debug("Received IBV_WC_WR_FLUSH_ERR (ib_read). Ignore it.");
else if (wc[j].status != IBV_WC_SUCCESS)
n->logger->warn("Work Completion status was not IBV_WC_SUCCESS: {}",
wc[j].status);
(int)wc[j].status);
/* 32 byte of meta data is always transferred. We should substract it.
* Furthermore, in case of an unreliable connection, a 40 byte
@ -987,7 +987,7 @@ int villas::node::ib_write(NodeCompat *n, struct Sample *const smps[],
for (int i = 0; i < ret; i++) {
if (wc[i].status != IBV_WC_SUCCESS && wc[i].status != IBV_WC_WR_FLUSH_ERR)
n->logger->warn("Work Completion status was not IBV_WC_SUCCESS: {}",
wc[i].status);
(int)wc[i].status);
// TODO: fix release logic
// smps[*release] = (struct Sample *) (wc[i].wr_id);

View file

@ -24,22 +24,6 @@ using namespace villas;
using namespace villas::node;
using namespace villas::node::webrtc;
/*
* libdatachannel defines the operator<< overloads required to format
* rtc::PeerConnection::State and similar in the global namespace.
* But C++ ADL based overload set construction does not find these operators,
* if these are invoked in the spdlog/fmt libraries.
*
* See this issue for a short explaination of ADL errors:
* https://github.com/gabime/spdlog/issues/1227#issuecomment-532009129
*
* Adding the global ::operator<< overload set to the namespace rtc where
* the data structures are defined, allows ADL to pick these up in spdlog/fmt.
*/
namespace rtc {
using ::operator<<;
}
PeerConnection::PeerConnection(const std::string &server,
const std::string &session,
const std::string &peer,

View file

@ -124,7 +124,7 @@ static void websocket_connection_close(struct websocket_connection *c,
c->node->logger->debug(
"Closing WebSocket connection with {}: status={}, reason={}",
c->toString(), status, reason);
c->toString(), (int)status, reason);
c->state = websocket_connection::State::CLOSED;
}