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

warn about unused return values for *_{init,destroy}() functions

This commit is contained in:
Steffen Vogel 2020-09-10 11:11:42 +02:00
parent b467169d3c
commit 6411fc5ca7
56 changed files with 240 additions and 151 deletions

2
common

@ -1 +1 @@
Subproject commit 7f356d91d5fe81e91ec552583fb5b307ccaa723d
Subproject commit 9533016a49e2880af995d69758eead89488b0b69

View file

@ -39,9 +39,9 @@ struct sample;
struct vpath;
struct vnode;
int hook_list_init(struct vlist *hs);
int hook_list_init(struct vlist *hs) __attribute__ ((warn_unused_result));
int hook_list_destroy(struct vlist *hs);
int hook_list_destroy(struct vlist *hs) __attribute__ ((warn_unused_result));
/** Parses an object of hooks
*

View file

@ -76,11 +76,11 @@ struct io {
const struct format_type *_vt;
};
int io_init(struct io *io, const struct format_type *fmt, struct vlist *signals, int flags);
int io_init(struct io *io, const struct format_type *fmt, struct vlist *signals, int flags) __attribute__ ((warn_unused_result));
int io_init2(struct io *io, const struct format_type *fmt, const char *dt, int flags);
int io_init2(struct io *io, const struct format_type *fmt, const char *dt, int flags) __attribute__ ((warn_unused_result));
int io_destroy(struct io *io);
int io_destroy(struct io *io) __attribute__ ((warn_unused_result));
int io_check(struct io *io);

View file

@ -62,7 +62,7 @@ struct interface {
* @retval >0 Success. A pointer to the new interface.
* @retval 0 Error. The creation failed.
*/
int if_init(struct interface * , struct rtnl_link *link);
int if_init(struct interface * , struct rtnl_link *link) __attribute__ ((warn_unused_result));
/** Get name of interface */
const char * if_name(struct interface *);
@ -71,7 +71,7 @@ const char * if_name(struct interface *);
*
* @param i A pointer to the interface structure.
*/
int if_destroy(struct interface *i);
int if_destroy(struct interface *i) __attribute__ ((warn_unused_result));
/** Start interface.
*

View file

@ -64,7 +64,7 @@ struct memory_allocation {
};
/** Initilialize memory subsystem */
int memory_init(int hugepages);
int memory_init(int hugepages) __attribute__ ((warn_unused_result));
int memory_lock(size_t lock);

View file

@ -60,4 +60,4 @@ extern struct memory_type *memory_default;
struct memory_type * memory_ib(struct vnode *n, struct memory_type *parent);
struct memory_type * memory_managed(void *ptr, size_t len);
int memory_mmap_init(int hugepages);
int memory_mmap_init(int hugepages) __attribute__ ((warn_unused_result));

View file

@ -101,7 +101,7 @@ struct vnode {
};
/** Initialize node with default values */
int node_init(struct vnode *n, struct vnode_type *vt);
int node_init(struct vnode *n, struct vnode_type *vt) __attribute__ ((warn_unused_result));
/** Do initialization after parsing the configuration */
int node_prepare(struct vnode *n);
@ -166,7 +166,7 @@ int node_restart(struct vnode *n);
*
* @see node_type::destroy
*/
int node_destroy(struct vnode *n);
int node_destroy(struct vnode *n) __attribute__ ((warn_unused_result));
/** Return a pointer to a string which should be used to print this node.
*

View file

@ -55,7 +55,9 @@ struct vnode_direction {
json_t *cfg; /**< A JSON object containing the configuration of the node. */
};
int node_direction_init(struct vnode_direction *nd, enum NodeDir dir, struct vnode *n);
int node_direction_init(struct vnode_direction *nd, enum NodeDir dir, struct vnode *n) __attribute__ ((warn_unused_result));
int node_direction_destroy(struct vnode_direction *nd, struct vnode *n) __attribute__ ((warn_unused_result));
int node_direction_parse(struct vnode_direction *nd, struct vnode *n, json_t *cfg);
@ -67,8 +69,6 @@ int node_direction_start(struct vnode_direction *nd, struct vnode *n);
int node_direction_stop(struct vnode_direction *nd, struct vnode *n);
int node_direction_destroy(struct vnode_direction *nd, struct vnode *n);
struct vlist * node_direction_get_signals(struct vnode_direction *nd);
/** @} */

View file

@ -98,7 +98,7 @@ struct vpath {
};
/** Initialize internal data structures. */
int path_init(struct vpath *p);
int path_init(struct vpath *p) __attribute__ ((warn_unused_result));
int path_prepare(struct vpath *p);
@ -127,7 +127,7 @@ int path_stop(struct vpath *p);
*
* @param i A pointer to the path structure.
*/
int path_destroy(struct vpath *p);
int path_destroy(struct vpath *p) __attribute__ ((warn_unused_result));
/** Fills the provided buffer with a string representation of the path.
*

View file

@ -57,10 +57,10 @@ struct pool {
* @retval 0 The pool has been successfully initialized.
* @retval <>0 There was an error during the pool initialization.
*/
int pool_init(struct pool *p, size_t cnt, size_t blocksz, struct memory_type *mem = memory_default);
int pool_init(struct pool *p, size_t cnt, size_t blocksz, struct memory_type *mem = memory_default) __attribute__ ((warn_unused_result));
/** Destroy and release memory used by pool. */
int pool_destroy(struct pool *p);
int pool_destroy(struct pool *p) __attribute__ ((warn_unused_result));
/** Pop up to \p cnt values from the stack an place them in the array \p blocks.
*

View file

@ -71,10 +71,10 @@ struct queue {
};
/** Initialize MPMC queue */
int queue_init(struct queue *q, size_t size, struct memory_type *mem = memory_default);
int queue_init(struct queue *q, size_t size, struct memory_type *mem = memory_default) __attribute__ ((warn_unused_result));
/** Desroy MPMC queue and release memory */
int queue_destroy(struct queue *q);
int queue_destroy(struct queue *q) __attribute__ ((warn_unused_result));
/** Return estimation of current queue usage.
*

View file

@ -64,19 +64,19 @@ struct queue_signalled {
#define queue_signalled_available(q) queue_available(&((q)->queue))
int queue_signalled_init(struct queue_signalled *qs, size_t size, struct memory_type *mem = memory_default, enum QueueSignalledMode mode = QueueSignalledMode::AUTO, int flags = 0);
int queue_signalled_init(struct queue_signalled *qs, size_t size, struct memory_type *mem = memory_default, enum QueueSignalledMode mode = QueueSignalledMode::AUTO, int flags = 0) __attribute__ ((warn_unused_result));
int queue_signalled_destroy(struct queue_signalled *qs);
int queue_signalled_destroy(struct queue_signalled *qs) __attribute__ ((warn_unused_result));
int queue_signalled_push(struct queue_signalled *qs, void *ptr);
int queue_signalled_push(struct queue_signalled *qs, void *ptr) __attribute__ ((warn_unused_result));
int queue_signalled_pull(struct queue_signalled *qs, void **ptr);
int queue_signalled_pull(struct queue_signalled *qs, void **ptr) __attribute__ ((warn_unused_result));
int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cnt);
int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cnt) __attribute__ ((warn_unused_result));
int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cnt);
int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cnt) __attribute__ ((warn_unused_result));
int queue_signalled_close(struct queue_signalled *qs);
int queue_signalled_close(struct queue_signalled *qs) __attribute__ ((warn_unused_result));
/** Returns a file descriptor which can be used with poll / select to wait for new data */
int queue_signalled_fd(struct queue_signalled *qs);

View file

@ -55,16 +55,16 @@ struct signal {
};
/** Initialize a signal with default values. */
int signal_init(struct signal *s);
int signal_init(struct signal *s) __attribute__ ((warn_unused_result));
/** Destroy a signal and release memory. */
int signal_destroy(struct signal *s);
int signal_destroy(struct signal *s) __attribute__ ((warn_unused_result));
/** Allocate memory for a new signal, and initialize it with provided values. */
struct signal * signal_create(const char *name, const char *unit, enum SignalType fmt);
struct signal * signal_create(const char *name, const char *unit, enum SignalType fmt) __attribute__ ((warn_unused_result));
/** Destroy and release memory of signal. */
int signal_free(struct signal *s);
int signal_free(struct signal *s) __attribute__ ((warn_unused_result));
/** Increase reference counter. */
int signal_incref(struct signal *s);

View file

@ -30,9 +30,9 @@
/* Forward declarations */
struct vlist;
int signal_list_init(struct vlist *list);
int signal_list_init(struct vlist *list) __attribute__ ((warn_unused_result));
int signal_list_destroy(struct vlist *list);
int signal_list_destroy(struct vlist *list) __attribute__ ((warn_unused_result));
int signal_list_parse(struct vlist *list, json_t *cfg);

View file

@ -66,7 +66,7 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.format.sprint = iotagent_ul_sprint;
p.format.size = 0;
vlist_push(&plugins, &p);
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110))) static void UNIQUE(__dtor)() {

View file

@ -352,7 +352,7 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.format.flags = (int) SampleFlags::HAS_TS_ORIGIN | (int) SampleFlags::HAS_SEQUENCE | (int) SampleFlags::HAS_DATA;
p.format.delimiter = '\n';
vlist_push(&plugins, &p);
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110))) static void UNIQUE(__dtor)() {

View file

@ -333,7 +333,7 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.format.sscan = json_reserve_sscan;
p.format.size = 0;
vlist_push(&plugins, &p);
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110))) static void UNIQUE(__dtor)() {

View file

@ -255,7 +255,7 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.format.flags = (int) IOFlags::HAS_BINARY_PAYLOAD |
(int) SampleFlags::HAS_TS_ORIGIN | (int) SampleFlags::HAS_SEQUENCE | (int) SampleFlags::HAS_DATA;
vlist_push(&plugins, &p);
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110))) static void UNIQUE(__dtor)() {

View file

@ -94,9 +94,6 @@ out: smp->flags = 0;
static struct plugin p;
__attribute__((constructor(110))) static void UNIQUE(__ctor)() {
if (plugins.state == State::DESTROYED)
vlist_init(&plugins);
p.name = "value";
p.description = "A bare text value without any headers";
p.type = PluginType::FORMAT;
@ -105,7 +102,7 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.format.size = 0;
p.format.flags = (int) SampleFlags::HAS_DATA | (int) IOFlags::NEWLINES;
vlist_push(&plugins, &p);
vlist_init_and_push(&plugins, &p);;
}
__attribute__((destructor(110))) static void UNIQUE(__dtor)() {

View file

@ -237,7 +237,7 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.format.delimiter = '\n';
p.format.separator = '\t';
vlist_push(&plugins, &p);
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110))) static void UNIQUE(__dtor)() {

View file

@ -60,7 +60,9 @@ Hook::Hook(struct vpath *p, struct vnode *n, int fl, int prio, bool en) :
Hook::~Hook()
{
signal_list_destroy(&signals);
int ret __attribute__((unused));
ret = signal_list_destroy(&signals);
}
void Hook::prepare()

View file

@ -59,7 +59,9 @@ public:
virtual ~AverageHook()
{
vlist_destroy(&signal_names, nullptr, true);
int ret __attribute__((unused));
ret = vlist_destroy(&signal_names, nullptr, true);
}
virtual void prepare()

View file

@ -61,7 +61,9 @@ public:
virtual ~LimitValueHook()
{
vlist_destroy(&signal_names, nullptr, true);
int ret __attribute__((unused));
ret = vlist_destroy(&signal_names, nullptr, true);
}
virtual void prepare()

View file

@ -44,6 +44,8 @@ using namespace villas::utils;
int if_init(struct interface *i, struct rtnl_link *link)
{
int ret;
i->nl_link = link;
debug(LOG_IF | 3, "Created interface '%s'", if_name(i));
@ -54,15 +56,21 @@ int if_init(struct interface *i, struct rtnl_link *link)
else
warning("Did not found any interrupts for interface '%s'", if_name(i));
vlist_init(&i->nodes);
ret = vlist_init(&i->nodes);
if (ret)
return ret;
return 0;
}
int if_destroy(struct interface *i)
{
int ret;
/* List members are freed by the nodes they belong to. */
vlist_destroy(&i->nodes, nullptr, false);
ret = vlist_destroy(&i->nodes);
if (ret)
return ret;
rtnl_qdisc_put(i->tc_qdisc);

View file

@ -413,8 +413,9 @@ static void register_plugin() {
p.node.write = amqp_write;
p.node.poll_fds = amqp_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -558,9 +558,6 @@ int can_poll_fds(struct vnode *n, int fds[])
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == State::DESTROYED)
vlist_init(&plugins);
p.name = "can";
p.description = "Receive CAN messages using the socketCAN driver";
p.node.instances.state = State::DESTROYED;
@ -578,8 +575,9 @@ static void register_plugin() {
p.node.write = can_write;
p.node.poll_fds = can_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -1013,8 +1013,9 @@ static void register_plugin() {
p.node.write = comedi_write;
p.node.poll_fds = comedi_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -61,6 +61,7 @@ struct coupler {
static void ethercat_cyclic_task(struct vnode *n)
{
int ret;
struct sample *smp;
struct ethercat *w = (struct ethercat *) n->_vd;
@ -89,7 +90,9 @@ static void ethercat_cyclic_task(struct vnode *n)
smp->data[i].f = w->in.range * (float) ain_value / INT16_MAX;
}
queue_signalled_push(&w->queue, smp);
ret = queue_signalled_push(&w->queue, smp);
if (ret)
warning("Ethercat: Failed to enqueue samples");
/* Write process data */
smp = w->send.exchange(nullptr);
@ -464,8 +467,9 @@ static void register_plugin() {
p.node.write = ethercat_write;
p.node.poll_fds = ethercat_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -254,8 +254,9 @@ static void register_plugin() {
p.node.poll_fds = example_poll_fds;
p.node.netem_fds = example_netem_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -285,8 +285,9 @@ static void register_plugin() {
p.node.write = exec_write;
p.node.poll_fds = exec_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -513,8 +513,9 @@ static void register_plugin() {
p.node.write = file_write;
p.node.poll_fds = file_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -327,9 +327,6 @@ int fpga_poll_fds(struct vnode *n, int fds[])
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == State::DESTROYED)
vlist_init(&plugins);
p.name = "fpga";
p.description = "Communicate with VILLASfpga Xilinx FPGA boards";
p.type = PluginType::NODE;
@ -350,8 +347,9 @@ static void register_plugin() {
p.node.write = fpga_write;
p.node.poll_fds = fpga_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -220,7 +220,9 @@ int iec61850_type_stop()
EthernetHandleSet_destroy(hset);
vlist_destroy(&receivers, (dtor_cb_t) iec61850_receiver_destroy, true);
ret = vlist_destroy(&receivers, (dtor_cb_t) iec61850_receiver_destroy, true);
if (ret)
return ret;
return 0;
}

View file

@ -134,7 +134,8 @@ static void iec61850_sv_listener(SVSubscriber subscriber, void *ctx, SVSubscribe
smp->length++;
}
queue_signalled_push(&i->in.queue, smp);
int pushed __attribute__((unused));
pushed = queue_signalled_push(&i->in.queue, smp);
}
int iec61850_sv_parse(struct vnode *n, json_t *json)
@ -496,8 +497,9 @@ static void register_plugin() {
p.node.write = iec61850_sv_write;
p.node.poll_fds = iec61850_sv_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -1028,8 +1028,9 @@ static void register_plugin() {
p.node.reverse = ib_reverse;
p.node.memory_type = memory_ib;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -228,9 +228,9 @@ static void register_plugin() {
p.node.stop = influxdb_close;
p.node.write = influxdb_write;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -148,7 +148,9 @@ static void mqtt_message_cb(struct mosquitto *mosq, void *userdata, const struct
return;
}
queue_signalled_push_many(&m->queue, (void **) smps, n->in.vectorize);
ret = queue_signalled_push_many(&m->queue, (void **) smps, n->in.vectorize);
if (ret < (int) n->in.vectorize)
warning("MQTT: Failed to enqueue samples");
}
static void mqtt_subscribe_cb(struct mosquitto *mosq, void *userdata, int mid, int qos_count, const int *granted_qos)
@ -416,9 +418,8 @@ int mqtt_type_start(villas::node::SuperNode *sn)
int ret;
ret = vlist_init(&clients);
if (ret) {
return ret;
}
if (ret)
return ret;
ret = mosquitto_lib_init();
if (ret)
@ -426,9 +427,8 @@ int mqtt_type_start(villas::node::SuperNode *sn)
// Start thread here to run mosquitto loop for registered clients
ret = pthread_create(&thread, nullptr, mosquitto_loop_thread, nullptr);
if (ret) {
return ret;
}
if (ret)
return ret;
return 0;
@ -445,23 +445,24 @@ int mqtt_type_stop()
// Stop thread here that executes mosquitto loop
ret = pthread_cancel(thread);
if (ret)
return ret;
return ret;
debug( 3, "Called pthread_cancel() on MQTT communication management thread.");
ret = pthread_join(thread, nullptr);
if (ret) {
return ret;
}
if (ret)
return ret;
ret = mosquitto_lib_cleanup();
if (ret)
goto mosquitto_error;
// When this is called the list of clients should be empty
if (vlist_length(&clients) > 0) {
error("List of MQTT clients contains elements at time of destruction. Call node_stop for each MQTT node before stopping node type!");
}
vlist_destroy(&clients, nullptr, false);
if (vlist_length(&clients) > 0)
error("List of MQTT clients contains elements at time of destruction. Call node_stop for each MQTT node before stopping node type!");
ret = vlist_destroy(&clients, nullptr, false);
if (ret)
return ret;
return 0;
@ -543,8 +544,9 @@ static void register_plugin() {
p.node.reverse = mqtt_reverse;
p.node.poll_fds = mqtt_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -91,8 +91,13 @@ int nanomsg_parse(struct vnode *n, json_t *cfg)
json_t *json_out_endpoints = nullptr;
json_t *json_in_endpoints = nullptr;
vlist_init(&m->out.endpoints);
vlist_init(&m->in.endpoints);
ret = vlist_init(&m->out.endpoints);
if (ret)
return ret;
ret = vlist_init(&m->in.endpoints);
if (ret)
return ret;
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s?: { s?: o }, s?: { s?: o } }",
"format", &format,
@ -313,8 +318,9 @@ static void register_plugin() {
p.node.poll_fds = nanomsg_poll_fds;
p.node.netem_fds = nanomsg_netem_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -868,8 +868,9 @@ static void register_plugin() {
p.node.poll_fds = ngsi_poll_fds;
p.node.reverse = ngsi_reverse;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -328,8 +328,9 @@ static void register_plugin() {
p.node.read = opal_read;
p.node.write = opal_write;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -638,8 +638,9 @@ static void register_plugin() {
p.node.poll_fds = rtp_poll_fds;
p.node.netem_fds = rtp_netem_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -218,9 +218,9 @@ static void register_plugin() {
p.node.read = shmem_read;
p.node.write = shmem_write;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -222,6 +222,8 @@ int signal_generator_parse(struct vnode *n, json_t *cfg)
json_array_foreach(json_type, i, json_value) {
type_str = json_string_value(json_value);
if (!type_str)
throw ConfigError(json_value, "node-config-node-signal", "Signal type must be a string");
s->type[i] = signal_generator_lookup_type(type_str);
}
@ -461,8 +463,9 @@ static void register_plugin() {
p.node.read = signal_generator_read;
p.node.poll_fds = signal_generator_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -589,8 +589,9 @@ static void register_plugin() {
p.node.poll_fds = socket_fds;
p.node.netem_fds = socket_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -264,8 +264,9 @@ static void register_plugin() {
p.node.read = stats_node_read;
p.node.poll_fds = stats_node_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -140,7 +140,9 @@ int test_rtt_parse(struct vnode *n, json_t *cfg)
t->cooldown = 0;
/* Generate list of test cases */
vlist_init(&t->cases);
ret = vlist_init(&t->cases);
if (ret)
return ret;
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s?: s, s?: s, s?: F, s: o }",
"prefix", &prefix,
@ -458,8 +460,9 @@ static void register_plugin() {
p.node.read = test_rtt_read;
p.node.write = test_rtt_write;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -661,8 +661,9 @@ static void register_plugin() {
p.node.stop = uldaq_stop;
p.node.read = uldaq_read;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -369,7 +369,11 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
int websocket_type_start(villas::node::SuperNode *sn)
{
vlist_init(&connections);
int ret;
ret = vlist_init(&connections);
if (ret)
return ret;
web = sn->getWeb();
if (web->getState() != State::STARTED)
@ -532,7 +536,9 @@ int websocket_parse(struct vnode *n, json_t *cfg)
json_t *json_dest;
json_error_t err;
vlist_init(&w->destinations);
ret = vlist_init(&w->destinations);
if (ret)
return ret;
ret = json_unpack_ex(cfg, &err, 0, "{ s?: o }", "destinations", &json_dests);
if (ret)
@ -626,8 +632,9 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.node.write = websocket_write;
p.node.poll_fds = websocket_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110))) static void UNIQUE(__dtor)() {

View file

@ -96,6 +96,7 @@ int zeromq_reverse(struct vnode *n)
int zeromq_init(struct vnode *n)
{
int ret;
struct zeromq *z = (struct zeromq *) n->_vd;
z->out.bind = 1;
@ -107,8 +108,13 @@ int zeromq_init(struct vnode *n)
z->in.pending = 0;
z->out.pending = 0;
vlist_init(&z->in.endpoints);
vlist_init(&z->out.endpoints);
ret = vlist_init(&z->in.endpoints);
if (ret)
return ret;
ret = vlist_init(&z->out.endpoints);
if (ret)
return ret;
return 0;
}
@ -660,8 +666,9 @@ static void register_plugin() {
p.node.poll_fds = zeromq_poll_fds;
p.node.netem_fds = zeromq_netem_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
int ret = vlist_init(&p.node.instances);
if (!ret)
vlist_init_and_push(&plugins, &p);
}
__attribute__((destructor(110)))

View file

@ -64,7 +64,9 @@ int pool_destroy(struct pool *p)
if (p->state == State::DESTROYED)
return 0;
queue_destroy(&p->queue);
ret = queue_destroy(&p->queue);
if (ret)
return ret;
void *buffer = (char *) p + p->buffer_off;
ret = memory_free(buffer);

View file

@ -164,13 +164,19 @@ retry: fd = shm_open(wname, O_RDWR|O_CREAT|O_EXCL, 0600);
int shmem_int_close(struct shmem_int *shm)
{
int ret;
atomic_store(&shm->closed, 1);
queue_signalled_close(&shm->write.shared->queue);
ret = queue_signalled_close(&shm->write.shared->queue);
if (ret)
return ret;
shm_unlink(shm->write.name);
if (atomic_load(&shm->readers) == 0)
munmap(shm->read.base, shm->read.len);
if (atomic_load(&shm->writers) == 0)
munmap(shm->write.base, shm->write.len);

View file

@ -149,21 +149,27 @@ int signal_decref(struct signal *s)
int prev = atomic_fetch_sub(&s->refcnt, 1);
/* Did we had the last reference? */
if (prev == 1)
signal_free(s);
if (prev == 1) {
int ret = signal_free(s);
if (ret)
throw RuntimeError("Failed to release sample");
}
return prev - 1;
}
struct signal * signal_copy(struct signal *s)
{
int ret;
struct signal *ns;
ns = new struct signal;
if (!ns)
throw MemoryAllocationError();
signal_init(ns);
ret = signal_init(ns);
if (!ret)
throw RuntimeError("Failed to initialize signal");
ns->type = s->type;
ns->init = s->init;

View file

@ -64,9 +64,19 @@ SuperNode::SuperNode() :
hugepages(DEFAULT_NR_HUGEPAGES),
task(CLOCK_REALTIME)
{
vlist_init(&nodes);
vlist_init(&paths);
vlist_init(&interfaces);
int ret;
ret = vlist_init(&nodes);
if (ret)
throw RuntimeError("Failed to initialize list");
ret = vlist_init(&paths);
if (ret)
throw RuntimeError("Failed to initialize list");
ret = vlist_init(&interfaces);
if (ret)
throw RuntimeError("Failed to initialize list");
#ifdef WITH_NETEM
nl_init(); /* Fill link cache */
@ -236,9 +246,7 @@ void SuperNode::check()
for (size_t i = 0; i < vlist_length(&paths); i++) {
auto *p = (struct vpath *) vlist_at(&paths, i);
ret = path_check(p);
if (ret)
throw RuntimeError("Invalid configuration for path {}", path_name(p));
path_check(p);
}
state = State::CHECKED;
@ -336,7 +344,7 @@ void SuperNode::preparePaths()
if (!path_is_enabled(p))
continue;
ret = path_prepare(p);
ret = path_prepare(p, &nodes);
if (ret)
throw RuntimeError("Failed to prepare path: {}", path_name(p));
}
@ -473,12 +481,14 @@ void SuperNode::run()
SuperNode::~SuperNode()
{
int ret __attribute__((unused));
assert(state != State::STARTED);
vlist_destroy(&paths, (dtor_cb_t) path_destroy, true);
vlist_destroy(&nodes, (dtor_cb_t) node_destroy, true);
ret = vlist_destroy(&paths, (dtor_cb_t) path_destroy, true);
ret = vlist_destroy(&nodes, (dtor_cb_t) node_destroy, true);
#ifdef WITH_NETEM
vlist_destroy(&interfaces, (dtor_cb_t) if_destroy, true);
ret = vlist_destroy(&interfaces, (dtor_cb_t) if_destroy, true);
#endif /* WITH_NETEM */
}

View file

@ -85,7 +85,9 @@ public:
~PipeDirection()
{
pool_destroy(&pool);
int ret __attribute__((unused));
ret = pool_destroy(&pool);
}
virtual void run()
@ -164,7 +166,9 @@ public:
goto leave;
}
leave2: return;
leave2:
logger->info("Send thread stopped");
return;
leave: if (io_eof(io)) {
if (limit < 0) {
@ -225,8 +229,11 @@ public:
return;
leave: logger->info("Reached receive limit. Terminating...");
leave2: raise(SIGINT);
leave:
logger->info("Reached receive limit. Terminating...");
leave2:
logger->info("Receive thread stopped");
raise(SIGINT);
}
};

View file

@ -239,7 +239,8 @@ ParameterizedTest(Param *p, io, lowlevel, .init = init_memory)
ret = pool_init(&pool, 2 * p->cnt, SAMPLE_LENGTH(NUM_VALUES));
cr_assert_eq(ret, 0);
vlist_init(&signals);
ret = vlist_init(&signals);
cr_assert_eq(ret, 0);
signal_list_generate(&signals, NUM_VALUES, SignalType::FLOAT);
ret = sample_alloc_many(&pool, smps, p->cnt);
@ -334,7 +335,8 @@ ParameterizedTest(Param *p, io, highlevel, .init = init_memory)
ret = sample_alloc_many(&pool, smpt, p->cnt);
cr_assert_eq(ret, p->cnt);
vlist_init(&signals);
ret = vlist_init(&signals);
cr_assert_eq(ret, 0);
signal_list_generate(&signals, NUM_VALUES, SignalType::FLOAT);
fill_sample_data(&signals, smps, p->cnt);

View file

@ -24,5 +24,6 @@
void init_memory()
{
memory_init(DEFAULT_NR_HUGEPAGES);
int ret __attribute__((unused));
ret = memory_init(DEFAULT_NR_HUGEPAGES);
}