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); void bay_init(struct bay *bay);
int bay_register(struct bay *bay, struct chan *chan); USE_RET int bay_register(struct bay *bay, struct chan *chan);
int bay_remove(struct bay *bay, struct chan *chan); USE_RET int bay_remove(struct bay *bay, struct chan *chan);
struct chan *bay_find(struct bay *bay, const char *name); USE_RET 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); USE_RET int bay_add_cb(struct bay *bay, enum bay_cb_type type,
int bay_propagate(struct bay *bay); struct chan *chan, bay_cb_func_t func, void *arg);
USE_RET int bay_propagate(struct bay *bay);
#endif /* BAY_H */ #endif /* BAY_H */

View File

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

View File

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

View File

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