[ostree] sysroot: Add precondition that load() has been called for some API calls



commit 6a55d2c32ffcb49de5f4d781315b67dcc885d6f7
Author: Colin Walters <walters verbum org>
Date:   Fri Aug 15 15:21:40 2014 -0400

    sysroot: Add precondition that load() has been called for some API calls
    
    We require the caller to invoke load() at the moment to do most
    things.

 src/libostree/ostree-sysroot.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
index 0c92f26..c88c6d4 100644
--- a/src/libostree/ostree-sysroot.c
+++ b/src/libostree/ostree-sysroot.c
@@ -755,6 +755,8 @@ ostree_sysroot_get_subbootversion (OstreeSysroot   *self)
 OstreeDeployment *
 ostree_sysroot_get_booted_deployment (OstreeSysroot       *self)
 {
+  g_return_val_if_fail (self->loaded, NULL);
+
   return self->booted_deployment;
 }
 
@@ -767,8 +769,12 @@ ostree_sysroot_get_booted_deployment (OstreeSysroot       *self)
 GPtrArray *
 ostree_sysroot_get_deployments (OstreeSysroot  *self)
 {
-  GPtrArray *copy = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+  GPtrArray *copy;
   guint i;
+
+  g_return_val_if_fail (self->loaded, NULL);
+
+  copy = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
   for (i = 0; i < self->deployments->len; i++)
     g_ptr_array_add (copy, g_object_ref (self->deployments->pdata[i]));
   return copy;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]