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

Conversation

danghai
Copy link
Member

@danghai danghai commented Mar 22, 2018

Hi Nick, PR for issue #41 to make configuration validation function return validation error message by using assert.

@coveralls
Copy link

coveralls commented Mar 22, 2018

Coverage Status

Coverage decreased (-0.03%) to 38.713% when pulling 89e2e02 on danghai:tlog_41 into 16f9a71 on Scribery:master.

Copy link
Member

@spbnick spbnick left a comment

Choose a reason for hiding this comment

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

This looks good, I only have one style comment.
Also, I think we should add similar assertions at the entry of the functions which accept configuration. Could you see if we can do it? Thanks, Hai!

/* 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.

Could you wrap it a bit differently, so it takes less lines? Here and elsewhere? E.g.:

assert(tlog_play_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
        TLOG_RC_OK);

@danghai
Copy link
Member Author

danghai commented Mar 27, 2018

I have updated it

Copy link
Member

@spbnick spbnick left a comment

Choose a reason for hiding this comment

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

Aside from the inline comment, this commit subject doesn't make sense. Please figure out what we're doing and why we're doing it and fix the subject.

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants