Skip to content

Commit

Permalink
export: small simplification
Browse files Browse the repository at this point in the history
use pares_options always (even with NULL)
  • Loading branch information
MartinPulec committed Jul 1, 2024
1 parent 894bd3a commit b10cbf5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ static void usage() {
static bool
parse_options(struct exporter *s, const char *ccfg, bool *should_export)
{
if (ccfg == NULL) {
return true;
}
char buf[STR_LEN];
snprintf(buf, sizeof buf, "%s", ccfg);
char *cfg = buf;
Expand Down Expand Up @@ -149,16 +152,10 @@ struct exporter *export_init(struct module *parent, const char *cfg, bool should
pthread_mutex_init(&s->lock, NULL);
s->limit = -1;

if (cfg) {
if (strcmp(cfg, "help") == 0) {
usage();
export_destroy(s);
return NULL;
}
if (!parse_options(s, cfg, &should_export)) {
HANDLE_ERROR
}
} else {
if (!parse_options(s, cfg, &should_export)) {
HANDLE_ERROR
}
if (s->dir == NULL) {
s->dir_auto = true;
}

Expand Down

0 comments on commit b10cbf5

Please sign in to comment.