Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make configuration validation function return validation error message #193

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/tlog/play_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ tlog_play_conf_load(struct tlog_errs **perrs,
assert(pcmd_help != NULL);
assert(pconf != NULL);
assert(argv != NULL);
/* Check validate the config */
assert(tlog_play_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
TLOG_RC_OK);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't make sense, we don't need to validate a NULL pointer we just initialized. This function doesn't need to validate the configuration it receives, as it doesn't receive any. The same for the rest of those.


/* Create empty config */
conf = json_object_new_object();
Expand Down Expand Up @@ -136,6 +139,10 @@ tlog_play_conf_load(struct tlog_errs **perrs,
json_object_put(overlay);
overlay = NULL;

/* Check validate the config */
assert(tlog_play_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
TLOG_RC_OK);

grc = TLOG_RC_OK;
*pcmd_help = cmd_help;
cmd_help = NULL;
Expand Down
7 changes: 7 additions & 0 deletions lib/tlog/rec_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ tlog_rec_conf_load(struct tlog_errs **perrs,
assert(pcmd_help != NULL);
assert(pconf != NULL);
assert(argv != NULL);
/* Check validate the config */
assert(tlog_rec_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
TLOG_RC_OK);

/* Create empty config */
conf = json_object_new_object();
Expand Down Expand Up @@ -250,6 +253,10 @@ tlog_rec_conf_load(struct tlog_errs **perrs,
json_object_put(overlay);
overlay = NULL;

/* Check validate the config */
assert(tlog_rec_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
TLOG_RC_OK);

grc = TLOG_RC_OK;
*pcmd_help = cmd_help;
cmd_help = NULL;
Expand Down
7 changes: 7 additions & 0 deletions lib/tlog/rec_session_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ tlog_rec_session_conf_load(struct tlog_errs **perrs,
assert(pcmd_help != NULL);
assert(pconf != NULL);
assert(argv != NULL);
/* Check validate the config */
assert(tlog_rec_session_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
TLOG_RC_OK);

/* Create empty config */
conf = json_object_new_object();
Expand Down Expand Up @@ -265,6 +268,10 @@ tlog_rec_session_conf_load(struct tlog_errs **perrs,
json_object_put(overlay);
overlay = NULL;

/* Check validate the config */
assert(tlog_rec_session_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
TLOG_RC_OK);

grc = TLOG_RC_OK;
*pcmd_help = cmd_help;
cmd_help = NULL;
Expand Down