lib: Add error prefixing for sysroot load and repo open
authorColin Walters <walters@verbum.org>
Sat, 28 Mar 2020 14:07:00 +0000 (14:07 +0000)
committerColin Walters <walters@verbum.org>
Sat, 28 Mar 2020 14:08:51 +0000 (14:08 +0000)
Noticed this while writing tests for a core `ostree_sysroot_load()`
entrypoint.  And decided to do the same for `ostree_repo_open()`,
and while there also noted we had a duplicate error prefixing
for the open (more recently `glnx_opendirat()` automatically
prefixes with the path).

src/libostree/ostree-repo.c
src/libostree/ostree-sysroot.c

index 3aeecc5c43515ab94acdecd4b8bfd98b764bb7c6..40251aa266baf9f22be7f6c18caaeb9d947e5239 100644 (file)
@@ -3257,6 +3257,8 @@ ostree_repo_open (OstreeRepo    *self,
                   GCancellable  *cancellable,
                   GError       **error)
 {
+  GLNX_AUTO_PREFIX_ERROR ("opening repo", error);
+
   struct stat stbuf;
 
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -3291,10 +3293,7 @@ ostree_repo_open (OstreeRepo    *self,
       g_assert (self->repodir);
       if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (self->repodir), TRUE,
                            &self->repo_dir_fd, error))
-        {
-          g_prefix_error (error, "%s: ", gs_file_get_path_cached (self->repodir));
-          return FALSE;
-        }
+        return FALSE;
     }
 
   if (!glnx_fstat (self->repo_dir_fd, &stbuf, error))
index 55a610148876157bfeee29e0e9cb69e0a73bafa0..7fbedee6ef2b62ec41589026e4b46765ae862181 100644 (file)
@@ -1003,6 +1003,7 @@ ostree_sysroot_load_if_changed (OstreeSysroot  *self,
                                 GCancellable   *cancellable,
                                 GError        **error)
 {
+  GLNX_AUTO_PREFIX_ERROR ("loading sysroot", error);
   if (!ostree_sysroot_initialize (self, error))
     return FALSE;