diff --git a/src/libostree/ostree-fetcher.c b/src/libostree/ostree-fetcher.c index 87e08441..c9161d40 100644 --- a/src/libostree/ostree-fetcher.c +++ b/src/libostree/ostree-fetcher.c @@ -128,11 +128,10 @@ G_DEFINE_TYPE (OstreeFetcher, _ostree_fetcher, G_TYPE_OBJECT) static ThreadClosure * thread_closure_ref (ThreadClosure *thread_closure) { + int refcount; g_return_val_if_fail (thread_closure != NULL, NULL); - g_return_val_if_fail (thread_closure->ref_count > 0, NULL); - - g_atomic_int_inc (&thread_closure->ref_count); - + refcount = g_atomic_int_add (&thread_closure->ref_count, 1); + g_assert (refcount > 0); return thread_closure; } @@ -140,7 +139,6 @@ static void thread_closure_unref (ThreadClosure *thread_closure) { g_return_if_fail (thread_closure != NULL); - g_return_if_fail (thread_closure->ref_count > 0); if (g_atomic_int_dec_and_test (&thread_closure->ref_count)) { @@ -197,11 +195,10 @@ pending_task_compare (gconstpointer a, static OstreeFetcherPendingURI * pending_uri_ref (OstreeFetcherPendingURI *pending) { + gint refcount; g_return_val_if_fail (pending != NULL, NULL); - g_return_val_if_fail (pending->ref_count > 0, NULL); - - g_atomic_int_inc (&pending->ref_count); - + refcount = g_atomic_int_add (&pending->ref_count, 1); + g_assert (refcount > 0); return pending; } diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index 84d15374..eb9733e8 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -2959,7 +2959,8 @@ ostree_repo_commit_modifier_new (OstreeRepoCommitModifierFlags flags, OstreeRepoCommitModifier * ostree_repo_commit_modifier_ref (OstreeRepoCommitModifier *modifier) { - g_atomic_int_inc (&modifier->refcount); + gint refcount = g_atomic_int_add (&modifier->refcount, 1); + g_assert (refcount > 0); return modifier; } diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index d3762521..b4cf4e38 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -161,11 +161,10 @@ ost_remote_new_from_keyfile (GKeyFile *keyfile, static OstreeRemote * ost_remote_ref (OstreeRemote *remote) { + gint refcount; g_return_val_if_fail (remote != NULL, NULL); - g_return_val_if_fail (remote->ref_count > 0, NULL); - - g_atomic_int_inc (&remote->ref_count); - + refcount = g_atomic_int_add (&remote->ref_count, 1); + g_assert (refcount > 0); return remote; }