Skip to content

Make configuration validation function return validation error message#193

Open
danghai wants to merge 1 commit into
Scribery:mainfrom
danghai:tlog_41
Open

Make configuration validation function return validation error message#193
danghai wants to merge 1 commit into
Scribery:mainfrom
danghai:tlog_41

Conversation

@danghai

@danghai danghai commented Mar 22, 2018

Copy link
Copy Markdown
Member

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

@coveralls

coveralls commented Mar 22, 2018

Copy link
Copy Markdown

Coverage Status

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

@spbnick spbnick left a comment

Copy link
Copy Markdown
Member

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!

Comment thread lib/tlog/play_conf.c Outdated
/* Check validate the config */
assert(tlog_play_conf_validate(NULL,
conf,
TLOG_CONF_ORIGIN_ARGS) == TLOG_RC_OK);

Copy link
Copy Markdown
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

danghai commented Mar 27, 2018

Copy link
Copy Markdown
Member Author

I have updated it

@spbnick spbnick left a comment

Copy link
Copy Markdown
Member

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.

Comment thread lib/tlog/play_conf.c
assert(argv != NULL);
/* Check validate the config */
assert(tlog_play_conf_validate(NULL, conf, TLOG_CONF_ORIGIN_ARGS) ==
TLOG_RC_OK);

Copy link
Copy Markdown
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.

3 participants