Since glib commit 2.31.10~16 [1], g_set_error() will issue a warning if it's passed a NULL domain. libosinfo is doing this in a few places (try for example 'osinfo-query os winxp'). This commit adds a generic OSINFO_ERROR domain which will be used instead of NULL. It's a bit inconsistent with OSINFO_MEDIA_ERROR and OSINFO_TREE_ERROR in that they both start with "osinfo-*" while OSINFO_ERROR uses "libosinfo". However, since OsinfoLoader already makes use of that quark, changing that would arguably be an (very small) ABI break. [1] https://gitlab.gnome.org/GNOME/glib/commit/6d9f874330 --- osinfo/libosinfo.syms | 5 +++++ osinfo/osinfo_loader.c | 24 +++++++++++++++++++++--- osinfo/osinfo_loader.h | 8 ++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms index 6bd08a10..db9b8b20 100644 --- a/osinfo/libosinfo.syms +++ b/osinfo/libosinfo.syms @@ -529,6 +529,11 @@ LIBOSINFO_0.2.13 { osinfo_media_get_eject_after_install; } LIBOSINFO_0.2.12; +LIBOSINFO_1.3.0 { + global: + osinfo_error_quark; +} LIBOSINFO_0.2.13; + /* Symbols in next release... LIBOSINFO_0.0.2 { diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 3accb29e..d1bf61d9 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -144,8 +144,26 @@ OsinfoLoader *osinfo_loader_new(void) return g_object_new(OSINFO_TYPE_LOADER, NULL); } -#define OSINFO_LOADER_SET_ERROR(err, msg) \ - g_set_error_literal((err), g_quark_from_static_string("libosinfo"), 0, (msg)); +/** + * osinfo_error_quark: + * + * Gets a #GQuark representing the string "libosinfo" + * + * Returns: the #GQuark representing the string. + **/ +GQuark +osinfo_error_quark(void) +{ + static GQuark quark = 0; + + if (!quark) + quark = g_quark_from_static_string("libosinfo"); + + return quark; +} + +#define OSINFO_LOADER_SET_ERROR(err, msg) \ + g_set_error_literal((err), OSINFO_ERROR, 0, (msg)); static gboolean error_is_set(GError **error) { @@ -191,7 +209,7 @@ osinfo_loader_nodeset(const char *xpath, if (obj == NULL) return 0; if (obj->type != XPATH_NODESET) { - g_set_error(err, g_quark_from_static_string("libosinfo"), 0, + g_set_error(err, OSINFO_ERROR, 0, _("Expected a nodeset in XPath query %s"), xpath); xmlXPathFreeObject(obj); return -1; diff --git a/osinfo/osinfo_loader.h b/osinfo/osinfo_loader.h index 41bfb146..76beb7ce 100644 --- a/osinfo/osinfo_loader.h +++ b/osinfo/osinfo_loader.h @@ -66,6 +66,14 @@ struct _OsinfoLoaderClass GType osinfo_loader_get_type(void); +/** + * OSINFO_ERROR: + * + * Error domain for generic libosinfo errors + */ +#define OSINFO_ERROR osinfo_error_quark() +GQuark osinfo_error_quark(void); + OsinfoLoader *osinfo_loader_new(void); OsinfoDb *osinfo_loader_get_db(OsinfoLoader *loader); -- 2.19.0 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo