Re: [PATCH] Fix error propagation in DB loader

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

 



On Fri, Apr 28, 2017 at 05:57:57PM +0400, Roman Bogorodskiy wrote:
>   Daniel P. Berrange wrote:
> 
> > When failing to read the pci/usb ID files we failed to
> > propagate the reported error.
> > 
> > We also had some dead code which would never be reached
> > due to earlier gotos.
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> > ---
> >  osinfo/osinfo_loader.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> > 
> > diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
> > index 6c7c009..dca23f1 100644
> > --- a/osinfo/osinfo_loader.c
> > +++ b/osinfo/osinfo_loader.c
> > @@ -2127,9 +2127,6 @@ static void osinfo_loader_process_list(OsinfoLoader *loader,
> >          tmp++;
> >      }
> >  
> > -    if (lerr)
> > -        goto cleanup;
> > -
> >      /* Phase 2: load data from non-native locations, filtering based
> >       * on overrides from native locations */
> >      tmp = dirs;
> > @@ -2151,15 +2148,13 @@ static void osinfo_loader_process_list(OsinfoLoader *loader,
> >          }
> >  
> >          if (lerr) {
> > -            break;
> > +            g_propagate_error(err, lerr);
> > +            goto cleanup;
> >          }
> >  
> >          tmp++;
> >      }
> >  
> > -    if (lerr)
> > -        goto cleanup;
> > -
> >      /* Phase 3: load combined set of files from native locations */
> >      g_hash_table_iter_init(&iter, allentries);
> >      while (g_hash_table_iter_next(&iter, &key, &value)) {
> 
> I gave it a test and it improves things, e.g.:
> 
> $ ./tools/osinfo-query os
> Error loading OS data: Error opening file:
> $
> 
> test-loader fails with that:
> 
> test-loader.c:36:F:Core:test_basic:0: Error opening file: No such file or directory
> 
> Maybe it will make sense to include the actual filename? Because from
> user perspective it's not quite obvious what file it's trying to open.

When I do it, it does include the file name !

$ ./tools/osinfo-query os
Error loading OS data: Error opening file /usr/share/hwdata/pci.ids: No such file or directory

libosinfo actually doesn't get involved in the error message here,
everything after "Error loading OS data" comes out of glib itself.
So I think the problem is your glib version isn't reporting good
errors.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux