Merge pull request #2496 from lucab/ups/repo-asserts

lib/repo: fix problematic invariant checks
This commit is contained in:
Colin Walters 2021-12-07 19:58:23 -05:00 committed by GitHub
commit b56786c415
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1558,8 +1558,10 @@ gboolean
ostree_repo_is_writable (OstreeRepo *self,
GError **error)
{
g_return_val_if_fail (self->inited, FALSE);
g_assert (self != NULL);
g_assert (self->inited);
g_assert (self->writable == (self->writable_error == NULL));
if (error != NULL && self->writable_error != NULL)
*error = g_error_copy (self->writable_error);
@ -1595,7 +1597,8 @@ _ostree_repo_update_mtime (OstreeRepo *self,
GKeyFile *
ostree_repo_get_config (OstreeRepo *self)
{
g_return_val_if_fail (self->inited, NULL);
g_assert (self != NULL);
g_assert (self->inited);
return self->config;
}
@ -1613,7 +1616,8 @@ ostree_repo_copy_config (OstreeRepo *self)
char *data;
gsize len;
g_return_val_if_fail (self->inited, NULL);
g_assert (self != NULL);
g_assert (self->inited);
copy = g_key_file_new ();
data = g_key_file_to_data (self->config, &len, NULL);
@ -3812,7 +3816,8 @@ ostree_repo_equal (OstreeRepo *a,
OstreeRepoMode
ostree_repo_get_mode (OstreeRepo *self)
{
g_return_val_if_fail (self->inited, FALSE);
g_assert (self != NULL);
g_assert (self->inited);
return self->mode;
}