ret = parse_stream_command(conf.writer_arg[i], &cmd);
if (ret < 0)
- goto out;
+ return ret;
af_mask = ret;
FOR_EACH_AUDIO_FORMAT(j) {
a = afi + j;
if ((af_mask & (1 << j)) == 0) /* no match */
continue;
- ret = -E_WRITE_COMMON_SYNTAX;
- wconf = check_writer_arg(cmd, &writer_num);
- if (!wconf)
- goto out;
+ wconf = check_writer_arg_or_die(cmd, &writer_num);
nw = a->num_writers;
a->writer_nums = para_realloc(a->writer_nums, (nw + 1) * sizeof(int));
a->writer_conf = para_realloc(a->writer_conf, (nw + 1) * sizeof(void *));
a->writer_conf[0] = w->parse_config_or_die("");
a->num_writers = 1;
}
- ret = 1;
-out:
- return ret;
+ return 1;
}
static int parse_receiver_args(void)
#define WRITE_COMMON_ERRORS \
- PARA_ERROR(WRITE_COMMON_SYNTAX, "syntax error in write option"), \
PARA_ERROR(WRITE_COMMON_EOF, "end of file"), \
*
* \return Standard.
*/
-static int setup_writer_node(const char *arg, struct btr_node *parent,
+static void setup_writer_node(const char *arg, struct btr_node *parent,
struct writer_node *wn)
{
if (arg)
- wn->conf = check_writer_arg(arg, &wn->writer_num);
+ wn->conf = check_writer_arg_or_die(arg, &wn->writer_num);
else {
wn->writer_num = DEFAULT_WRITER;
wn->conf = writers[DEFAULT_WRITER].parse_config_or_die("");
}
- if (!wn->conf)
- return -E_WRITE_COMMON_SYNTAX;
register_writer_node(wn, parent);
- return 1;
}
static int setup_and_schedule(void)
register_task(&cwt->task);
if (!conf.writer_given) {
- i = 0;
wns = para_calloc(sizeof(*wns));
- ret = setup_writer_node(NULL, cwt->btrn, wns);
- if (ret < 0)
- goto out;
+ setup_writer_node(NULL, cwt->btrn, wns);
i = 1;
} else {
wns = para_calloc(conf.writer_given * sizeof(*wns));
- for (i = 0; i < conf.writer_given; i++) {
- ret = setup_writer_node(conf.writer_arg[i],
- cwt->btrn, wns + i);
- if (ret < 0)
- goto out;
- }
+ for (i = 0; i < conf.writer_given; i++)
+ setup_writer_node(conf.writer_arg[i], cwt->btrn,
+ wns + i);
}
s.default_timeout.tv_sec = 10;
}
}
}
-out:
for (i--; i >= 0; i--) {
struct writer_node *wn = wns + i;
struct writer *w = writers + wn->writer_num;
*
* \return On success, a pointer to the gengetopt args info struct is returned
* and \a writer_num contains the number of the writer. Otherwise this function
- * returns \p NULL.
+ * prints an error message and calls exit().
*/
-void *check_writer_arg(const char *wa, int *writer_num)
+void *check_writer_arg_or_die(const char *wa, int *writer_num)
{
int i;
- *writer_num = -E_WRITE_COMMON_SYNTAX;
- PARA_INFO_LOG("checking %s\n", wa);
+ PARA_INFO_LOG("checking %s\n", wa);
FOR_EACH_WRITER(i) {
const char *name = writer_names[i];
size_t len = strlen(name);
*writer_num = i;
return writers[i].parse_config_or_die(c? wa + len + 1 : "");
}
- PARA_ERROR_LOG("writer not found\n");
- return NULL;
+ PARA_EMERG_LOG("invalid writer %s\n", wa);
+ exit(EXIT_FAILURE);
}
/**
/** \file write_common.h Exported symbols from write_common.c. */
void writer_init(void);
-void *check_writer_arg(const char *wa, int *writer_num);
+void *check_writer_arg_or_die(const char *wa, int *writer_num);
void print_writer_helps(int detailed);
void register_writer_node(struct writer_node *wn, struct btr_node *parent);
void get_btr_sample_rate(struct btr_node *btrn, int32_t *result);