Fail when the return value is not used

This commit is contained in:
Rodrigo Arias 2023-01-16 15:42:59 +01:00 committed by Rodrigo Arias Mallo
parent e240937e58
commit d394bb88c3
4 changed files with 26 additions and 29 deletions

View File

@ -59,10 +59,11 @@ struct bay {
};
void bay_init(struct bay *bay);
int bay_register(struct bay *bay, struct chan *chan);
int bay_remove(struct bay *bay, struct chan *chan);
struct chan *bay_find(struct bay *bay, const char *name);
int bay_add_cb(struct bay *bay, enum bay_cb_type type, struct chan *chan, bay_cb_func_t func, void *arg);
int bay_propagate(struct bay *bay);
USE_RET int bay_register(struct bay *bay, struct chan *chan);
USE_RET int bay_remove(struct bay *bay, struct chan *chan);
USE_RET struct chan *bay_find(struct bay *bay, const char *name);
USE_RET int bay_add_cb(struct bay *bay, enum bay_cb_type type,
struct chan *chan, bay_cb_func_t func, void *arg);
USE_RET int bay_propagate(struct bay *bay);
#endif /* BAY_H */

View File

@ -19,6 +19,7 @@ enum chan_type {
enum chan_prop {
CHAN_DIRTY_WRITE = 0,
CHAN_DUPLICATES,
CHAN_ROW,
CHAN_MAXPROP,
};
@ -47,22 +48,15 @@ struct chan {
void *dirty_arg;
};
//int chan_enable(struct chan *chan);
//int chan_disable(struct chan *chan);
//int chan_is_enabled(const struct chan *chan);
void chan_init(struct chan *chan, enum chan_type type, const char *name);
int chan_set(struct chan *chan, struct value value);
int chan_push(struct chan *chan, struct value value);
int chan_pop(struct chan *chan, struct value expected);
int chan_read(struct chan *chan, struct value *value);
enum chan_type chan_get_type(struct chan *chan);
int chan_flush(struct chan *chan);
USE_RET int chan_set(struct chan *chan, struct value value);
USE_RET int chan_push(struct chan *chan, struct value value);
USE_RET int chan_pop(struct chan *chan, struct value expected);
USE_RET int chan_read(struct chan *chan, struct value *value);
USE_RET enum chan_type chan_get_type(struct chan *chan);
USE_RET int chan_flush(struct chan *chan);
void chan_prop_set(struct chan *chan, enum chan_prop prop, int value);
int chan_prop_get(struct chan *chan, enum chan_prop prop);
/* Called when it becomes dirty */
USE_RET int chan_prop_get(struct chan *chan, enum chan_prop prop);
void chan_set_dirty_cb(struct chan *chan, chan_cb_t func, void *arg);
#endif /* CHAN_H */

View File

@ -30,20 +30,20 @@ void mux_input_init(struct mux_input *mux,
struct value key,
struct chan *chan);
int mux_init(struct mux *mux,
USE_RET int mux_init(struct mux *mux,
struct bay *bay,
struct chan *select,
struct chan *output,
mux_select_func_t select_func);
struct mux_input *mux_find_input(struct mux *mux,
USE_RET struct mux_input *mux_find_input(struct mux *mux,
struct value key);
int mux_add_input(struct mux *mux,
USE_RET int mux_add_input(struct mux *mux,
struct value key,
struct chan *input);
int mux_register(struct mux *mux,
USE_RET int mux_register(struct mux *mux,
struct bay *bay);
#endif /* MUX_H */

View File

@ -242,8 +242,10 @@ main(void)
if (mux_init(&mux, &bay, &select, &output, NULL) != 0)
die("mux_init failed\n");
for (int i = 0; i < N; i++)
mux_add_input(&mux, value_int64(i), &inputs[i]);
for (int i = 0; i < N; i++) {
if (mux_add_input(&mux, value_int64(i), &inputs[i]) != 0)
die("mux_add_input failed\n");
}
/* Write something to the input channels */
for (int i = 0; i < N; i++) {