ostree icon indicating copy to clipboard operation
ostree copied to clipboard

[WIP] lib/repo: Validate config more strictly

Open mwleeds opened this issue 7 years ago • 8 comments

Now that we're correctly reading negative values for the "lock-timeout-secs" config key, throw an error if it's not within the range of values that have semantic meaning. This mirrors the behavior when other config keys have invalid values.

mwleeds avatar Sep 28 '18 16:09 mwleeds

I like this better than relying on an assert since that's a programmer error, not a user error. Actually, there are a bunch of potential errors not caught here that were in my original implementation in https://github.com/ostreedev/ostree/pull/1292/commits/532199858ce283a7e8528a1f2affc7c8069a43fc. See also @pwithnall's review in https://github.com/ostreedev/ostree/pull/1292/commits/532199858ce283a7e8528a1f2affc7c8069a43fc#r147145444.

dbnicholson avatar Sep 28 '18 17:09 dbnicholson

That link didn't work for me but I think I found what you're referring to here: https://github.com/ostreedev/ostree/pull/1292#discussion_r147145444

mwleeds avatar Sep 28 '18 18:09 mwleeds

@rh-atomic-bot delegate=dbnicholson

cgwalters avatar Sep 28 '18 19:09 cgwalters

:v: @dbnicholson can now approve this pull request

rh-atomic-bot avatar Sep 28 '18 19:09 rh-atomic-bot

Unfortunately it does not look so good to all the compilers:

src/libostree/ostree-repo.c: In function 'reload_core_config':
src/libostree/ostree-repo.c:2810:11: error: unused variable 'endptr' [-Werror=unused-variable]
     char *endptr;
           ^~~~~~
src/libostree/ostree-repo.c:2840:9: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
         if (configured_lock_timeout < REPO_LOCK_DISABLED || configured_lock_timeout > G_MAXINT32 ||
         ^~
src/libostree/ostree-repo.c:2842:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
           return glnx_throw (error, "Invalid lock-timeout-secs '%s'", lock_timeout_seconds);
           ^~~~~~

pwithnall avatar Sep 29 '18 09:09 pwithnall

Note: You could also potentially use g_ascii_string_to_[un]signed() rather than g_strto[u]ll(), if you depend on a new enough GLib version (I haven’ŧ checked).

pwithnall avatar Sep 29 '18 12:09 pwithnall

Oops, didn't intend for y'all to spend time reviewing that last commit. I was pushing it to get it from one computer to another. But yeah, I'll follow-up and fix it.

mwleeds avatar Sep 29 '18 22:09 mwleeds

@mwleeds: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/sanity dce18c9f10c18bacf6b7f33762d3b060c07c6928 link true /test sanity

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

openshift-ci[bot] avatar Apr 06 '22 20:04 openshift-ci[bot]