mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
ci: fix all remaining cppcheck warnings and errors
This commit is contained in:
parent
20efb098e8
commit
c7c513a5f6
45 changed files with 146 additions and 148 deletions
|
@ -54,7 +54,6 @@ protected:
|
|||
|
||||
public:
|
||||
std::string uri;
|
||||
int method;
|
||||
std::smatch matches;
|
||||
json_t *body;
|
||||
|
||||
|
@ -68,14 +67,15 @@ public:
|
|||
OPTIONS,
|
||||
PUT,
|
||||
PATCH
|
||||
};
|
||||
} method;
|
||||
|
||||
Request(Session *s) :
|
||||
session(s),
|
||||
body(nullptr)
|
||||
{
|
||||
logger = logging.get("api:request");
|
||||
}
|
||||
logger(logging.get("api:request")),
|
||||
body(nullptr),
|
||||
factory(nullptr),
|
||||
method(Method::UNKNOWN)
|
||||
{ }
|
||||
|
||||
virtual ~Request()
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
make(Session *s) = 0;
|
||||
|
||||
static Request *
|
||||
make(Session *s, const std::string &uri, int meth);
|
||||
make(Session *s, const std::string &uri, Request::Method meth);
|
||||
};
|
||||
|
||||
template<typename T, const char *name, const char *re, const char *desc>
|
||||
|
|
|
@ -46,10 +46,10 @@ protected:
|
|||
public:
|
||||
LimitRateHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
LimitHook(p, n, fl, prio, en),
|
||||
mode(LIMIT_RATE_LOCAL)
|
||||
{
|
||||
last = (timespec) { 0, 0 };
|
||||
}
|
||||
mode(LIMIT_RATE_LOCAL),
|
||||
deadtime(0),
|
||||
last({0, 0})
|
||||
{ }
|
||||
|
||||
virtual void setRate(double rate, double maxRate = -1)
|
||||
{
|
||||
|
|
|
@ -42,11 +42,10 @@ InvalidMethod::InvalidMethod(Request *req) :
|
|||
{ }
|
||||
|
||||
Api::Api(SuperNode *sn) :
|
||||
logger(logging.get("api")),
|
||||
state(State::INITIALIZED),
|
||||
super_node(sn)
|
||||
{
|
||||
logger = logging.get("api");
|
||||
}
|
||||
{ }
|
||||
|
||||
Api::~Api()
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
using namespace villas;
|
||||
using namespace villas::node::api;
|
||||
|
||||
Request * RequestFactory::make(Session *s, const std::string &uri, int meth)
|
||||
Request * RequestFactory::make(Session *s, const std::string &uri, Request::Method meth)
|
||||
{
|
||||
for (auto *rf : plugin::Registry::lookup<RequestFactory>()) {
|
||||
std::smatch mr;
|
||||
|
|
|
@ -28,11 +28,10 @@ using namespace villas::node::api;
|
|||
|
||||
Response::Response(Session *s, json_t *resp) :
|
||||
session(s),
|
||||
logger(logging.get("api:response")),
|
||||
response(resp),
|
||||
code(HTTP_STATUS_OK)
|
||||
{
|
||||
logger = logging.get("api:response");
|
||||
}
|
||||
{ }
|
||||
|
||||
Response::~Response()
|
||||
{
|
||||
|
|
|
@ -37,10 +37,9 @@ using namespace villas::node;
|
|||
using namespace villas::node::api;
|
||||
|
||||
Session::Session(lws *w) :
|
||||
wsi(w)
|
||||
wsi(w),
|
||||
logger(logging.get("api:session"))
|
||||
{
|
||||
logger = logging.get("api:session");
|
||||
|
||||
lws_context *ctx = lws_get_context(wsi);
|
||||
void *user_ctx = lws_context_user(ctx);
|
||||
|
||||
|
@ -127,11 +126,11 @@ void Session::open(void *in, size_t len)
|
|||
char buf[32];
|
||||
unsigned long contentLength;
|
||||
|
||||
int meth;
|
||||
Request::Method meth;
|
||||
std::string uri = reinterpret_cast<char *>(in);
|
||||
|
||||
try {
|
||||
meth = getRequestMethod(wsi);
|
||||
meth = (Request::Method) getRequestMethod(wsi);
|
||||
if (meth == Request::Method::UNKNOWN)
|
||||
throw RuntimeError("Invalid request method");
|
||||
|
||||
|
|
|
@ -43,10 +43,9 @@ using namespace villas;
|
|||
using namespace villas::node;
|
||||
|
||||
Config::Config() :
|
||||
logger(logging.get("config")),
|
||||
root(nullptr)
|
||||
{
|
||||
logger = logging.get("config");
|
||||
}
|
||||
{ }
|
||||
|
||||
Config::Config(const std::string &u) :
|
||||
Config()
|
||||
|
|
|
@ -183,7 +183,7 @@ void csv_header(struct io *io, const struct sample *smp)
|
|||
if (sig->name)
|
||||
fprintf(f, "%s", sig->name);
|
||||
else
|
||||
fprintf(f, "signal%d", i);
|
||||
fprintf(f, "signal%u", i);
|
||||
|
||||
if (sig->unit)
|
||||
fprintf(f, "[%s]", sig->unit);
|
||||
|
|
|
@ -46,7 +46,7 @@ int iotagent_ul_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, str
|
|||
printed += snprintf(buf + printed, len - printed, "%s|%f|", sig->name, smp->data[i].f);
|
||||
else {
|
||||
char name[32];
|
||||
snprintf(name, 32, "signal_%d", i);
|
||||
snprintf(name, 32, "signal_%u", i);
|
||||
printed += snprintf(buf + printed, len - printed, "%s|%f|", name, smp->data[i].f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ static int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *sm
|
|||
json_name = json_string(sig->name);
|
||||
else {
|
||||
char name[32];
|
||||
snprintf(name, 32, "signal_%d", i);
|
||||
snprintf(name, 32, "signal%u", i);
|
||||
|
||||
json_name = json_string(name);
|
||||
}
|
||||
|
|
|
@ -56,15 +56,17 @@ int raw_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct samp
|
|||
int o = 0;
|
||||
size_t nlen;
|
||||
|
||||
int8_t *i8 = (int8_t *) buf;
|
||||
int16_t *i16 = (int16_t *) buf;
|
||||
int32_t *i32 = (int32_t *) buf;
|
||||
int64_t *i64 = (int64_t *) buf;
|
||||
float *f32 = (float *) buf;
|
||||
double *f64 = (double *) buf;
|
||||
void *vbuf = (char *) buf; // avoid warning about invalid pointer cast
|
||||
|
||||
int8_t *i8 = (int8_t *) vbuf;
|
||||
int16_t *i16 = (int16_t *) vbuf;
|
||||
int32_t *i32 = (int32_t *) vbuf;
|
||||
int64_t *i64 = (int64_t *) vbuf;
|
||||
float *f32 = (float *) vbuf;
|
||||
double *f64 = (double *) vbuf;
|
||||
#ifdef HAS_128BIT
|
||||
__int128 *i128 = (__int128 *) buf;
|
||||
__float128 *f128 = (__float128 *) buf;
|
||||
__int128 *i128 = (__int128 *) vbuf;
|
||||
__float128 *f128 = (__float128 *) vbuf;
|
||||
#endif
|
||||
|
||||
int bits = 1 << (io->flags >> 24);
|
||||
|
@ -226,8 +228,8 @@ int raw_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct samp
|
|||
break;
|
||||
#ifdef HAS_128BIT
|
||||
case 128:
|
||||
f128[o++] = SWAP_FLOAT_HTOX(io->flags & RAW_BIG_ENDIAN, 128, std::real(data->z);
|
||||
f128[o++] = SWAP_FLOAT_HTOX(io->flags & RAW_BIG_ENDIAN, 128, std::imag(data->z);
|
||||
f128[o++] = SWAP_FLOAT_HTOX(io->flags & RAW_BIG_ENDIAN, 128, std::real(data->z));
|
||||
f128[o++] = SWAP_FLOAT_HTOX(io->flags & RAW_BIG_ENDIAN, 128, std::imag(data->z));
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
@ -247,15 +249,17 @@ out: if (wbytes)
|
|||
|
||||
int raw_sscan(struct io *io, const char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt)
|
||||
{
|
||||
int8_t *i8 = (int8_t *) buf;
|
||||
int16_t *i16 = (int16_t *) buf;
|
||||
int32_t *i32 = (int32_t *) buf;
|
||||
int64_t *i64 = (int64_t *) buf;
|
||||
float *f32 = (float *) buf;
|
||||
double *f64 = (double *) buf;
|
||||
void *vbuf = (void *) buf; // avoid warning about invalid pointer cast
|
||||
|
||||
int8_t *i8 = (int8_t *) vbuf;
|
||||
int16_t *i16 = (int16_t *) vbuf;
|
||||
int32_t *i32 = (int32_t *) vbuf;
|
||||
int64_t *i64 = (int64_t *) vbuf;
|
||||
float *f32 = (float *) vbuf;
|
||||
double *f64 = (double *) vbuf;
|
||||
#ifdef HAS_128BIT
|
||||
__int128 *i128 = (__int128 *) buf;
|
||||
__float128 *f128 = (__float128 *) buf;
|
||||
__int128 *i128 = (__int128 *) vbuf;
|
||||
__float128 *f128 = (__float128 *) vbuf;
|
||||
#endif
|
||||
|
||||
/* The raw format can not encode multiple samples in one buffer
|
||||
|
|
|
@ -51,7 +51,7 @@ static size_t villas_human_sprint_single(struct io *io, char *buf, size_t len, c
|
|||
}
|
||||
|
||||
if (io->flags & (int) SampleFlags::HAS_SEQUENCE) {
|
||||
if (io->flags & (int) SampleFlags::HAS_SEQUENCE)
|
||||
if (smp->flags & (int) SampleFlags::HAS_SEQUENCE)
|
||||
off += snprintf(buf + off, len - off, "(%" PRIu64 ")", smp->sequence);
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ void villas_human_header(struct io *io, const struct sample *smp)
|
|||
if (sig->name)
|
||||
fprintf(f, "%c%s", io->separator, sig->name);
|
||||
else
|
||||
fprintf(f, "%csignal%d", io->separator, i);
|
||||
fprintf(f, "%csignal%u", io->separator, i);
|
||||
|
||||
if (sig->unit)
|
||||
fprintf(f, "[%s]", sig->unit);
|
||||
|
|
|
@ -39,17 +39,17 @@ using namespace villas;
|
|||
using namespace villas::node;
|
||||
|
||||
Hook::Hook(struct vpath *p, struct vnode *n, int fl, int prio, bool en) :
|
||||
logger(logging.get("hook")),
|
||||
state(State::INITIALIZED),
|
||||
flags(fl),
|
||||
priority(prio),
|
||||
enabled(en),
|
||||
path(p),
|
||||
node(n)
|
||||
node(n),
|
||||
cfg(nullptr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
logger = logging.get("hook");
|
||||
|
||||
ret = signal_list_init(&signals);
|
||||
if (ret)
|
||||
throw RuntimeError("Failed to initialize signal list");
|
||||
|
@ -61,7 +61,7 @@ Hook::Hook(struct vpath *p, struct vnode *n, int fl, int prio, bool en) :
|
|||
Hook::~Hook()
|
||||
{
|
||||
int ret __attribute__((unused));
|
||||
|
||||
|
||||
ret = signal_list_destroy(&signals);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ protected:
|
|||
|
||||
public:
|
||||
AverageHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en)
|
||||
Hook(p, n, fl, prio, en),
|
||||
offset(0)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -118,7 +118,17 @@ public:
|
|||
|
||||
DPHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en),
|
||||
inverse(0)
|
||||
signal_name(nullptr),
|
||||
signal_index(0),
|
||||
offset(0),
|
||||
inverse(0),
|
||||
f0(50.0),
|
||||
timestep(50e-6),
|
||||
time(),
|
||||
steps(0),
|
||||
coeffs(),
|
||||
fharmonics(),
|
||||
fharmonics_len(0)
|
||||
{ }
|
||||
|
||||
virtual ~DPHook()
|
||||
|
|
|
@ -61,11 +61,14 @@ public:
|
|||
GateHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en),
|
||||
mode(Mode::RISING_EDGE),
|
||||
signalName(),
|
||||
signalIndex(0),
|
||||
threshold(0.5),
|
||||
duration(-1),
|
||||
samples(-1),
|
||||
previousValue(std::numeric_limits<double>::quiet_NaN()),
|
||||
active(false)
|
||||
active(false),
|
||||
startSequence(0)
|
||||
{ }
|
||||
|
||||
virtual void parse(json_t *cfg)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
|
||||
|
@ -40,10 +41,11 @@ namespace node {
|
|||
class JitterCalcHook : public Hook {
|
||||
|
||||
protected:
|
||||
int64_t *jitter_val;
|
||||
int64_t *delay_series;
|
||||
int64_t *moving_avg;
|
||||
int64_t *moving_var;
|
||||
std::vector<int64_t> jitter_val;
|
||||
std::vector<int64_t> delay_series;
|
||||
std::vector<int64_t> moving_avg;
|
||||
std::vector<int64_t> moving_var;
|
||||
|
||||
int64_t delay_mov_sum;
|
||||
int64_t delay_mov_sum_sqrd;
|
||||
int curr_count;
|
||||
|
@ -51,35 +53,15 @@ protected:
|
|||
public:
|
||||
|
||||
JitterCalcHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en)
|
||||
{
|
||||
size_t sz = GPS_NTP_DELAY_WIN_SIZE;
|
||||
|
||||
jitter_val = new int64_t[sz];
|
||||
delay_series = new int64_t[sz];
|
||||
moving_avg = new int64_t[sz];
|
||||
moving_var = new int64_t[sz];
|
||||
|
||||
if (!jitter_val || !delay_series || !moving_avg || !moving_var)
|
||||
throw MemoryAllocationError();
|
||||
|
||||
memset(jitter_val, 0, sz);
|
||||
memset(delay_series, 0, sz);
|
||||
memset(moving_avg, 0, sz);
|
||||
memset(moving_var, 0, sz);
|
||||
|
||||
delay_mov_sum = 0;
|
||||
delay_mov_sum_sqrd = 0;
|
||||
curr_count = 0;
|
||||
}
|
||||
|
||||
~JitterCalcHook()
|
||||
{
|
||||
delete[] jitter_val;
|
||||
delete[] delay_series;
|
||||
delete[] moving_avg;
|
||||
delete[] moving_var;
|
||||
}
|
||||
Hook(p, n, fl, prio, en),
|
||||
jitter_val(GPS_NTP_DELAY_WIN_SIZE),
|
||||
delay_series(GPS_NTP_DELAY_WIN_SIZE),
|
||||
moving_avg(GPS_NTP_DELAY_WIN_SIZE),
|
||||
moving_var(GPS_NTP_DELAY_WIN_SIZE),
|
||||
delay_mov_sum(0),
|
||||
delay_mov_sum_sqrd(0),
|
||||
curr_count(0)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Hook to calculate jitter between GTNET-SKT GPS timestamp and Villas node NTP timestamp.
|
||||
|
|
|
@ -48,7 +48,9 @@ protected:
|
|||
|
||||
public:
|
||||
LimitValueHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en)
|
||||
Hook(p, n, fl, prio, en),
|
||||
offset(0),
|
||||
min(0), max(0)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ protected:
|
|||
public:
|
||||
PrintHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en),
|
||||
io(),
|
||||
prefix(nullptr),
|
||||
uri(nullptr)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,8 @@ protected:
|
|||
public:
|
||||
ScaleHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en),
|
||||
signal_name(nullptr),
|
||||
signal_index(0),
|
||||
scale(1),
|
||||
offset(0)
|
||||
{ }
|
||||
|
|
|
@ -65,6 +65,7 @@ protected:
|
|||
public:
|
||||
StatsReadHook(StatsHook *pa, struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en),
|
||||
last(nullptr),
|
||||
parent(pa)
|
||||
{
|
||||
state = State::CHECKED;
|
||||
|
@ -98,8 +99,8 @@ class StatsHook : public Hook {
|
|||
friend StatsWriteHook;
|
||||
|
||||
protected:
|
||||
StatsReadHook *readHook;
|
||||
StatsWriteHook *writeHook;
|
||||
StatsReadHook readHook;
|
||||
StatsWriteHook writeHook;
|
||||
|
||||
enum Stats::Format format;
|
||||
int verbose;
|
||||
|
@ -115,6 +116,8 @@ public:
|
|||
|
||||
StatsHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en),
|
||||
readHook(this, p, n, fl, prio, en),
|
||||
writeHook(this, p, n, fl, prio, en),
|
||||
format(Stats::Format::HUMAN),
|
||||
verbose(0),
|
||||
warmup(500),
|
||||
|
@ -123,15 +126,9 @@ public:
|
|||
uri()
|
||||
{
|
||||
/* Add child hooks */
|
||||
readHook = new StatsReadHook(this, p, n, fl, prio, en);
|
||||
writeHook = new StatsWriteHook(this, p, n, fl, prio, en);
|
||||
|
||||
if (!readHook || !writeHook)
|
||||
throw MemoryAllocationError();
|
||||
|
||||
if (node) {
|
||||
vlist_push(&node->in.hooks, (void *) readHook);
|
||||
vlist_push(&node->out.hooks, (void *) writeHook);
|
||||
vlist_push(&node->in.hooks, (void *) &readHook);
|
||||
vlist_push(&node->out.hooks, (void *) &writeHook);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +168,7 @@ public:
|
|||
{
|
||||
// Only call readHook if it hasnt been added to the node's hook list
|
||||
if (!node)
|
||||
return readHook->process(smp);
|
||||
return readHook.process(smp);
|
||||
|
||||
return Hook::Reason::OK;
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ int if_set_affinity(struct interface *i, int affinity)
|
|||
FILE *file;
|
||||
|
||||
for (int n = 0; n < IF_IRQ_MAX && i->irqs[n]; n++) {
|
||||
snprintf(filename, sizeof(filename), "/proc/irq/%u/smp_affinity", i->irqs[n]);
|
||||
snprintf(filename, sizeof(filename), "/proc/irq/%d/smp_affinity", (int) i->irqs[n]);
|
||||
|
||||
file = fopen(filename, "w");
|
||||
if (file) {
|
||||
|
|
|
@ -285,7 +285,7 @@ int node_start(struct vnode *n)
|
|||
|
||||
ret = setsockopt(fd, SOL_SOCKET, SO_MARK, &n->fwmark, sizeof(n->fwmark));
|
||||
if (ret)
|
||||
serror("Failed to set FW mark for outgoing packets");
|
||||
throw RuntimeError("Failed to set FW mark for outgoing packets");
|
||||
else
|
||||
debug(LOG_SOCKET | 4, "Set FW mark for socket (sd=%u) to %u", fd, n->fwmark);
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ int node_start(struct vnode *n)
|
|||
n->state = State::STARTED;
|
||||
n->sequence = 0;
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int node_stop(struct vnode *n)
|
||||
|
|
|
@ -951,9 +951,6 @@ char* comedi_cmd_trigger_src(unsigned int src, char *buf)
|
|||
if (src & TRIG_COUNT) strcat(buf, "count|");
|
||||
if (src & TRIG_EXT) strcat(buf, "ext|");
|
||||
if (src & TRIG_INT) strcat(buf, "int|");
|
||||
#ifdef TRIG_OTHER
|
||||
if (src & TRIG_OTHER) strcat(buf, "other|");
|
||||
#endif
|
||||
|
||||
if (strlen(buf) == 0)
|
||||
sprintf(buf, "unknown(0x%08x)", src);
|
||||
|
|
|
@ -157,7 +157,7 @@ int influxdb_write(struct vnode *n, struct sample *smps[], unsigned cnt, unsigne
|
|||
if (sig->name)
|
||||
strncpy(name, sig->name, sizeof(name));
|
||||
else
|
||||
snprintf(name, sizeof(name), "value%d", j);
|
||||
snprintf(name, sizeof(name), "value%u", j);
|
||||
|
||||
if (sig->type == SignalType::COMPLEX) {
|
||||
strcatf(&buf, "%s_re=%f, %s_im=%f",
|
||||
|
|
|
@ -439,7 +439,7 @@ int rtp_stop(struct vnode *n)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtp_destroy(struct vnode *n)
|
||||
|
@ -508,7 +508,7 @@ int rtp_type_start(villas::node::SuperNode *sn)
|
|||
}
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtp_type_stop()
|
||||
|
|
|
@ -273,7 +273,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
|
|||
|
||||
case LWS_CALLBACK_CLIENT_WRITEABLE:
|
||||
case LWS_CALLBACK_SERVER_WRITEABLE: {
|
||||
struct sample **smps = (struct sample **) alloca(cnt * sizeof(struct sample *));
|
||||
struct sample *smps[cnt];
|
||||
|
||||
pulled = queue_pull_many(&c->queue, (void **) smps, cnt);
|
||||
if (pulled > 0) {
|
||||
|
@ -318,7 +318,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
|
|||
|
||||
int avail, enqueued;
|
||||
struct websocket *w = (struct websocket *) n->_vd;
|
||||
struct sample **smps = (struct sample **) alloca(cnt * sizeof(struct sample *));
|
||||
struct sample *smps[cnt];
|
||||
if (!smps) {
|
||||
warning("Failed to allocate memory for connection: %s", websocket_connection_name(c));
|
||||
break;
|
||||
|
|
|
@ -235,7 +235,7 @@ int sample_cmp(struct sample *a, struct sample *b, double epsilon, int flags)
|
|||
/* Compare data */
|
||||
if (flags & (int) SampleFlags::HAS_DATA) {
|
||||
if (a->length != b->length) {
|
||||
printf("length: %d != %d\n", a->length, b->length);
|
||||
printf("length: %u != %u\n", a->length, b->length);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -247,28 +247,28 @@ int sample_cmp(struct sample *a, struct sample *b, double epsilon, int flags)
|
|||
switch (sample_format(a, i)) {
|
||||
case SignalType::FLOAT:
|
||||
if (fabs(a->data[i].f - b->data[i].f) > epsilon) {
|
||||
printf("data[%d].f: %f != %f\n", i, a->data[i].f, b->data[i].f);
|
||||
printf("data[%u].f: %f != %f\n", i, a->data[i].f, b->data[i].f);
|
||||
return 5;
|
||||
}
|
||||
break;
|
||||
|
||||
case SignalType::INTEGER:
|
||||
if (a->data[i].i != b->data[i].i) {
|
||||
printf("data[%d].i: %" PRId64 " != %" PRId64 "\n", i, a->data[i].i, b->data[i].i);
|
||||
printf("data[%u].i: %" PRId64 " != %" PRId64 "\n", i, a->data[i].i, b->data[i].i);
|
||||
return 5;
|
||||
}
|
||||
break;
|
||||
|
||||
case SignalType::BOOLEAN:
|
||||
if (a->data[i].b != b->data[i].b) {
|
||||
printf("data[%d].b: %s != %s\n", i, a->data[i].b ? "true" : "false", b->data[i].b ? "true" : "false");
|
||||
printf("data[%u].b: %s != %s\n", i, a->data[i].b ? "true" : "false", b->data[i].b ? "true" : "false");
|
||||
return 5;
|
||||
}
|
||||
break;
|
||||
|
||||
case SignalType::COMPLEX:
|
||||
if (std::abs(a->data[i].z - b->data[i].z) > epsilon) {
|
||||
printf("data[%d].z: %f+%fi != %f+%fi\n", i, std::real(a->data[i].z), std::imag(a->data[i].z), std::real(b->data[i].z), std::imag(b->data[i].z));
|
||||
printf("data[%u].z: %f+%fi != %f+%fi\n", i, std::real(a->data[i].z), std::imag(a->data[i].z), std::real(b->data[i].z), std::imag(b->data[i].z));
|
||||
return 5;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -61,7 +61,6 @@ void signal_data_cast(union signal_data *data, const struct signal *from, const
|
|||
case SignalType::BOOLEAN:
|
||||
switch(from->type) {
|
||||
case SignalType::BOOLEAN:
|
||||
data->b = data->b;
|
||||
break;
|
||||
|
||||
case SignalType::INTEGER:
|
||||
|
@ -87,7 +86,6 @@ void signal_data_cast(union signal_data *data, const struct signal *from, const
|
|||
break;
|
||||
|
||||
case SignalType::INTEGER:
|
||||
data->i = data->i;
|
||||
break;
|
||||
|
||||
case SignalType::FLOAT:
|
||||
|
@ -113,7 +111,6 @@ void signal_data_cast(union signal_data *data, const struct signal *from, const
|
|||
break;
|
||||
|
||||
case SignalType::FLOAT:
|
||||
data->f = data->f;
|
||||
break;
|
||||
|
||||
case SignalType::COMPLEX:
|
||||
|
@ -139,7 +136,6 @@ void signal_data_cast(union signal_data *data, const struct signal *from, const
|
|||
break;
|
||||
|
||||
case SignalType::COMPLEX:
|
||||
data->z = data->z;
|
||||
break;
|
||||
|
||||
default: { }
|
||||
|
|
|
@ -87,7 +87,7 @@ int signal_list_generate(struct vlist *list, unsigned len, enum SignalType typ)
|
|||
char name[32];
|
||||
|
||||
for (unsigned i = 0; i < len; i++) {
|
||||
snprintf(name, sizeof(name), "signal%d", i);
|
||||
snprintf(name, sizeof(name), "signal%u", i);
|
||||
|
||||
struct signal *sig = signal_create(name, nullptr, typ);
|
||||
if (!sig)
|
||||
|
|
14
lib/web.cpp
14
lib/web.cpp
|
@ -176,19 +176,15 @@ void Web::worker()
|
|||
|
||||
Web::Web(Api *a) :
|
||||
state(State::INITIALIZED),
|
||||
logger(logging.get("web")),
|
||||
context(nullptr),
|
||||
vhost(nullptr),
|
||||
port(getuid() > 0 ? 8080 : 80),
|
||||
htdocs(WEB_PATH),
|
||||
api(a)
|
||||
{
|
||||
int lvl = LLL_ERR | LLL_WARN | LLL_NOTICE;
|
||||
|
||||
/** @todo: Port to C++: add LLL_DEBUG and others if trace log level is activated */
|
||||
|
||||
lws_set_log_level(lvl, lwsLogger);
|
||||
|
||||
/* Default values */
|
||||
port = getuid() > 0 ? 8080 : 80;
|
||||
|
||||
logger = logging.get("web");
|
||||
lws_set_log_level(LLL_ERR | LLL_WARN | LLL_NOTICE, lwsLogger);
|
||||
}
|
||||
|
||||
int Web::parse(json_t *cfg)
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
stop(false),
|
||||
format("villas.human"),
|
||||
dtypes("64f"),
|
||||
p(),
|
||||
io(),
|
||||
cnt(1)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
~PipeDirection()
|
||||
{
|
||||
int ret __attribute__((unused));
|
||||
|
||||
|
||||
ret = pool_destroy(&pool);
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ public:
|
|||
goto leave;
|
||||
}
|
||||
|
||||
leave2:
|
||||
leave2:
|
||||
logger->info("Send thread stopped");
|
||||
return;
|
||||
|
||||
|
@ -243,10 +243,12 @@ public:
|
|||
Pipe(int argc, char *argv[]) :
|
||||
Tool(argc, argv, "pipe"),
|
||||
stop(false),
|
||||
io(),
|
||||
timeout(0),
|
||||
reverse(false),
|
||||
format("villas.human"),
|
||||
dtypes("64f"),
|
||||
cfg_cli(json_object()),
|
||||
enable_send(true),
|
||||
enable_recv(true),
|
||||
limit_send(-1),
|
||||
|
@ -257,8 +259,6 @@ public:
|
|||
ret = memory_init(DEFAULT_NR_HUGEPAGES);
|
||||
if (ret)
|
||||
throw RuntimeError("Failed to initialize memory");
|
||||
|
||||
cfg_cli = json_object();
|
||||
}
|
||||
|
||||
~Pipe()
|
||||
|
|
|
@ -224,6 +224,8 @@ void RelayConnection::read(void *in, size_t len)
|
|||
Relay::Relay(int argc, char *argv[]) :
|
||||
Tool(argc, argv, "relay"),
|
||||
stop(false),
|
||||
context(nullptr),
|
||||
vhost(nullptr),
|
||||
loopback(false),
|
||||
port(8088),
|
||||
protocol("live")
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
Signal(int argc, char *argv[]) :
|
||||
Tool(argc, argv, "signal"),
|
||||
stop(false),
|
||||
n(),
|
||||
io(),
|
||||
q(),
|
||||
format("villas.human")
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -78,15 +78,10 @@ public:
|
|||
|
||||
~TestCmpSide() noexcept(false)
|
||||
{
|
||||
int ret;
|
||||
int ret __attribute((unused));
|
||||
|
||||
ret = io_close(&io);
|
||||
if (ret)
|
||||
throw RuntimeError("Failed to close IO");
|
||||
|
||||
ret = io_destroy(&io);
|
||||
if (ret)
|
||||
throw RuntimeError("Failed to destroy IO");
|
||||
|
||||
sample_decref(sample);
|
||||
}
|
||||
|
@ -97,6 +92,7 @@ class TestCmp : public Tool {
|
|||
public:
|
||||
TestCmp(int argc, char *argv[]) :
|
||||
Tool(argc, argv, "test-cmp"),
|
||||
pool(),
|
||||
epsilon(1e-9),
|
||||
format("villas.human"),
|
||||
dtypes("64f"),
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
namespace fs = std::filesystem;
|
||||
using namespace villas::node;
|
||||
|
||||
// cppcheck-suppress syntaxError
|
||||
Test(config, env)
|
||||
{
|
||||
const char *cfg_f = "test = \"${MY_ENV_VAR}\"\n";
|
||||
|
@ -54,7 +55,6 @@ Test(config, env)
|
|||
cr_assert_str_eq("mobydick", json_string_value(j));
|
||||
}
|
||||
|
||||
|
||||
Test(config, include)
|
||||
{
|
||||
const char *cfg_f2 = "magic = 1234\n";
|
||||
|
|
|
@ -59,6 +59,7 @@ const char *json_example = "{\n"
|
|||
" ]\n"
|
||||
"}";
|
||||
|
||||
// cppcheck-suppress syntaxError
|
||||
Test(config, config_to_json)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -217,6 +217,7 @@ ParameterizedTestParameters(io, lowlevel)
|
|||
return params;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unknownMacro
|
||||
ParameterizedTest(Param *p, io, lowlevel, .init = init_memory)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -34,6 +34,7 @@ struct param {
|
|||
char *json;
|
||||
};
|
||||
|
||||
// cppcheck-suppress syntaxError
|
||||
ParameterizedTestParameters(json, json_load_cli)
|
||||
{
|
||||
const auto d = cr_strdup;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
// cppcheck-suppress syntaxError
|
||||
Test(mapping, parse_nodes)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -40,6 +40,7 @@ TheoryDataPoints(memory, aligned) = {
|
|||
DataPoints(struct memory_type *, &memory_heap, &memory_mmap_hugetlb, &memory_mmap_hugetlb)
|
||||
};
|
||||
|
||||
// cppcheck-suppress unknownMacro
|
||||
Theory((size_t len, size_t align, struct memory_type *mt), memory, aligned, .init = init_memory) {
|
||||
int ret;
|
||||
void *ptr;
|
||||
|
|
|
@ -49,6 +49,7 @@ ParameterizedTestParameters(pool, basic)
|
|||
return cr_make_param_array(struct param, params, ARRAY_LEN(params));
|
||||
}
|
||||
|
||||
// cppcheck-suppress unknownMacro
|
||||
ParameterizedTest(struct param *p, pool, basic, .init = init_memory)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -127,6 +127,7 @@ ParameterizedTestParameters(queue_signalled, simple)
|
|||
return cr_make_param_array(struct param, params, ARRAY_LEN(params));
|
||||
}
|
||||
|
||||
// cppcheck-suppress unknownMacro
|
||||
ParameterizedTest(struct param *param, queue_signalled, simple, .timeout = 5, .init = init_memory)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
extern void init_memory();
|
||||
|
||||
// cppcheck-suppress unknownMacro
|
||||
Test(signal, parse, .init = init_memory) {
|
||||
int ret;
|
||||
struct signal sig;
|
||||
|
@ -36,7 +37,7 @@ Test(signal, parse, .init = init_memory) {
|
|||
|
||||
str = "1";
|
||||
sig.type = SignalType::INTEGER;
|
||||
|
||||
|
||||
ret = signal_data_parse_str(&sd, &sig, str, &end);
|
||||
cr_assert_eq(ret, 0);
|
||||
cr_assert_eq(end, str + strlen(str));
|
||||
|
@ -44,7 +45,7 @@ Test(signal, parse, .init = init_memory) {
|
|||
|
||||
str = "1.2";
|
||||
sig.type = SignalType::FLOAT;
|
||||
|
||||
|
||||
ret = signal_data_parse_str(&sd, &sig, str, &end);
|
||||
cr_assert_eq(ret, 0);
|
||||
cr_assert_eq(end, str + strlen(str));
|
||||
|
@ -52,7 +53,7 @@ Test(signal, parse, .init = init_memory) {
|
|||
|
||||
str = "1";
|
||||
sig.type = SignalType::BOOLEAN;
|
||||
|
||||
|
||||
ret = signal_data_parse_str(&sd, &sig, str, &end);
|
||||
cr_assert_eq(ret, 0);
|
||||
cr_assert_eq(end, str + strlen(str));
|
||||
|
@ -60,7 +61,7 @@ Test(signal, parse, .init = init_memory) {
|
|||
|
||||
str = "1";
|
||||
sig.type = SignalType::COMPLEX;
|
||||
|
||||
|
||||
ret = signal_data_parse_str(&sd, &sig, str, &end);
|
||||
cr_assert_eq(ret, 0);
|
||||
cr_assert_eq(end, str + strlen(str));
|
||||
|
@ -69,7 +70,7 @@ Test(signal, parse, .init = init_memory) {
|
|||
|
||||
str = "-1-3i";
|
||||
sig.type = SignalType::COMPLEX;
|
||||
|
||||
|
||||
ret = signal_data_parse_str(&sd, &sig, str, &end);
|
||||
cr_assert_eq(ret, 0);
|
||||
cr_assert_eq(end, str + strlen(str));
|
||||
|
@ -78,7 +79,7 @@ Test(signal, parse, .init = init_memory) {
|
|||
|
||||
str = "-3i";
|
||||
sig.type = SignalType::COMPLEX;
|
||||
|
||||
|
||||
ret = signal_data_parse_str(&sd, &sig, str, &end);
|
||||
cr_assert_eq(ret, 0);
|
||||
cr_assert_eq(end, str + strlen(str));
|
||||
|
|
Loading…
Add table
Reference in a new issue