From gscrivan at redhat.com Tue Jun 3 14:08:07 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 16:08:07 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations Message-ID: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> libosinfo takes quite a while to preload its data, it was evident in virt-manager that the UI became much slower. This series is mostly targeted at starting a discussion about this issue. I thought about caching the data in another format, that could be used instead of XML without preloading the entire DB at the startup, but it seems like a big task considering the various relations between objects at runtime. I am not sure if patch 5/5 is correct (does the lang function in the xpath query use gettext?). With the following patches, the startup time is around -30% on my machine. What do you think about these changes? Any other ideas? Giuseppe Scrivano (5): entity: use g_hash_table_replace instead of remove+insert osinfo_loader: avoid multiple calls to OSINFO_ENTITY osinfo_loader: introduce a compiled xpaths cache osinfo_loader: replace some xpath queries with direct data access osinfo_loader: do not use xpath to read localized strings osinfo/osinfo_entity.c | 5 +- osinfo/osinfo_loader.c | 287 +++++++++++++++++++++++-------------------------- 2 files changed, 139 insertions(+), 153 deletions(-) -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 14:08:08 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 16:08:08 +0200 Subject: [Libosinfo] [RFC PATCH 1/5] entity: use g_hash_table_replace instead of remove+insert In-Reply-To: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401804492-11338-2-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_entity.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c index 5c062bc..1212f13 100644 --- a/osinfo/osinfo_entity.c +++ b/osinfo/osinfo_entity.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -187,9 +187,8 @@ void osinfo_entity_set_param(OsinfoEntity *entity, const gchar *key, const gchar GList *values = NULL; - g_hash_table_remove(entity->priv->params, key); values = g_list_append(values, g_strdup(value)); - g_hash_table_insert(entity->priv->params, g_strdup(key), values); + g_hash_table_replace(entity->priv->params, g_strdup(key), values); } -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 14:08:09 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 16:08:09 +0200 Subject: [Libosinfo] [RFC PATCH 2/5] osinfo_loader: avoid multiple calls to OSINFO_ENTITY In-Reply-To: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401804492-11338-3-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index aa5e48f..a767bb8 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -1657,19 +1657,20 @@ osinfo_loader_process_file_reg_ids(OsinfoLoader *loader, baseURI, vendor_id, device_id); OsinfoDevice *dev = osinfo_loader_get_device(loader, id); - osinfo_entity_set_param(OSINFO_ENTITY(dev), + OsinfoEntity *entity = OSINFO_ENTITY(dev); + osinfo_entity_set_param(entity, OSINFO_DEVICE_PROP_VENDOR_ID, vendor_id); - osinfo_entity_set_param(OSINFO_ENTITY(dev), + osinfo_entity_set_param(entity, OSINFO_DEVICE_PROP_VENDOR, vendor); - osinfo_entity_set_param(OSINFO_ENTITY(dev), + osinfo_entity_set_param(entity, OSINFO_DEVICE_PROP_PRODUCT_ID, device_id); - osinfo_entity_set_param(OSINFO_ENTITY(dev), + osinfo_entity_set_param(entity, OSINFO_DEVICE_PROP_PRODUCT, device); - osinfo_entity_set_param(OSINFO_ENTITY(dev), + osinfo_entity_set_param(entity, OSINFO_DEVICE_PROP_BUS_TYPE, busType); g_free(id); -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 14:08:10 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 16:08:10 +0200 Subject: [Libosinfo] [RFC PATCH 3/5] osinfo_loader: introduce a compiled xpaths cache In-Reply-To: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401804492-11338-4-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 159 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 111 insertions(+), 48 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index a767bb8..6b1d3e1 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -55,6 +55,7 @@ G_DEFINE_TYPE (OsinfoLoader, osinfo_loader, G_TYPE_OBJECT); struct _OsinfoLoaderPrivate { OsinfoDb *db; + GHashTable *xpath_cache; }; struct _OsinfoEntityKey @@ -70,6 +71,7 @@ osinfo_loader_finalize (GObject *object) OsinfoLoader *loader = OSINFO_LOADER (object); g_object_unref(loader->priv->db); + g_hash_table_destroy(loader->priv->xpath_cache); /* Chain up to the parent class */ G_OBJECT_CLASS (osinfo_loader_parent_class)->finalize (object); @@ -89,11 +91,21 @@ osinfo_loader_class_init (OsinfoLoaderClass *klass) g_type_class_add_private (klass, sizeof (OsinfoLoaderPrivate)); } + +static void xpath_cache_value_free(gpointer values) +{ + xmlXPathFreeCompExpr(values); +} + static void osinfo_loader_init (OsinfoLoader *loader) { loader->priv = OSINFO_LOADER_GET_PRIVATE(loader); loader->priv->db = osinfo_db_new(); + loader->priv->xpath_cache = g_hash_table_new_full(g_str_hash, + g_str_equal, + g_free, + xpath_cache_value_free); } /** PUBLIC METHODS */ @@ -118,8 +130,20 @@ static gboolean error_is_set(GError **error) return ((error != NULL) && (*error != NULL)); } +static xmlXPathCompExprPtr osinfo_loader_get_comp_xpath(OsinfoLoader *loader, + const char *xpath) +{ + xmlXPathCompExprPtr comp = g_hash_table_lookup(loader->priv->xpath_cache, + xpath); + if (comp == NULL) { + comp = xmlXPathCompile(BAD_CAST xpath); + g_hash_table_insert(loader->priv->xpath_cache, g_strdup(xpath), comp); + } + return comp; +} + static int -osinfo_loader_nodeset(const char *xpath, +osinfo_loader_nodeset(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt, xmlNodePtr **list, GError **err) @@ -129,19 +153,19 @@ osinfo_loader_nodeset(const char *xpath, int ret; g_return_val_if_fail(ctxt != NULL, -1); - g_return_val_if_fail(xpath != NULL, -1); + g_return_val_if_fail(comp != NULL, -1); if (list != NULL) *list = NULL; relnode = ctxt->node; - obj = xmlXPathEval(BAD_CAST xpath, ctxt); + obj = xmlXPathCompiledEval(comp, ctxt); ctxt->node = relnode; if (obj == NULL) return(0); if (obj->type != XPATH_NODESET) { g_set_error(err, g_quark_from_static_string("libosinfo"), 0, - _("Expected a nodeset in XPath query %s"), xpath); + _("Expected a nodeset in XPath query")); xmlXPathFreeObject(obj); return (-1); } @@ -161,7 +185,7 @@ osinfo_loader_nodeset(const char *xpath, } static gchar * -osinfo_loader_string(const char *xpath, +osinfo_loader_string(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt, GError **err) { @@ -169,11 +193,9 @@ osinfo_loader_string(const char *xpath, xmlNodePtr relnode; gchar *ret; - g_return_val_if_fail(ctxt != NULL, NULL); - g_return_val_if_fail(xpath != NULL, NULL); - relnode = ctxt->node; - obj = xmlXPathEval(BAD_CAST xpath, ctxt); + obj = xmlXPathCompiledEval(comp, ctxt); + ctxt->node = relnode; if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL) || (obj->stringval[0] == 0)) { @@ -187,7 +209,7 @@ osinfo_loader_string(const char *xpath, } static gboolean -osinfo_loader_boolean(const char *xpath, +osinfo_loader_boolean(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt, GError **err) { @@ -198,9 +220,9 @@ osinfo_loader_boolean(const char *xpath, gboolean ret = FALSE; g_return_val_if_fail(ctxt != NULL, FALSE); - g_return_val_if_fail(xpath != NULL, FALSE); + g_return_val_if_fail(comp != NULL, FALSE); - count = osinfo_loader_nodeset(xpath, ctxt, &nodes, err); + count = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (count < 0) { return FALSE; @@ -229,7 +251,7 @@ cleanup: } static gchar * -osinfo_loader_doc(const char *xpath, +osinfo_loader_doc(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt, GError **err) { @@ -239,10 +261,10 @@ osinfo_loader_doc(const char *xpath, xmlBufferPtr buf; g_return_val_if_fail(ctxt != NULL, NULL); - g_return_val_if_fail(xpath != NULL, NULL); + g_return_val_if_fail(comp != NULL, NULL); relnode = ctxt->node; - obj = xmlXPathEval(BAD_CAST xpath, ctxt); + obj = xmlXPathCompiledEval(comp, ctxt); ctxt->node = relnode; if ((obj == NULL) || (obj->type != XPATH_NODESET)) { xmlXPathFreeObject(obj); @@ -283,6 +305,7 @@ static void osinfo_loader_entity(OsinfoLoader *loader, gboolean value_bool = FALSE; gchar *xpath = NULL; int j; + xmlXPathCompExprPtr comp; /* We are guaranteed to have at least the default "C" locale and we * want to ignore that, hence the NULL check on index 'j + 1'. @@ -291,7 +314,8 @@ static void osinfo_loader_entity(OsinfoLoader *loader, for (j = 0; langs[j + 1] != NULL; j++) { xpath = g_strdup_printf("string(./%s[lang('%s')])", keys[i].name, langs[j]); - value_str = osinfo_loader_string(xpath, ctxt, err); + comp = osinfo_loader_get_comp_xpath(loader, xpath); + value_str = osinfo_loader_string(comp, ctxt, err); g_free(xpath); xpath = NULL; if (error_is_set(err)) @@ -304,20 +328,23 @@ static void osinfo_loader_entity(OsinfoLoader *loader, switch (keys[i].type) { case G_TYPE_STRING: - xpath = g_strdup_printf("string(./%s)", keys[i].name); if (value_str == NULL) { - value_str = osinfo_loader_string(xpath, ctxt, err); + xpath = g_strdup_printf("string(./%s)", keys[i].name); + comp = osinfo_loader_get_comp_xpath(loader, xpath); + value_str = osinfo_loader_string(comp, ctxt, err); + g_free(xpath); } break; case G_TYPE_BOOLEAN: xpath = g_strdup_printf("./%s", keys[i].name); - value_bool = osinfo_loader_boolean(xpath, ctxt, err); + comp = osinfo_loader_get_comp_xpath(loader, xpath); + value_bool = osinfo_loader_boolean(comp, ctxt, err); + g_free(xpath); break; default: g_warn_if_reached(); break; } - g_free(xpath); switch (keys[i].type) { case G_TYPE_STRING: @@ -339,7 +366,10 @@ static void osinfo_loader_entity(OsinfoLoader *loader, /* Then any site specific custom keys. x-... Can be repeated */ xmlNodePtr *custom = NULL; - int ncustom = osinfo_loader_nodeset("./*[substring(name(),1,2)='x-']", ctxt, &custom, err); + xmlXPathCompExprPtr comp; + comp = osinfo_loader_get_comp_xpath(loader, + "./*[substring(name(),1,2)='x-']"); + int ncustom = osinfo_loader_nodeset(comp, ctxt, &custom, err); if (error_is_set(err)) return; @@ -457,7 +487,8 @@ static void osinfo_loader_device_link(OsinfoLoader *loader, GError **err) { xmlNodePtr *related = NULL; - int nrelated = osinfo_loader_nodeset(xpath, ctxt, &related, err); + xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, xpath); + int nrelated = osinfo_loader_nodeset(comp, ctxt, &related, err); int i; if (error_is_set(err)) return; @@ -505,7 +536,8 @@ static void osinfo_loader_product_relshp(OsinfoLoader *loader, GError **err) { xmlNodePtr *related = NULL; - int nrelated = osinfo_loader_nodeset(xpath, ctxt, &related, err); + xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, xpath); + int nrelated = osinfo_loader_nodeset(comp, ctxt, &related, err); int i; if (error_is_set(err)) return; @@ -611,13 +643,15 @@ static void osinfo_loader_deployment(OsinfoLoader *loader, xmlNodePtr root, GError **err) { + xmlXPathCompExprPtr comp; gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id"); if (!id) { OSINFO_ERROR(err, _("Missing deployment id property")); return; } - gchar *osid = osinfo_loader_string("string(./os/@id)", ctxt, err); + comp = osinfo_loader_get_comp_xpath(loader, "string(./os/@id)"); + gchar *osid = osinfo_loader_string(comp, ctxt, err); if (!osid && 0) { OSINFO_ERROR(err, _("Missing deployment os id property")); xmlFree(id); @@ -626,7 +660,8 @@ static void osinfo_loader_deployment(OsinfoLoader *loader, OsinfoOs *os = osinfo_loader_get_os(loader, osid); g_free(osid); - gchar *platformid = osinfo_loader_string("string(./platform/@id)", ctxt, err); + comp = osinfo_loader_get_comp_xpath(loader, "string(./platform/@id)"); + gchar *platformid = osinfo_loader_string(comp, ctxt, err); if (!platformid) { OSINFO_ERROR(err, _("Missing deployment platform id property")); xmlFree(id); @@ -672,7 +707,8 @@ static void osinfo_loader_datamap(OsinfoLoader *loader, OsinfoDatamap *map = osinfo_loader_get_datamap(loader, id); - nnodes = osinfo_loader_nodeset("./entry", ctxt, &nodes, err); + xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, "./entry"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -702,7 +738,8 @@ static void osinfo_loader_install_config_params(OsinfoLoader *loader, GError **err) { xmlNodePtr *nodes = NULL; - int nnodes = osinfo_loader_nodeset(xpath, ctxt, &nodes, err); + xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, xpath); + int nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); int i; if (error_is_set(err)) return; @@ -786,6 +823,7 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, return; } + xmlXPathCompExprPtr comp; OsinfoInstallScript *installScript = osinfo_loader_get_install_script(loader, id); xmlFree(id); @@ -794,7 +832,8 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, if (error_is_set(err)) goto error; - value = osinfo_loader_doc("./template/*[1]", ctxt, err); + comp = osinfo_loader_get_comp_xpath(loader, "./template/*[1]"); + value = osinfo_loader_doc(comp, ctxt, err); if (error_is_set(err)) goto error; if (value) @@ -803,7 +842,8 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, value); g_free(value); - value = osinfo_loader_string("./template/@uri", ctxt, err); + comp = osinfo_loader_get_comp_xpath(loader, "./template/@uri"); + value = osinfo_loader_string(comp, ctxt, err); if (error_is_set(err)) goto error; if (value) @@ -819,7 +859,8 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, root, err); - nnodes = osinfo_loader_nodeset("./avatar-format", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./avatar-format"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto error; @@ -837,7 +878,8 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, } g_free(nodes); - nnodes = osinfo_loader_nodeset("./injection-method", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./injection-method"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto error; @@ -872,6 +914,7 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, { xmlNodePtr *nodes = NULL; guint i; + xmlXPathCompExprPtr comp; gchar *arch = (gchar *)xmlGetProp(root, BAD_CAST "arch"); xmlChar *live = xmlGetProp(root, BAD_CAST OSINFO_MEDIA_PROP_LIVE); @@ -910,7 +953,8 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, xmlFree(installer_reboots); } - gint nnodes = osinfo_loader_nodeset("./variant", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./variant"); + gint nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(media); return NULL; @@ -925,7 +969,8 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, } g_free(nodes); - nnodes = osinfo_loader_nodeset("./iso/*", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./iso/*"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(media); return NULL; @@ -986,6 +1031,7 @@ static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader, { xmlNodePtr *nodes = NULL; guint i; + xmlXPathCompExprPtr comp; gchar *arch = (gchar *)xmlGetProp(root, BAD_CAST "arch"); const OsinfoEntityKey keys[] = { @@ -1001,7 +1047,8 @@ static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader, osinfo_loader_entity(loader, OSINFO_ENTITY(tree), keys, ctxt, root, err); - gint nnodes = osinfo_loader_nodeset("./treeinfo/*", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./treeinfo/*"); + gint nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(G_OBJECT(tree)); return NULL; @@ -1071,7 +1118,8 @@ static OsinfoResources *osinfo_loader_resources(OsinfoLoader *loader, gchar *arch = (gchar *)xmlGetProp(root, BAD_CAST "arch"); gchar *node_path = g_strjoin("/", ".", name, "*", NULL); - gint nnodes = osinfo_loader_nodeset(node_path, ctxt, &nodes, err); + xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, node_path); + gint nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); g_free(node_path); if (error_is_set(err) || nnodes < 1) goto EXIT; @@ -1175,7 +1223,8 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader, xmlFree(is_signed); } - gint nnodes = osinfo_loader_nodeset("./*", ctxt, &nodes, err); + xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, "./*"); + gint nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(G_OBJECT(driver)); return NULL; @@ -1214,6 +1263,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, xmlNodePtr *nodes = NULL; guint i; int nnodes; + xmlXPathCompExprPtr comp; gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id"); const OsinfoEntityKey keys[] = { @@ -1243,7 +1293,8 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - nnodes = osinfo_loader_nodeset("./media", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./media"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1263,7 +1314,8 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./tree", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./tree"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1283,7 +1335,8 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./variant", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./variant"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1304,7 +1357,8 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./resources", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./resources"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1326,7 +1380,8 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./installer/script", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./installer/script"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1345,7 +1400,8 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./driver", ctxt, &nodes, err); + comp = osinfo_loader_get_comp_xpath(loader, "./driver"); + nnodes = osinfo_loader_nodeset(comp, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1406,13 +1462,15 @@ static void osinfo_loader_root(OsinfoLoader *loader, int nplatform; int ninstallScript; int ndataMaps; + xmlXPathCompExprPtr comp; if (!xmlStrEqual(root->name, BAD_CAST "libosinfo")) { OSINFO_ERROR(err, _("Incorrect root element")); return; } - ndevice = osinfo_loader_nodeset("./device", ctxt, &devices, err); + comp = osinfo_loader_get_comp_xpath(loader, "./device"); + ndevice = osinfo_loader_nodeset(comp, ctxt, &devices, err); if (error_is_set(err)) goto cleanup; @@ -1425,7 +1483,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - nplatform = osinfo_loader_nodeset("./platform", ctxt, &platforms, err); + comp = osinfo_loader_get_comp_xpath(loader, "./platform"); + nplatform = osinfo_loader_nodeset(comp, ctxt, &platforms, err); if (error_is_set(err)) goto cleanup; @@ -1438,7 +1497,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - nos = osinfo_loader_nodeset("./os", ctxt, &oss, err); + comp = osinfo_loader_get_comp_xpath(loader, "./os"); + nos = osinfo_loader_nodeset(comp, ctxt, &oss, err); if (error_is_set(err)) goto cleanup; @@ -1451,7 +1511,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - ndeployment = osinfo_loader_nodeset("./deployment", ctxt, &deployments, err); + comp = osinfo_loader_get_comp_xpath(loader, "./deployment"); + ndeployment = osinfo_loader_nodeset(comp, ctxt, &deployments, err); if (error_is_set(err)) goto cleanup; @@ -1464,7 +1525,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - ninstallScript = osinfo_loader_nodeset("./install-script", ctxt, &installScripts, err); + comp = osinfo_loader_get_comp_xpath(loader, "./install-script"); + ninstallScript = osinfo_loader_nodeset(comp, ctxt, &installScripts, err); if (error_is_set(err)) goto cleanup; @@ -1477,7 +1539,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - ndataMaps = osinfo_loader_nodeset("./datamap", ctxt, &dataMaps, err); + comp = osinfo_loader_get_comp_xpath(loader, "./datamap"); + ndataMaps = osinfo_loader_nodeset(comp, ctxt, &dataMaps, err); if (error_is_set(err)) goto cleanup; -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 14:08:11 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 16:08:11 +0200 Subject: [Libosinfo] [RFC PATCH 4/5] osinfo_loader: replace some xpath queries with direct data access In-Reply-To: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401804492-11338-5-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 133 ++++++++++++------------------------------------- 1 file changed, 32 insertions(+), 101 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 6b1d3e1..2a7d748 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -530,20 +530,25 @@ static void osinfo_loader_device_link(OsinfoLoader *loader, static void osinfo_loader_product_relshp(OsinfoLoader *loader, OsinfoProduct *product, OsinfoProductRelationship relshp, - const gchar *xpath, + const gchar *name, xmlXPathContextPtr ctxt, xmlNodePtr root, GError **err) { xmlNodePtr *related = NULL; - xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, xpath); - int nrelated = osinfo_loader_nodeset(comp, ctxt, &related, err); - int i; + xmlNodePtr it; + if (error_is_set(err)) return; - for (i = 0 ; i < nrelated ; i++) { - gchar *id = (gchar *)xmlGetProp(related[i], BAD_CAST "id"); + for(it = root->children; it; it = it->next) { + if (it->type != XML_ELEMENT_NODE) + continue; + + if (!xmlStrEqual(it->name, BAD_CAST name)) + continue; + + gchar *id = (gchar *)xmlGetProp(it, BAD_CAST "id"); if (!id) { OSINFO_ERROR(err, _("Missing product upgrades id property")); goto cleanup; @@ -586,7 +591,7 @@ static void osinfo_loader_product(OsinfoLoader *loader, osinfo_loader_product_relshp(loader, product, OSINFO_PRODUCT_RELATIONSHIP_DERIVES_FROM, - "./derives-from", + "derives-from", ctxt, root, err); @@ -595,7 +600,7 @@ static void osinfo_loader_product(OsinfoLoader *loader, osinfo_loader_product_relshp(loader, product, OSINFO_PRODUCT_RELATIONSHIP_CLONES, - "./clones", + "clones", ctxt, root, err); @@ -604,7 +609,7 @@ static void osinfo_loader_product(OsinfoLoader *loader, osinfo_loader_product_relshp(loader, product, OSINFO_PRODUCT_RELATIONSHIP_UPGRADES, - "./upgrades", + "upgrades", ctxt, root, err); @@ -1449,117 +1454,43 @@ static void osinfo_loader_root(OsinfoLoader *loader, * After loop, return success if no error * If there was an error, clean up lib data acquired so far */ - xmlNodePtr *oss = NULL; - xmlNodePtr *devices = NULL; - xmlNodePtr *platforms = NULL; - xmlNodePtr *deployments = NULL; - xmlNodePtr *installScripts = NULL; - xmlNodePtr *dataMaps = NULL; - int i; - int ndeployment; - int nos; - int ndevice; - int nplatform; - int ninstallScript; - int ndataMaps; - xmlXPathCompExprPtr comp; + xmlNodePtr it; if (!xmlStrEqual(root->name, BAD_CAST "libosinfo")) { OSINFO_ERROR(err, _("Incorrect root element")); return; } - comp = osinfo_loader_get_comp_xpath(loader, "./device"); - ndevice = osinfo_loader_nodeset(comp, ctxt, &devices, err); - if (error_is_set(err)) - goto cleanup; + for(it = root->children; it; it = it->next) { + if (it->type != XML_ELEMENT_NODE) + continue; - for (i = 0 ; i < ndevice ; i++) { xmlNodePtr saved = ctxt->node; - ctxt->node = devices[i]; - osinfo_loader_device(loader, ctxt, devices[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } - - comp = osinfo_loader_get_comp_xpath(loader, "./platform"); - nplatform = osinfo_loader_nodeset(comp, ctxt, &platforms, err); - if (error_is_set(err)) - goto cleanup; + ctxt->node = it; - for (i = 0 ; i < nplatform ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = platforms[i]; - osinfo_loader_platform(loader, ctxt, platforms[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } + if (xmlStrEqual(it->name, BAD_CAST "device")) + osinfo_loader_device(loader, ctxt, it, err); - comp = osinfo_loader_get_comp_xpath(loader, "./os"); - nos = osinfo_loader_nodeset(comp, ctxt, &oss, err); - if (error_is_set(err)) - goto cleanup; + else if (xmlStrEqual(it->name, BAD_CAST "platform")) + osinfo_loader_platform(loader, ctxt, it, err); - for (i = 0 ; i < nos ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = oss[i]; - osinfo_loader_os(loader, ctxt, oss[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } + else if (xmlStrEqual(it->name, BAD_CAST "os")) + osinfo_loader_os(loader, ctxt, it, err); - comp = osinfo_loader_get_comp_xpath(loader, "./deployment"); - ndeployment = osinfo_loader_nodeset(comp, ctxt, &deployments, err); - if (error_is_set(err)) - goto cleanup; + else if (xmlStrEqual(it->name, BAD_CAST "deployment")) + osinfo_loader_deployment(loader, ctxt, it, err); - for (i = 0 ; i < ndeployment ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = deployments[i]; - osinfo_loader_deployment(loader, ctxt, deployments[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } + else if (xmlStrEqual(it->name, BAD_CAST "install-script")) + osinfo_loader_install_script(loader, ctxt, it, err); - comp = osinfo_loader_get_comp_xpath(loader, "./install-script"); - ninstallScript = osinfo_loader_nodeset(comp, ctxt, &installScripts, err); - if (error_is_set(err)) - goto cleanup; + else if (xmlStrEqual(it->name, BAD_CAST "datamap")) + osinfo_loader_datamap(loader, ctxt, it, err); - for (i = 0 ; i < ninstallScript ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = installScripts[i]; - osinfo_loader_install_script(loader, ctxt, installScripts[i], err); ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } - - comp = osinfo_loader_get_comp_xpath(loader, "./datamap"); - ndataMaps = osinfo_loader_nodeset(comp, ctxt, &dataMaps, err); - if (error_is_set(err)) - goto cleanup; - for (i = 0 ; i < ndataMaps ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = dataMaps[i]; - osinfo_loader_datamap(loader, ctxt, dataMaps[i], err); - ctxt->node = saved; if (error_is_set(err)) - goto cleanup; + return; } - - cleanup: - g_free(dataMaps); - g_free(installScripts); - g_free(deployments); - g_free(platforms); - g_free(oss); - g_free(devices); } static void -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 14:08:12 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 16:08:12 +0200 Subject: [Libosinfo] [RFC PATCH 5/5] osinfo_loader: do not use xpath to read localized strings In-Reply-To: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401804492-11338-6-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 2a7d748..bcd1b1d 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -297,32 +297,24 @@ static void osinfo_loader_entity(OsinfoLoader *loader, GError **err) { int i = 0; - const gchar * const *langs = g_get_language_names (); /* Standard well-known keys first, allow single value only */ for (i = 0 ; keys != NULL && keys[i].name != NULL; i++) { gchar *value_str = NULL; gboolean value_bool = FALSE; gchar *xpath = NULL; - int j; xmlXPathCompExprPtr comp; /* We are guaranteed to have at least the default "C" locale and we * want to ignore that, hence the NULL check on index 'j + 1'. */ if (keys[i].type == G_TYPE_STRING) { - for (j = 0; langs[j + 1] != NULL; j++) { - xpath = g_strdup_printf("string(./%s[lang('%s')])", - keys[i].name, langs[j]); - comp = osinfo_loader_get_comp_xpath(loader, xpath); - value_str = osinfo_loader_string(comp, ctxt, err); - g_free(xpath); - xpath = NULL; - if (error_is_set(err)) - return; - - if (value_str != NULL) + xmlNodePtr it; + for (it = root->children; it; it = it->next) { + if (xmlStrEqual(it->name, BAD_CAST keys[i].name)) { + value_str = g_strdup(gettext((const char *) it->children->content)); break; + } } } -- 1.9.3 From berrange at redhat.com Tue Jun 3 14:15:40 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Tue, 3 Jun 2014 15:15:40 +0100 Subject: [Libosinfo] [RFC PATCH 3/5] osinfo_loader: introduce a compiled xpaths cache In-Reply-To: <1401804492-11338-4-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <1401804492-11338-4-git-send-email-gscrivan@redhat.com> Message-ID: <20140603141540.GQ4207@redhat.com> On Tue, Jun 03, 2014 at 04:08:10PM +0200, Giuseppe Scrivano wrote: > @@ -291,7 +314,8 @@ static void osinfo_loader_entity(OsinfoLoader *loader, > for (j = 0; langs[j + 1] != NULL; j++) { > xpath = g_strdup_printf("string(./%s[lang('%s')])", > keys[i].name, langs[j]); > - value_str = osinfo_loader_string(xpath, ctxt, err); > + comp = osinfo_loader_get_comp_xpath(loader, xpath); > + value_str = osinfo_loader_string(comp, ctxt, err); I think it would be nice to push the call to osinfo_loader_get_comp_xpath down one level into the osinfo_loader_string() function. That would mean we only need todo the lookup in a couple of places, instead of every single caller, while still having the perf benefit. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Tue Jun 3 14:18:02 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Tue, 3 Jun 2014 15:18:02 +0100 Subject: [Libosinfo] [RFC PATCH 4/5] osinfo_loader: replace some xpath queries with direct data access In-Reply-To: <1401804492-11338-5-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <1401804492-11338-5-git-send-email-gscrivan@redhat.com> Message-ID: <20140603141802.GR4207@redhat.com> On Tue, Jun 03, 2014 at 04:08:11PM +0200, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > osinfo/osinfo_loader.c | 133 ++++++++++++------------------------------------- > 1 file changed, 32 insertions(+), 101 deletions(-) ACK, makes total sense - much smaller code & faster too. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Tue Jun 3 14:22:05 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Tue, 3 Jun 2014 15:22:05 +0100 Subject: [Libosinfo] [RFC PATCH 5/5] osinfo_loader: do not use xpath to read localized strings In-Reply-To: <1401804492-11338-6-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <1401804492-11338-6-git-send-email-gscrivan@redhat.com> Message-ID: <20140603142205.GS4207@redhat.com> On Tue, Jun 03, 2014 at 04:08:12PM +0200, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > osinfo/osinfo_loader.c | 18 +++++------------- > 1 file changed, 5 insertions(+), 13 deletions(-) > > diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c > index 2a7d748..bcd1b1d 100644 > --- a/osinfo/osinfo_loader.c > +++ b/osinfo/osinfo_loader.c > @@ -297,32 +297,24 @@ static void osinfo_loader_entity(OsinfoLoader *loader, > GError **err) > { > int i = 0; > - const gchar * const *langs = g_get_language_names (); > > /* Standard well-known keys first, allow single value only */ > for (i = 0 ; keys != NULL && keys[i].name != NULL; i++) { > gchar *value_str = NULL; > gboolean value_bool = FALSE; > gchar *xpath = NULL; > - int j; > xmlXPathCompExprPtr comp; > > /* We are guaranteed to have at least the default "C" locale and we > * want to ignore that, hence the NULL check on index 'j + 1'. > */ > if (keys[i].type == G_TYPE_STRING) { > - for (j = 0; langs[j + 1] != NULL; j++) { > - xpath = g_strdup_printf("string(./%s[lang('%s')])", > - keys[i].name, langs[j]); So given an XML doc eek bar wizz an expression './foo[lang('fr')]' will return the contents of the element which has xml:lang == 'fr'. > - comp = osinfo_loader_get_comp_xpath(loader, xpath); > - value_str = osinfo_loader_string(comp, ctxt, err); > - g_free(xpath); > - xpath = NULL; > - if (error_is_set(err)) > - return; > - > - if (value_str != NULL) > + xmlNodePtr it; > + for (it = root->children; it; it = it->next) { > + if (xmlStrEqual(it->name, BAD_CAST keys[i].name)) { > + value_str = g_strdup(gettext((const char *) it->children->content)); This meanwhile is matching on any ignoring the desired 'langs[j]' value. So you need to check the 'xml:lang' attribute value too Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Tue Jun 3 14:23:09 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Tue, 3 Jun 2014 15:23:09 +0100 Subject: [Libosinfo] [RFC PATCH 2/5] osinfo_loader: avoid multiple calls to OSINFO_ENTITY In-Reply-To: <1401804492-11338-3-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <1401804492-11338-3-git-send-email-gscrivan@redhat.com> Message-ID: <20140603142309.GT4207@redhat.com> On Tue, Jun 03, 2014 at 04:08:09PM +0200, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > osinfo/osinfo_loader.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c > index aa5e48f..a767bb8 100644 > --- a/osinfo/osinfo_loader.c > +++ b/osinfo/osinfo_loader.c > @@ -1657,19 +1657,20 @@ osinfo_loader_process_file_reg_ids(OsinfoLoader *loader, > baseURI, vendor_id, device_id); > > OsinfoDevice *dev = osinfo_loader_get_device(loader, id); > - osinfo_entity_set_param(OSINFO_ENTITY(dev), > + OsinfoEntity *entity = OSINFO_ENTITY(dev); > + osinfo_entity_set_param(entity, > OSINFO_DEVICE_PROP_VENDOR_ID, > vendor_id); > - osinfo_entity_set_param(OSINFO_ENTITY(dev), > + osinfo_entity_set_param(entity, > OSINFO_DEVICE_PROP_VENDOR, > vendor); > - osinfo_entity_set_param(OSINFO_ENTITY(dev), > + osinfo_entity_set_param(entity, > OSINFO_DEVICE_PROP_PRODUCT_ID, > device_id); > - osinfo_entity_set_param(OSINFO_ENTITY(dev), > + osinfo_entity_set_param(entity, > OSINFO_DEVICE_PROP_PRODUCT, > device); > - osinfo_entity_set_param(OSINFO_ENTITY(dev), > + osinfo_entity_set_param(entity, > OSINFO_DEVICE_PROP_BUS_TYPE, > busType); > g_free(id); Does this change actually have a measurable performance benefit ? If it does have a measurable benefit, then ACK, but otherwise I tend to prefer the code as it is really. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Tue Jun 3 14:24:04 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Tue, 3 Jun 2014 15:24:04 +0100 Subject: [Libosinfo] [RFC PATCH 1/5] entity: use g_hash_table_replace instead of remove+insert In-Reply-To: <1401804492-11338-2-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <1401804492-11338-2-git-send-email-gscrivan@redhat.com> Message-ID: <20140603142404.GU4207@redhat.com> On Tue, Jun 03, 2014 at 04:08:08PM +0200, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > osinfo/osinfo_entity.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c > index 5c062bc..1212f13 100644 > --- a/osinfo/osinfo_entity.c > +++ b/osinfo/osinfo_entity.c > @@ -1,7 +1,7 @@ > /* > * libosinfo: > * > - * Copyright (C) 2009-2012 Red Hat, Inc. > + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > @@ -187,9 +187,8 @@ void osinfo_entity_set_param(OsinfoEntity *entity, const gchar *key, const gchar > > GList *values = NULL; > > - g_hash_table_remove(entity->priv->params, key); > values = g_list_append(values, g_strdup(value)); > - g_hash_table_insert(entity->priv->params, g_strdup(key), values); > + g_hash_table_replace(entity->priv->params, g_strdup(key), values); > } ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Tue Jun 3 14:24:54 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Tue, 3 Jun 2014 15:24:54 +0100 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> Message-ID: <20140603142454.GV4207@redhat.com> On Tue, Jun 03, 2014 at 04:08:07PM +0200, Giuseppe Scrivano wrote: > libosinfo takes quite a while to preload its data, it was evident in > virt-manager that the UI became much slower. This series is mostly > targeted at starting a discussion about this issue. > > I thought about caching the data in another format, that could be used > instead of XML without preloading the entire DB at the startup, but it > seems like a big task considering the various relations between > objects at runtime. > > I am not sure if patch 5/5 is correct (does the lang function in the > xpath query use gettext?). > > With the following patches, the startup time is around -30% on my > machine. What do you think about these changes? Any other ideas? Pretty much look fine. I'd suggest using oprofile or sysprof to collect data on exactly where our cputime is disappearing to before trying to optimize further. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From gscrivan at redhat.com Tue Jun 3 14:41:06 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 03 Jun 2014 16:41:06 +0200 Subject: [Libosinfo] [RFC PATCH 2/5] osinfo_loader: avoid multiple calls to OSINFO_ENTITY In-Reply-To: <20140603142309.GT4207@redhat.com> (Daniel P. Berrange's message of "Tue, 3 Jun 2014 15:23:09 +0100") References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <1401804492-11338-3-git-send-email-gscrivan@redhat.com> <20140603142309.GT4207@redhat.com> Message-ID: <87wqcy3vjx.fsf@redhat.com> "Daniel P. Berrange" writes: > On Tue, Jun 03, 2014 at 04:08:09PM +0200, Giuseppe Scrivano wrote: >> Signed-off-by: Giuseppe Scrivano >> --- >> osinfo/osinfo_loader.c | 11 ++++++----- >> 1 file changed, 6 insertions(+), 5 deletions(-) >> >> diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c >> index aa5e48f..a767bb8 100644 >> --- a/osinfo/osinfo_loader.c >> +++ b/osinfo/osinfo_loader.c >> @@ -1657,19 +1657,20 @@ osinfo_loader_process_file_reg_ids(OsinfoLoader *loader, >> baseURI, vendor_id, device_id); >> >> OsinfoDevice *dev = osinfo_loader_get_device(loader, id); >> - osinfo_entity_set_param(OSINFO_ENTITY(dev), >> + OsinfoEntity *entity = OSINFO_ENTITY(dev); >> + osinfo_entity_set_param(entity, >> OSINFO_DEVICE_PROP_VENDOR_ID, >> vendor_id); >> - osinfo_entity_set_param(OSINFO_ENTITY(dev), >> + osinfo_entity_set_param(entity, >> OSINFO_DEVICE_PROP_VENDOR, >> vendor); >> - osinfo_entity_set_param(OSINFO_ENTITY(dev), >> + osinfo_entity_set_param(entity, >> OSINFO_DEVICE_PROP_PRODUCT_ID, >> device_id); >> - osinfo_entity_set_param(OSINFO_ENTITY(dev), >> + osinfo_entity_set_param(entity, >> OSINFO_DEVICE_PROP_PRODUCT, >> device); >> - osinfo_entity_set_param(OSINFO_ENTITY(dev), >> + osinfo_entity_set_param(entity, >> OSINFO_DEVICE_PROP_BUS_TYPE, >> busType); >> g_free(id); > > Does this change actually have a measurable performance benefit ? > > If it does have a measurable benefit, then ACK, but otherwise I > tend to prefer the code as it is really. not really, it only reduces the number of function calls. I will drop this change. Thanks, Giuseppe From gscrivan at redhat.com Tue Jun 3 14:51:14 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 03 Jun 2014 16:51:14 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140603142454.GV4207@redhat.com> (Daniel P. Berrange's message of "Tue, 3 Jun 2014 15:24:54 +0100") References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> Message-ID: <87sinm3v31.fsf@redhat.com> "Daniel P. Berrange" writes: > I'd suggest using oprofile or sysprof to collect data on exactly > where our cputime is disappearing to before trying to optimize > further. I've seen that creating and accessing many gobjects, as this chunk of code in osinfo_loader.c does, takes a lot of cputime: OsinfoDevice *dev = osinfo_loader_get_device(loader, id); osinfo_entity_set_param(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_VENDOR_ID, vendor_id); osinfo_entity_set_param(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_VENDOR, vendor); osinfo_entity_set_param(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_PRODUCT_ID, device_id); osinfo_entity_set_param(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_PRODUCT, device); osinfo_entity_set_param(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_BUS_TYPE, busType); I am not sure how to optimize this part, I will look if I can avoid somehow the preloading of the entire devices DB. Regards, Giuseppe From berrange at redhat.com Tue Jun 3 14:57:25 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Tue, 3 Jun 2014 15:57:25 +0100 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <87sinm3v31.fsf@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> Message-ID: <20140603145725.GY4207@redhat.com> On Tue, Jun 03, 2014 at 04:51:14PM +0200, Giuseppe Scrivano wrote: > "Daniel P. Berrange" writes: > > > I'd suggest using oprofile or sysprof to collect data on exactly > > where our cputime is disappearing to before trying to optimize > > further. > > > I've seen that creating and accessing many gobjects, as this chunk of > code in osinfo_loader.c does, takes a lot of cputime: > > OsinfoDevice *dev = osinfo_loader_get_device(loader, id); > osinfo_entity_set_param(OSINFO_ENTITY(dev), > OSINFO_DEVICE_PROP_VENDOR_ID, > vendor_id); > osinfo_entity_set_param(OSINFO_ENTITY(dev), > OSINFO_DEVICE_PROP_VENDOR, > vendor); > osinfo_entity_set_param(OSINFO_ENTITY(dev), > OSINFO_DEVICE_PROP_PRODUCT_ID, > device_id); > osinfo_entity_set_param(OSINFO_ENTITY(dev), > OSINFO_DEVICE_PROP_PRODUCT, > device); > osinfo_entity_set_param(OSINFO_ENTITY(dev), > OSINFO_DEVICE_PROP_BUS_TYPE, > busType); So that basically comes down to the performance of the hash table inserts. I wonder if we could make use of GQuark and/or g_intern_string so that the hash table lookup can do a straight pointer or int comparison, instead of strcmp. }? Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From cfergeau at redhat.com Tue Jun 3 15:07:47 2014 From: cfergeau at redhat.com (Christophe Fergeau) Date: Tue, 3 Jun 2014 17:07:47 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140603145725.GY4207@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> Message-ID: <20140603150747.GJ27464@edamame.cdg.redhat.com> On Tue, Jun 03, 2014 at 03:57:25PM +0100, Daniel P. Berrange wrote: > On Tue, Jun 03, 2014 at 04:51:14PM +0200, Giuseppe Scrivano wrote: > > "Daniel P. Berrange" writes: > > > > > I'd suggest using oprofile or sysprof to collect data on exactly > > > where our cputime is disappearing to before trying to optimize > > > further. > > > > > > I've seen that creating and accessing many gobjects, as this chunk of > > code in osinfo_loader.c does, takes a lot of cputime: > > > > OsinfoDevice *dev = osinfo_loader_get_device(loader, id); > > osinfo_entity_set_param(OSINFO_ENTITY(dev), > > OSINFO_DEVICE_PROP_VENDOR_ID, > > vendor_id); > > osinfo_entity_set_param(OSINFO_ENTITY(dev), > > OSINFO_DEVICE_PROP_VENDOR, > > vendor); > > osinfo_entity_set_param(OSINFO_ENTITY(dev), > > OSINFO_DEVICE_PROP_PRODUCT_ID, > > device_id); > > osinfo_entity_set_param(OSINFO_ENTITY(dev), > > OSINFO_DEVICE_PROP_PRODUCT, > > device); > > osinfo_entity_set_param(OSINFO_ENTITY(dev), > > OSINFO_DEVICE_PROP_BUS_TYPE, > > busType); > > So that basically comes down to the performance of the hash > table inserts. I wonder if we could make use of GQuark and/or > g_intern_string so that the hash table lookup can do a straight > pointer or int comparison, instead of strcmp. }? The call to osinfo_loader_get_device() can also hide a g_object_new(), which can be heavy. Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From gscrivan at redhat.com Tue Jun 3 16:52:47 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 03 Jun 2014 18:52:47 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140603150747.GJ27464@edamame.cdg.redhat.com> (Christophe Fergeau's message of "Tue, 3 Jun 2014 17:07:47 +0200") References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> Message-ID: <87fvjm3pgg.fsf@redhat.com> Christophe Fergeau writes: > On Tue, Jun 03, 2014 at 03:57:25PM +0100, Daniel P. Berrange wrote: >> On Tue, Jun 03, 2014 at 04:51:14PM +0200, Giuseppe Scrivano wrote: >> > "Daniel P. Berrange" writes: >> > >> > > I'd suggest using oprofile or sysprof to collect data on exactly >> > > where our cputime is disappearing to before trying to optimize >> > > further. >> > >> > >> > I've seen that creating and accessing many gobjects, as this chunk of >> > code in osinfo_loader.c does, takes a lot of cputime: >> > >> > OsinfoDevice *dev = osinfo_loader_get_device(loader, id); >> > osinfo_entity_set_param(OSINFO_ENTITY(dev), >> > OSINFO_DEVICE_PROP_VENDOR_ID, >> > vendor_id); >> > osinfo_entity_set_param(OSINFO_ENTITY(dev), >> > OSINFO_DEVICE_PROP_VENDOR, >> > vendor); >> > osinfo_entity_set_param(OSINFO_ENTITY(dev), >> > OSINFO_DEVICE_PROP_PRODUCT_ID, >> > device_id); >> > osinfo_entity_set_param(OSINFO_ENTITY(dev), >> > OSINFO_DEVICE_PROP_PRODUCT, >> > device); >> > osinfo_entity_set_param(OSINFO_ENTITY(dev), >> > OSINFO_DEVICE_PROP_BUS_TYPE, >> > busType); >> >> So that basically comes down to the performance of the hash >> table inserts. I wonder if we could make use of GQuark and/or >> g_intern_string so that the hash table lookup can do a straight >> pointer or int comparison, instead of strcmp. }? > > The call to osinfo_loader_get_device() can also hide a g_object_new(), > which can be heavy. indeed, g_object_new seems to be very slow. I will try to play with what Daniel suggested and see if it makes any difference. I am going to send a v2 soon with all the suggested fixes for this series. Thanks, Giuseppe From gscrivan at redhat.com Tue Jun 3 18:19:00 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 20:19:00 +0200 Subject: [Libosinfo] [PATCH v2 0/4] various optimizations Message-ID: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> It addresses the comments for v1 posted here: https://www.redhat.com/archives/libosinfo/2014-June/msg00000.html Giuseppe Scrivano (4): entity: use g_hash_table_replace instead of remove+insert osinfo_loader: introduce a compiled xpaths cache osinfo_loader: replace some xpath queries with direct data access osinfo_loader: do not use xpath to read localized strings osinfo/osinfo_entity.c | 5 +- osinfo/osinfo_loader.c | 255 +++++++++++++++++++++++-------------------------- 2 files changed, 124 insertions(+), 136 deletions(-) -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 18:19:01 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 20:19:01 +0200 Subject: [Libosinfo] [PATCH v2 1/4] entity: use g_hash_table_replace instead of remove+insert In-Reply-To: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> References: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401819544-24381-2-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_entity.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c index 5c062bc..1212f13 100644 --- a/osinfo/osinfo_entity.c +++ b/osinfo/osinfo_entity.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -187,9 +187,8 @@ void osinfo_entity_set_param(OsinfoEntity *entity, const gchar *key, const gchar GList *values = NULL; - g_hash_table_remove(entity->priv->params, key); values = g_list_append(values, g_strdup(value)); - g_hash_table_insert(entity->priv->params, g_strdup(key), values); + g_hash_table_replace(entity->priv->params, g_strdup(key), values); } -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 18:19:02 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 20:19:02 +0200 Subject: [Libosinfo] [PATCH v2 2/4] osinfo_loader: introduce a compiled xpaths cache In-Reply-To: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> References: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401819544-24381-3-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 124 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 37 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index aa5e48f..dba6a2a 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -55,6 +55,7 @@ G_DEFINE_TYPE (OsinfoLoader, osinfo_loader, G_TYPE_OBJECT); struct _OsinfoLoaderPrivate { OsinfoDb *db; + GHashTable *xpath_cache; }; struct _OsinfoEntityKey @@ -70,6 +71,7 @@ osinfo_loader_finalize (GObject *object) OsinfoLoader *loader = OSINFO_LOADER (object); g_object_unref(loader->priv->db); + g_hash_table_destroy(loader->priv->xpath_cache); /* Chain up to the parent class */ G_OBJECT_CLASS (osinfo_loader_parent_class)->finalize (object); @@ -89,11 +91,21 @@ osinfo_loader_class_init (OsinfoLoaderClass *klass) g_type_class_add_private (klass, sizeof (OsinfoLoaderPrivate)); } + +static void xpath_cache_value_free(gpointer values) +{ + xmlXPathFreeCompExpr(values); +} + static void osinfo_loader_init (OsinfoLoader *loader) { loader->priv = OSINFO_LOADER_GET_PRIVATE(loader); loader->priv->db = osinfo_db_new(); + loader->priv->xpath_cache = g_hash_table_new_full(g_str_hash, + g_str_equal, + g_free, + xpath_cache_value_free); } /** PUBLIC METHODS */ @@ -118,8 +130,21 @@ static gboolean error_is_set(GError **error) return ((error != NULL) && (*error != NULL)); } +static xmlXPathCompExprPtr osinfo_loader_get_comp_xpath(OsinfoLoader *loader, + const char *xpath) +{ + xmlXPathCompExprPtr comp = g_hash_table_lookup(loader->priv->xpath_cache, + xpath); + if (comp == NULL) { + comp = xmlXPathCompile(BAD_CAST xpath); + g_hash_table_insert(loader->priv->xpath_cache, g_strdup(xpath), comp); + } + return comp; +} + static int osinfo_loader_nodeset(const char *xpath, + OsinfoLoader *loader, xmlXPathContextPtr ctxt, xmlNodePtr **list, GError **err) @@ -127,15 +152,19 @@ osinfo_loader_nodeset(const char *xpath, xmlXPathObjectPtr obj; xmlNodePtr relnode; int ret; + xmlXPathCompExprPtr comp; g_return_val_if_fail(ctxt != NULL, -1); g_return_val_if_fail(xpath != NULL, -1); + g_return_val_if_fail(loader != NULL, NULL); + + comp = osinfo_loader_get_comp_xpath(loader, xpath); if (list != NULL) *list = NULL; relnode = ctxt->node; - obj = xmlXPathEval(BAD_CAST xpath, ctxt); + obj = xmlXPathCompiledEval(comp, ctxt); ctxt->node = relnode; if (obj == NULL) return(0); @@ -162,18 +191,23 @@ osinfo_loader_nodeset(const char *xpath, static gchar * osinfo_loader_string(const char *xpath, + OsinfoLoader *loader, xmlXPathContextPtr ctxt, GError **err) { xmlXPathObjectPtr obj; xmlNodePtr relnode; gchar *ret; + xmlXPathCompExprPtr comp; g_return_val_if_fail(ctxt != NULL, NULL); g_return_val_if_fail(xpath != NULL, NULL); + g_return_val_if_fail(loader != NULL, NULL); + comp = osinfo_loader_get_comp_xpath(loader, xpath); relnode = ctxt->node; - obj = xmlXPathEval(BAD_CAST xpath, ctxt); + obj = xmlXPathCompiledEval(comp, ctxt); + ctxt->node = relnode; if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL) || (obj->stringval[0] == 0)) { @@ -188,6 +222,7 @@ osinfo_loader_string(const char *xpath, static gboolean osinfo_loader_boolean(const char *xpath, + OsinfoLoader *loader, xmlXPathContextPtr ctxt, GError **err) { @@ -199,8 +234,9 @@ osinfo_loader_boolean(const char *xpath, g_return_val_if_fail(ctxt != NULL, FALSE); g_return_val_if_fail(xpath != NULL, FALSE); + g_return_val_if_fail(loader != NULL, FALSE); - count = osinfo_loader_nodeset(xpath, ctxt, &nodes, err); + count = osinfo_loader_nodeset(xpath, loader, ctxt, &nodes, err); if (count < 0) { return FALSE; @@ -230,6 +266,7 @@ cleanup: static gchar * osinfo_loader_doc(const char *xpath, + OsinfoLoader *loader, xmlXPathContextPtr ctxt, GError **err) { @@ -240,9 +277,12 @@ osinfo_loader_doc(const char *xpath, g_return_val_if_fail(ctxt != NULL, NULL); g_return_val_if_fail(xpath != NULL, NULL); + g_return_val_if_fail(loader != NULL, NULL); + + xmlXPathCompExprPtr comp = osinfo_loader_get_comp_xpath(loader, xpath); relnode = ctxt->node; - obj = xmlXPathEval(BAD_CAST xpath, ctxt); + obj = xmlXPathCompiledEval(comp, ctxt); ctxt->node = relnode; if ((obj == NULL) || (obj->type != XPATH_NODESET)) { xmlXPathFreeObject(obj); @@ -291,7 +331,7 @@ static void osinfo_loader_entity(OsinfoLoader *loader, for (j = 0; langs[j + 1] != NULL; j++) { xpath = g_strdup_printf("string(./%s[lang('%s')])", keys[i].name, langs[j]); - value_str = osinfo_loader_string(xpath, ctxt, err); + value_str = osinfo_loader_string(xpath, loader, ctxt, err); g_free(xpath); xpath = NULL; if (error_is_set(err)) @@ -304,20 +344,21 @@ static void osinfo_loader_entity(OsinfoLoader *loader, switch (keys[i].type) { case G_TYPE_STRING: - xpath = g_strdup_printf("string(./%s)", keys[i].name); if (value_str == NULL) { - value_str = osinfo_loader_string(xpath, ctxt, err); + xpath = g_strdup_printf("string(./%s)", keys[i].name); + value_str = osinfo_loader_string(xpath, loader, ctxt, err); + g_free(xpath); } break; case G_TYPE_BOOLEAN: xpath = g_strdup_printf("./%s", keys[i].name); - value_bool = osinfo_loader_boolean(xpath, ctxt, err); + value_bool = osinfo_loader_boolean(xpath, loader, ctxt, err); + g_free(xpath); break; default: g_warn_if_reached(); break; } - g_free(xpath); switch (keys[i].type) { case G_TYPE_STRING: @@ -339,7 +380,8 @@ static void osinfo_loader_entity(OsinfoLoader *loader, /* Then any site specific custom keys. x-... Can be repeated */ xmlNodePtr *custom = NULL; - int ncustom = osinfo_loader_nodeset("./*[substring(name(),1,2)='x-']", ctxt, &custom, err); + int ncustom = osinfo_loader_nodeset("./*[substring(name(),1,2)='x-']", + loader, ctxt, &custom, err); if (error_is_set(err)) return; @@ -457,7 +499,7 @@ static void osinfo_loader_device_link(OsinfoLoader *loader, GError **err) { xmlNodePtr *related = NULL; - int nrelated = osinfo_loader_nodeset(xpath, ctxt, &related, err); + int nrelated = osinfo_loader_nodeset(xpath, loader, ctxt, &related, err); int i; if (error_is_set(err)) return; @@ -505,7 +547,7 @@ static void osinfo_loader_product_relshp(OsinfoLoader *loader, GError **err) { xmlNodePtr *related = NULL; - int nrelated = osinfo_loader_nodeset(xpath, ctxt, &related, err); + int nrelated = osinfo_loader_nodeset(xpath, loader, ctxt, &related, err); int i; if (error_is_set(err)) return; @@ -617,7 +659,7 @@ static void osinfo_loader_deployment(OsinfoLoader *loader, return; } - gchar *osid = osinfo_loader_string("string(./os/@id)", ctxt, err); + gchar *osid = osinfo_loader_string("string(./os/@id)", loader, ctxt, err); if (!osid && 0) { OSINFO_ERROR(err, _("Missing deployment os id property")); xmlFree(id); @@ -626,7 +668,8 @@ static void osinfo_loader_deployment(OsinfoLoader *loader, OsinfoOs *os = osinfo_loader_get_os(loader, osid); g_free(osid); - gchar *platformid = osinfo_loader_string("string(./platform/@id)", ctxt, err); + gchar *platformid = osinfo_loader_string("string(./platform/@id)", loader, + ctxt, err); if (!platformid) { OSINFO_ERROR(err, _("Missing deployment platform id property")); xmlFree(id); @@ -672,7 +715,7 @@ static void osinfo_loader_datamap(OsinfoLoader *loader, OsinfoDatamap *map = osinfo_loader_get_datamap(loader, id); - nnodes = osinfo_loader_nodeset("./entry", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./entry", loader, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -702,7 +745,7 @@ static void osinfo_loader_install_config_params(OsinfoLoader *loader, GError **err) { xmlNodePtr *nodes = NULL; - int nnodes = osinfo_loader_nodeset(xpath, ctxt, &nodes, err); + int nnodes = osinfo_loader_nodeset(xpath, loader, ctxt, &nodes, err); int i; if (error_is_set(err)) return; @@ -794,7 +837,7 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, if (error_is_set(err)) goto error; - value = osinfo_loader_doc("./template/*[1]", ctxt, err); + value = osinfo_loader_doc("./template/*[1]", loader, ctxt, err); if (error_is_set(err)) goto error; if (value) @@ -803,7 +846,7 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, value); g_free(value); - value = osinfo_loader_string("./template/@uri", ctxt, err); + value = osinfo_loader_string("./template/@uri", loader, ctxt, err); if (error_is_set(err)) goto error; if (value) @@ -819,7 +862,8 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, root, err); - nnodes = osinfo_loader_nodeset("./avatar-format", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./avatar-format", loader, ctxt, &nodes, + err); if (error_is_set(err)) goto error; @@ -837,7 +881,8 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, } g_free(nodes); - nnodes = osinfo_loader_nodeset("./injection-method", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./injection-method", loader, ctxt, &nodes, + err); if (error_is_set(err)) goto error; @@ -910,7 +955,7 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, xmlFree(installer_reboots); } - gint nnodes = osinfo_loader_nodeset("./variant", ctxt, &nodes, err); + gint nnodes = osinfo_loader_nodeset("./variant", loader, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(media); return NULL; @@ -925,7 +970,7 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, } g_free(nodes); - nnodes = osinfo_loader_nodeset("./iso/*", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./iso/*", loader, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(media); return NULL; @@ -1001,7 +1046,7 @@ static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader, osinfo_loader_entity(loader, OSINFO_ENTITY(tree), keys, ctxt, root, err); - gint nnodes = osinfo_loader_nodeset("./treeinfo/*", ctxt, &nodes, err); + gint nnodes = osinfo_loader_nodeset("./treeinfo/*", loader, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(G_OBJECT(tree)); return NULL; @@ -1071,7 +1116,7 @@ static OsinfoResources *osinfo_loader_resources(OsinfoLoader *loader, gchar *arch = (gchar *)xmlGetProp(root, BAD_CAST "arch"); gchar *node_path = g_strjoin("/", ".", name, "*", NULL); - gint nnodes = osinfo_loader_nodeset(node_path, ctxt, &nodes, err); + gint nnodes = osinfo_loader_nodeset(node_path, loader, ctxt, &nodes, err); g_free(node_path); if (error_is_set(err) || nnodes < 1) goto EXIT; @@ -1175,7 +1220,7 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader, xmlFree(is_signed); } - gint nnodes = osinfo_loader_nodeset("./*", ctxt, &nodes, err); + gint nnodes = osinfo_loader_nodeset("./*", loader, ctxt, &nodes, err); if (error_is_set(err)) { g_object_unref(G_OBJECT(driver)); return NULL; @@ -1243,7 +1288,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - nnodes = osinfo_loader_nodeset("./media", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./media", loader, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1263,7 +1308,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./tree", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./tree", loader, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1283,7 +1328,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./variant", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./variant", loader, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1304,7 +1349,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./resources", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./resources", loader, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1326,7 +1371,8 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./installer/script", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./installer/script", loader, ctxt, &nodes, + err); if (error_is_set(err)) goto cleanup; @@ -1345,7 +1391,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, g_free(nodes); - nnodes = osinfo_loader_nodeset("./driver", ctxt, &nodes, err); + nnodes = osinfo_loader_nodeset("./driver", loader, ctxt, &nodes, err); if (error_is_set(err)) goto cleanup; @@ -1412,7 +1458,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, return; } - ndevice = osinfo_loader_nodeset("./device", ctxt, &devices, err); + ndevice = osinfo_loader_nodeset("./device", loader, ctxt, &devices, err); if (error_is_set(err)) goto cleanup; @@ -1425,7 +1471,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - nplatform = osinfo_loader_nodeset("./platform", ctxt, &platforms, err); + nplatform = osinfo_loader_nodeset("./platform", loader, ctxt, &platforms, + err); if (error_is_set(err)) goto cleanup; @@ -1438,7 +1485,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - nos = osinfo_loader_nodeset("./os", ctxt, &oss, err); + nos = osinfo_loader_nodeset("./os", loader, ctxt, &oss, err); if (error_is_set(err)) goto cleanup; @@ -1451,7 +1498,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - ndeployment = osinfo_loader_nodeset("./deployment", ctxt, &deployments, err); + ndeployment = osinfo_loader_nodeset("./deployment", loader, ctxt, + &deployments, err); if (error_is_set(err)) goto cleanup; @@ -1464,7 +1512,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - ninstallScript = osinfo_loader_nodeset("./install-script", ctxt, &installScripts, err); + ninstallScript = osinfo_loader_nodeset("./install-script", loader, ctxt, + &installScripts, err); if (error_is_set(err)) goto cleanup; @@ -1477,7 +1526,8 @@ static void osinfo_loader_root(OsinfoLoader *loader, goto cleanup; } - ndataMaps = osinfo_loader_nodeset("./datamap", ctxt, &dataMaps, err); + ndataMaps = osinfo_loader_nodeset("./datamap", loader, ctxt, &dataMaps, + err); if (error_is_set(err)) goto cleanup; -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 18:19:03 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 20:19:03 +0200 Subject: [Libosinfo] [PATCH v2 3/4] osinfo_loader: replace some xpath queries with direct data access In-Reply-To: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> References: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401819544-24381-4-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 129 ++++++++++++------------------------------------- 1 file changed, 32 insertions(+), 97 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index dba6a2a..6e79e78 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -541,19 +541,25 @@ static void osinfo_loader_device_link(OsinfoLoader *loader, static void osinfo_loader_product_relshp(OsinfoLoader *loader, OsinfoProduct *product, OsinfoProductRelationship relshp, - const gchar *xpath, + const gchar *name, xmlXPathContextPtr ctxt, xmlNodePtr root, GError **err) { xmlNodePtr *related = NULL; - int nrelated = osinfo_loader_nodeset(xpath, loader, ctxt, &related, err); - int i; + xmlNodePtr it; + if (error_is_set(err)) return; - for (i = 0 ; i < nrelated ; i++) { - gchar *id = (gchar *)xmlGetProp(related[i], BAD_CAST "id"); + for(it = root->children; it; it = it->next) { + if (it->type != XML_ELEMENT_NODE) + continue; + + if (!xmlStrEqual(it->name, BAD_CAST name)) + continue; + + gchar *id = (gchar *)xmlGetProp(it, BAD_CAST "id"); if (!id) { OSINFO_ERROR(err, _("Missing product upgrades id property")); goto cleanup; @@ -596,7 +602,7 @@ static void osinfo_loader_product(OsinfoLoader *loader, osinfo_loader_product_relshp(loader, product, OSINFO_PRODUCT_RELATIONSHIP_DERIVES_FROM, - "./derives-from", + "derives-from", ctxt, root, err); @@ -605,7 +611,7 @@ static void osinfo_loader_product(OsinfoLoader *loader, osinfo_loader_product_relshp(loader, product, OSINFO_PRODUCT_RELATIONSHIP_CLONES, - "./clones", + "clones", ctxt, root, err); @@ -614,7 +620,7 @@ static void osinfo_loader_product(OsinfoLoader *loader, osinfo_loader_product_relshp(loader, product, OSINFO_PRODUCT_RELATIONSHIP_UPGRADES, - "./upgrades", + "upgrades", ctxt, root, err); @@ -1439,114 +1445,43 @@ static void osinfo_loader_root(OsinfoLoader *loader, * After loop, return success if no error * If there was an error, clean up lib data acquired so far */ - xmlNodePtr *oss = NULL; - xmlNodePtr *devices = NULL; - xmlNodePtr *platforms = NULL; - xmlNodePtr *deployments = NULL; - xmlNodePtr *installScripts = NULL; - xmlNodePtr *dataMaps = NULL; - int i; - int ndeployment; - int nos; - int ndevice; - int nplatform; - int ninstallScript; - int ndataMaps; + xmlNodePtr it; if (!xmlStrEqual(root->name, BAD_CAST "libosinfo")) { OSINFO_ERROR(err, _("Incorrect root element")); return; } - ndevice = osinfo_loader_nodeset("./device", loader, ctxt, &devices, err); - if (error_is_set(err)) - goto cleanup; + for(it = root->children; it; it = it->next) { + if (it->type != XML_ELEMENT_NODE) + continue; - for (i = 0 ; i < ndevice ; i++) { xmlNodePtr saved = ctxt->node; - ctxt->node = devices[i]; - osinfo_loader_device(loader, ctxt, devices[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } + ctxt->node = it; - nplatform = osinfo_loader_nodeset("./platform", loader, ctxt, &platforms, - err); - if (error_is_set(err)) - goto cleanup; + if (xmlStrEqual(it->name, BAD_CAST "device")) + osinfo_loader_device(loader, ctxt, it, err); - for (i = 0 ; i < nplatform ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = platforms[i]; - osinfo_loader_platform(loader, ctxt, platforms[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } - - nos = osinfo_loader_nodeset("./os", loader, ctxt, &oss, err); - if (error_is_set(err)) - goto cleanup; + else if (xmlStrEqual(it->name, BAD_CAST "platform")) + osinfo_loader_platform(loader, ctxt, it, err); - for (i = 0 ; i < nos ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = oss[i]; - osinfo_loader_os(loader, ctxt, oss[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } + else if (xmlStrEqual(it->name, BAD_CAST "os")) + osinfo_loader_os(loader, ctxt, it, err); - ndeployment = osinfo_loader_nodeset("./deployment", loader, ctxt, - &deployments, err); - if (error_is_set(err)) - goto cleanup; + else if (xmlStrEqual(it->name, BAD_CAST "deployment")) + osinfo_loader_deployment(loader, ctxt, it, err); - for (i = 0 ; i < ndeployment ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = deployments[i]; - osinfo_loader_deployment(loader, ctxt, deployments[i], err); - ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } + else if (xmlStrEqual(it->name, BAD_CAST "install-script")) + osinfo_loader_install_script(loader, ctxt, it, err); - ninstallScript = osinfo_loader_nodeset("./install-script", loader, ctxt, - &installScripts, err); - if (error_is_set(err)) - goto cleanup; + else if (xmlStrEqual(it->name, BAD_CAST "datamap")) + osinfo_loader_datamap(loader, ctxt, it, err); - for (i = 0 ; i < ninstallScript ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = installScripts[i]; - osinfo_loader_install_script(loader, ctxt, installScripts[i], err); ctxt->node = saved; - if (error_is_set(err)) - goto cleanup; - } - - ndataMaps = osinfo_loader_nodeset("./datamap", loader, ctxt, &dataMaps, - err); - if (error_is_set(err)) - goto cleanup; - for (i = 0 ; i < ndataMaps ; i++) { - xmlNodePtr saved = ctxt->node; - ctxt->node = dataMaps[i]; - osinfo_loader_datamap(loader, ctxt, dataMaps[i], err); - ctxt->node = saved; if (error_is_set(err)) - goto cleanup; + return; } - - cleanup: - g_free(dataMaps); - g_free(installScripts); - g_free(deployments); - g_free(platforms); - g_free(oss); - g_free(devices); } static void -- 1.9.3 From gscrivan at redhat.com Tue Jun 3 18:19:04 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Tue, 3 Jun 2014 20:19:04 +0200 Subject: [Libosinfo] [PATCH v2 4/4] osinfo_loader: do not use xpath to read localized strings In-Reply-To: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> References: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401819544-24381-5-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 6e79e78..6fe7145 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -328,17 +328,21 @@ static void osinfo_loader_entity(OsinfoLoader *loader, * want to ignore that, hence the NULL check on index 'j + 1'. */ if (keys[i].type == G_TYPE_STRING) { - for (j = 0; langs[j + 1] != NULL; j++) { - xpath = g_strdup_printf("string(./%s[lang('%s')])", - keys[i].name, langs[j]); - value_str = osinfo_loader_string(xpath, loader, ctxt, err); - g_free(xpath); - xpath = NULL; - if (error_is_set(err)) - return; - - if (value_str != NULL) - break; + xmlNodePtr it; + for (it = root->children; it; it = it->next) { + if (xmlStrEqual(it->name, BAD_CAST keys[i].name)) { + xmlChar *lang = xmlGetProp(it, BAD_CAST "lang"); + if (lang == NULL) + continue; + + for (j = 0; langs[j + 1] != NULL; j++) { + if (xmlStrEqual(lang, BAD_CAST langs[j])) { + gchar *content = (gchar *) it->children->content; + value_str = g_strdup(content); + break; + } + } + } } } -- 1.9.3 From eblake at redhat.com Tue Jun 3 18:38:19 2014 From: eblake at redhat.com (Eric Blake) Date: Tue, 03 Jun 2014 12:38:19 -0600 Subject: [Libosinfo] [PATCH v2 3/4] osinfo_loader: replace some xpath queries with direct data access In-Reply-To: <1401819544-24381-4-git-send-email-gscrivan@redhat.com> References: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> <1401819544-24381-4-git-send-email-gscrivan@redhat.com> Message-ID: <538E161B.4070505@redhat.com> On 06/03/2014 12:19 PM, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > - for (i = 0 ; i < nrelated ; i++) { > - gchar *id = (gchar *)xmlGetProp(related[i], BAD_CAST "id"); > + for(it = root->children; it; it = it->next) { Style nit - isn't there supposed to be a space after 'for' ? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 604 bytes Desc: OpenPGP digital signature URL: From cfergeau at redhat.com Wed Jun 4 08:38:15 2014 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 4 Jun 2014 10:38:15 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <87fvjm3pgg.fsf@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> Message-ID: <20140604083815.GQ27464@edamame.cdg.redhat.com> On Tue, Jun 03, 2014 at 06:52:47PM +0200, Giuseppe Scrivano wrote: > Christophe Fergeau writes: > > The call to osinfo_loader_get_device() can also hide a g_object_new(), > > which can be heavy. > > indeed, g_object_new seems to be very slow. I will try to play with > what Daniel suggested and see if it makes any difference. Some profiling should tell you if the expensive part is the object creation or the hash table insertion, and how much slower one is compared to the ohter. Did you get these numbers by any chance? Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From lasse.schuirmann at gmail.com Wed Jun 4 08:55:01 2014 From: lasse.schuirmann at gmail.com (Lasse Schuirmann) Date: Wed, 4 Jun 2014 10:55:01 +0200 Subject: [Libosinfo] [PATCH] fedora: Adjust initrd/kernel paths to real file In-Reply-To: References: <20140530085247.GV14904@edamame.cdg.redhat.com> Message-ID: 2014-05-30 12:24 GMT+02:00 Zeeshan Ali (Khattak) : > On Fri, May 30, 2014 at 9:52 AM, Christophe Fergeau wrote: >> On Thu, May 29, 2014 at 07:44:57PM +0200, Lasse Schuirmann wrote: >>> What is the hardlink and what is the "real file" is determined during >>> the compression process nondeterministically. (To be exact the first >>> occurrence will be the "real" file [entry + body] and the following >>> will be only the entries without body in this archive format IIRC.) >>> That is the reason while the paths of the 32 bit iso and the 64 bit >>> iso differ. >> >> This sounds like something that will need to be updated with every new >> releases rather than having some somehow fixed path. This was also a >> non-issue when Boxes was using iso-read, but is now more complicated >> since it chose to switch to libarchive (but not impossible). From a >> quick reading of libarchive page about link handling, I'm under the >> impression that it's writing which is hard, I'm not sure reading is that >> complicated, and I think reading is enough in the Fedora case. >> >> Short version: I don't think this is a great change, and this is >> something Boxes can/should handle, so NACK from me. > > Hmm.. good points. Thanks for chimming in. :) > > -- > Regards, > > Zeeshan Ali (Khattak) > ________________________________________ > Befriend GNOME: http://www.gnome.org/friends/ I have implemented the hardlink support in Boxes so it is no problem anymore for us. I think it may be a problem for other people using libosinfo. You have to download the ISO anyway to make the new entry, I don't see why it is difficult to just choose the "real" file (its the only one that is named appropriately and doesn't seem to have a size of 0 bytes in file-roller). I think it's just friendly forward to the users of libosinfo. (I do agree that this patch is quite optional!) It also improves performance a bit for the users since they may have to reiterate through the archive again to follow the hardlink. Just state whether you want this patch or not, in case I'll refine it for you. Greetings, Lasse From gscrivan at redhat.com Wed Jun 4 09:50:52 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 4 Jun 2014 11:50:52 +0200 Subject: [Libosinfo] [PATCH 0/5] fix bracket spacing Message-ID: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Fix bracket spacing and enforce it with a new syntax rule (copied from libvirt). Giuseppe Scrivano (5): osinfo_loader: don't wrap return value with parentheses test: fix spacing to satisfy sc_bracket_spacing_check tools: fix spacing to satisfy sc_bracket_spacing_check osinfo: fix spacing to satisfy sc_bracket_spacing_check enforce bracket spacing with a syntax rule build-aux/bracket-spacing.pl | 162 +++++++++++++ cfg.mk | 6 + osinfo/osinfo_avatar_format.c | 16 +- osinfo/osinfo_datamap.c | 18 +- osinfo/osinfo_datamaplist.c | 18 +- osinfo/osinfo_db.c | 48 ++-- osinfo/osinfo_deployment.c | 28 +-- osinfo/osinfo_deploymentlist.c | 18 +- osinfo/osinfo_device.c | 20 +- osinfo/osinfo_device_driver.c | 28 +-- osinfo/osinfo_device_driverlist.c | 18 +- osinfo/osinfo_devicelink.c | 24 +- osinfo/osinfo_devicelinkfilter.c | 26 +-- osinfo/osinfo_devicelinklist.c | 20 +- osinfo/osinfo_devicelist.c | 18 +- osinfo/osinfo_entity.c | 44 ++-- osinfo/osinfo_filter.c | 22 +- osinfo/osinfo_install_config.c | 14 +- osinfo/osinfo_install_config_param.c | 24 +- osinfo/osinfo_install_config_paramlist.c | 18 +- osinfo/osinfo_install_script.c | 28 +-- osinfo/osinfo_install_scriptlist.c | 18 +- osinfo/osinfo_list.c | 24 +- osinfo/osinfo_loader.c | 116 +++++----- osinfo/osinfo_media.c | 382 +++++++++++++++---------------- osinfo/osinfo_medialist.c | 18 +- osinfo/osinfo_os.c | 84 +++---- osinfo/osinfo_os_variant.c | 48 ++-- osinfo/osinfo_os_variantlist.c | 12 +- osinfo/osinfo_oslist.c | 18 +- osinfo/osinfo_platform.c | 20 +- osinfo/osinfo_platformlist.c | 18 +- osinfo/osinfo_product.c | 138 +++++------ osinfo/osinfo_productfilter.c | 24 +- osinfo/osinfo_productlist.c | 18 +- osinfo/osinfo_resources.c | 178 +++++++------- osinfo/osinfo_resourceslist.c | 18 +- osinfo/osinfo_tree.c | 12 +- osinfo/osinfo_treelist.c | 22 +- test/test-db.c | 18 +- test/test-device.c | 12 +- test/test-devicelist.c | 18 +- test/test-entity.c | 16 +- test/test-filter.c | 12 +- test/test-install-script.c | 24 +- test/test-isodetect.c | 12 +- test/test-list.c | 26 +-- test/test-loader.c | 12 +- test/test-mediauris.c | 18 +- test/test-os.c | 12 +- test/test-oslist.c | 18 +- test/test-platform.c | 14 +- test/test-platformlist.c | 18 +- test/test-product.c | 16 +- test/test-productfilter.c | 16 +- test/test-treeuris.c | 18 +- tools/osinfo-db-validate.c | 8 +- tools/osinfo-detect.c | 14 +- tools/osinfo-install-script.c | 8 +- tools/osinfo-query.c | 24 +- 60 files changed, 1144 insertions(+), 976 deletions(-) create mode 100755 build-aux/bracket-spacing.pl -- 1.9.3 From gscrivan at redhat.com Wed Jun 4 09:50:53 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 4 Jun 2014 11:50:53 +0200 Subject: [Libosinfo] [PATCH 1/5] osinfo_loader: don't wrap return value with parentheses In-Reply-To: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401875457-21439-2-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_loader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index aa5e48f..685352b 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -138,16 +138,16 @@ osinfo_loader_nodeset(const char *xpath, obj = xmlXPathEval(BAD_CAST xpath, ctxt); ctxt->node = relnode; if (obj == NULL) - return(0); + return 0; if (obj->type != XPATH_NODESET) { g_set_error(err, g_quark_from_static_string("libosinfo"), 0, _("Expected a nodeset in XPath query %s"), xpath); xmlXPathFreeObject(obj); - return (-1); + return -1; } if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr < 0)) { xmlXPathFreeObject(obj); - return (0); + return 0; } ret = obj->nodesetval->nodeNr; @@ -157,7 +157,7 @@ osinfo_loader_nodeset(const char *xpath, ret * sizeof(xmlNodePtr)); } xmlXPathFreeObject(obj); - return (ret); + return ret; } static gchar * -- 1.9.3 From gscrivan at redhat.com Wed Jun 4 09:50:54 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 4 Jun 2014 11:50:54 +0200 Subject: [Libosinfo] [PATCH 2/5] test: fix spacing to satisfy sc_bracket_spacing_check In-Reply-To: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401875457-21439-3-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- test/test-db.c | 18 +++++++++--------- test/test-device.c | 12 ++++++------ test/test-devicelist.c | 18 +++++++++--------- test/test-entity.c | 16 ++++++++-------- test/test-filter.c | 12 ++++++------ test/test-install-script.c | 24 ++++++++++++------------ test/test-isodetect.c | 12 ++++++------ test/test-list.c | 26 +++++++++++++------------- test/test-loader.c | 12 ++++++------ test/test-mediauris.c | 18 +++++++++--------- test/test-os.c | 12 ++++++------ test/test-oslist.c | 18 +++++++++--------- test/test-platform.c | 14 +++++++------- test/test-platformlist.c | 18 +++++++++--------- test/test-product.c | 16 ++++++++-------- test/test-productfilter.c | 16 ++++++++-------- test/test-treeuris.c | 18 +++++++++--------- 17 files changed, 140 insertions(+), 140 deletions(-) diff --git a/test/test-db.c b/test/test-db.c index 576f40f..df586f6 100644 --- a/test/test-db.c +++ b/test/test-db.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -304,7 +304,7 @@ START_TEST(test_rel_os) gboolean hasOs5 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(sublist)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(sublist)); i++) { OsinfoOs *ent = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(sublist), i)); if (ent == os1) @@ -332,7 +332,7 @@ START_TEST(test_rel_os) sublist = osinfo_db_unique_values_for_os_relationship(db, OSINFO_PRODUCT_RELATIONSHIP_UPGRADES); hasOs1 = hasOs2 = hasOs3 = hasOs4 = hasOs5 = hasBad = FALSE; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(sublist)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(sublist)); i++) { OsinfoOs *ent = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(sublist), i)); if (ent == os1) @@ -360,7 +360,7 @@ START_TEST(test_rel_os) sublist = osinfo_db_unique_values_for_os_relationship(db, OSINFO_PRODUCT_RELATIONSHIP_CLONES); hasOs1 = hasOs2 = hasOs3 = hasOs4 = hasOs5 = hasBad = FALSE; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(sublist)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(sublist)); i++) { OsinfoOs *ent = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(sublist), i)); if (ent == os1) @@ -419,8 +419,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -438,9 +438,9 @@ int main(void) osinfo_oslist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-device.c b/test/test-device.c index 4b9d3c6..72f8e8c 100644 --- a/test/test-device.c +++ b/test/test-device.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,8 +52,8 @@ device_suite(void) int main(void) { int number_failed; - Suite *s = device_suite (); - SRunner *sr = srunner_create (s); + Suite *s = device_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -62,9 +62,9 @@ int main(void) /* Upfront so we don't confuse valgrind */ osinfo_device_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-devicelist.c b/test/test-devicelist.c index c3aa65f..02f0ff7 100644 --- a/test/test-devicelist.c +++ b/test/test-devicelist.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ START_TEST(test_union) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list3)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list3)); i++) { OsinfoDevice *ent = OSINFO_DEVICE(osinfo_list_get_nth(OSINFO_LIST(list3), i)); if (ent == ent1) has1 = TRUE; @@ -112,7 +112,7 @@ START_TEST(test_intersect) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list3)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list3)); i++) { OsinfoDevice *ent = OSINFO_DEVICE(osinfo_list_get_nth(OSINFO_LIST(list3), i)); if (ent == ent1) has1 = TRUE; @@ -176,7 +176,7 @@ START_TEST(test_filter) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list2)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list2)); i++) { OsinfoDevice *ent = OSINFO_DEVICE(osinfo_list_get_nth(OSINFO_LIST(list2), i)); if (ent == ent1) has1 = TRUE; @@ -221,8 +221,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -233,9 +233,9 @@ int main(void) osinfo_devicelist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-entity.c b/test/test-entity.c index aeee513..03dc570 100644 --- a/test/test-entity.c +++ b/test/test-entity.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,10 +41,10 @@ struct _OsinfoDummyClass GType osinfo_dummy_get_type(void); -G_DEFINE_TYPE (OsinfoDummy, osinfo_dummy, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoDummy, osinfo_dummy, OSINFO_TYPE_ENTITY); static void osinfo_dummy_class_init(OsinfoDummyClass *klass G_GNUC_UNUSED){} -static void osinfo_dummy_init (OsinfoDummy *self G_GNUC_UNUSED) {} +static void osinfo_dummy_init(OsinfoDummy *self G_GNUC_UNUSED) {} START_TEST(test_id) @@ -332,8 +332,8 @@ entity_suite(void) int main(void) { int number_failed; - Suite *s = entity_suite (); - SRunner *sr = srunner_create (s); + Suite *s = entity_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -342,9 +342,9 @@ int main(void) /* Upfront so we don't confuse valgrind */ osinfo_dummy_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-filter.c b/test/test-filter.c index 1a51370..aa4fb72 100644 --- a/test/test-filter.c +++ b/test/test-filter.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -169,8 +169,8 @@ filter_suite(void) int main(void) { int number_failed; - Suite *s = filter_suite (); - SRunner *sr = srunner_create (s); + Suite *s = filter_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -180,9 +180,9 @@ int main(void) osinfo_device_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-install-script.c b/test/test-install-script.c index 1068da9..4da3bb4 100644 --- a/test/test-install-script.c +++ b/test/test-install-script.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -107,8 +107,8 @@ START_TEST(test_script_file) "jeos", "file://" SRCDIR "/test/install-script.xsl"); - loop = g_main_loop_new (g_main_context_get_thread_default (), - TRUE); + loop = g_main_loop_new(g_main_context_get_thread_default(), + TRUE); os = osinfo_os_new("http://fedoraproject.org/fedora/16"); osinfo_install_script_generate_async(script, @@ -156,8 +156,8 @@ START_TEST(test_script_data) "jeos", data); - loop = g_main_loop_new (g_main_context_get_thread_default (), - TRUE); + loop = g_main_loop_new(g_main_context_get_thread_default(), + TRUE); osinfo_install_script_generate_async(script, os, @@ -231,8 +231,8 @@ START_TEST(test_script_datamap) OSINFO_PRODUCT_PROP_SHORT_ID, "fedora16"); - loop = g_main_loop_new (g_main_context_get_thread_default (), - TRUE); + loop = g_main_loop_new(g_main_context_get_thread_default(), + TRUE); osinfo_install_script_generate_async(script, os, @@ -274,8 +274,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -293,9 +293,9 @@ int main(void) osinfo_oslist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-isodetect.c b/test/test-isodetect.c index 1b6450e..5bd211a 100644 --- a/test/test-isodetect.c +++ b/test/test-isodetect.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -433,8 +433,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -452,9 +452,9 @@ int main(void) osinfo_oslist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-list.c b/test/test-list.c index bd82183..d9076b8 100644 --- a/test/test-list.c +++ b/test/test-list.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,10 +41,10 @@ struct _OsinfoDummyClass GType osinfo_dummy_get_type(void); -G_DEFINE_TYPE (OsinfoDummy, osinfo_dummy, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoDummy, osinfo_dummy, OSINFO_TYPE_ENTITY); static void osinfo_dummy_class_init(OsinfoDummyClass *klass G_GNUC_UNUSED){} -static void osinfo_dummy_init (OsinfoDummy *self G_GNUC_UNUSED) {} +static void osinfo_dummy_init(OsinfoDummy *self G_GNUC_UNUSED) {} typedef struct _OsinfoDummyList OsinfoDummyList; @@ -62,10 +62,10 @@ struct _OsinfoDummyListClass GType osinfo_dummy_list_get_type(void); -G_DEFINE_TYPE (OsinfoDummyList, osinfo_dummy_list, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoDummyList, osinfo_dummy_list, OSINFO_TYPE_LIST); static void osinfo_dummy_list_class_init(OsinfoDummyListClass *klass G_GNUC_UNUSED){} -static void osinfo_dummy_list_init (OsinfoDummyList *self G_GNUC_UNUSED) {} +static void osinfo_dummy_list_init(OsinfoDummyList *self G_GNUC_UNUSED) {} @@ -134,7 +134,7 @@ START_TEST(test_union) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(list3) ; i++) { + for (i = 0; i < osinfo_list_get_length(list3); i++) { OsinfoEntity *ent = osinfo_list_get_nth(list3, i); if (ent == ent1) has1 = TRUE; @@ -192,7 +192,7 @@ START_TEST(test_intersect) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(list3) ; i++) { + for (i = 0; i < osinfo_list_get_length(list3); i++) { OsinfoEntity *ent = osinfo_list_get_nth(list3, i); if (ent == ent1) has1 = TRUE; @@ -256,7 +256,7 @@ START_TEST(test_filter) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(list2) ; i++) { + for (i = 0; i < osinfo_list_get_length(list2); i++) { OsinfoEntity *ent = osinfo_list_get_nth(list2, i); if (ent == ent1) has1 = TRUE; @@ -381,8 +381,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -393,9 +393,9 @@ int main(void) osinfo_dummy_list_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-loader.c b/test/test-loader.c index 3fe5c26..0f83b49 100644 --- a/test/test-loader.c +++ b/test/test-loader.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,8 +52,8 @@ loader_suite(void) int main(void) { int number_failed; - Suite *s = loader_suite (); - SRunner *sr = srunner_create (s); + Suite *s = loader_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -72,9 +72,9 @@ int main(void) osinfo_filter_get_type(); osinfo_loader_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-mediauris.c b/test/test-mediauris.c index a1b1df2..d66f4a3 100644 --- a/test/test-mediauris.c +++ b/test/test-mediauris.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,9 +77,9 @@ START_TEST(test_uris) SoupLogger *logger; int debug_level = atoi(debugstr); - logger = soup_logger_new (debug_level, -1); - soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger)); - g_object_unref (logger); + logger = soup_logger_new(debug_level, -1); + soup_session_add_feature(session, SOUP_SESSION_FEATURE(logger)); + g_object_unref(logger); } fail_unless(OSINFO_IS_LOADER(loader), "Loader is not a LOADER"); @@ -127,8 +127,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); if (!g_getenv("LIBOSINFO_NETWORK_TESTS")) return 77; /* Skip */ @@ -149,9 +149,9 @@ int main(void) osinfo_oslist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-os.c b/test/test-os.c index 6077435..48ad8ac 100644 --- a/test/test-os.c +++ b/test/test-os.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -210,8 +210,8 @@ os_suite(void) int main(void) { int number_failed; - Suite *s = os_suite (); - SRunner *sr = srunner_create (s); + Suite *s = os_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -225,9 +225,9 @@ int main(void) osinfo_devicelist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-oslist.c b/test/test-oslist.c index 2fa97c6..765d546 100644 --- a/test/test-oslist.c +++ b/test/test-oslist.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ START_TEST(test_union) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list3)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list3)); i++) { OsinfoOs *ent = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(list3), i)); if (ent == ent1) has1 = TRUE; @@ -112,7 +112,7 @@ START_TEST(test_intersect) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list3)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list3)); i++) { OsinfoOs *ent = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(list3), i)); if (ent == ent1) has1 = TRUE; @@ -176,7 +176,7 @@ START_TEST(test_filter) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list2)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list2)); i++) { OsinfoOs *ent = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(list2), i)); if (ent == ent1) has1 = TRUE; @@ -221,8 +221,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -233,9 +233,9 @@ int main(void) osinfo_oslist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-platform.c b/test/test-platform.c index 92772a7..6f05b83 100644 --- a/test/test-platform.c +++ b/test/test-platform.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,7 +57,7 @@ START_TEST(test_devices) gboolean hasDev2 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(devices)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(devices)); i++) { OsinfoEntity *ent = osinfo_list_get_nth(OSINFO_LIST(devices), i); fail_unless(OSINFO_IS_DEVICE(ent), "entity is a device"); if (OSINFO_DEVICE(ent) == dev1) @@ -128,8 +128,8 @@ platform_suite(void) int main(void) { int number_failed; - Suite *s = platform_suite (); - SRunner *sr = srunner_create (s); + Suite *s = platform_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -141,9 +141,9 @@ int main(void) osinfo_devicelist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-platformlist.c b/test/test-platformlist.c index 4baf4ff..e1b1d13 100644 --- a/test/test-platformlist.c +++ b/test/test-platformlist.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ START_TEST(test_union) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list3)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list3)); i++) { OsinfoPlatform *ent = OSINFO_PLATFORM(osinfo_list_get_nth(OSINFO_LIST(list3), i)); if (ent == ent1) has1 = TRUE; @@ -112,7 +112,7 @@ START_TEST(test_intersect) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list3)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list3)); i++) { OsinfoPlatform *ent = OSINFO_PLATFORM(osinfo_list_get_nth(OSINFO_LIST(list3), i)); if (ent == ent1) has1 = TRUE; @@ -176,7 +176,7 @@ START_TEST(test_filter) gboolean has4 = FALSE; gboolean hasBad = FALSE; int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list2)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list2)); i++) { OsinfoPlatform *ent = OSINFO_PLATFORM(osinfo_list_get_nth(OSINFO_LIST(list2), i)); if (ent == ent1) has1 = TRUE; @@ -221,8 +221,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -233,9 +233,9 @@ int main(void) osinfo_platformlist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-product.c b/test/test-product.c index f8f654c..f6b30fa 100644 --- a/test/test-product.c +++ b/test/test-product.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,10 +41,10 @@ struct _OsinfoDummyClass GType osinfo_dummy_get_type(void); -G_DEFINE_TYPE (OsinfoDummy, osinfo_dummy, OSINFO_TYPE_PRODUCT); +G_DEFINE_TYPE(OsinfoDummy, osinfo_dummy, OSINFO_TYPE_PRODUCT); static void osinfo_dummy_class_init(OsinfoDummyClass *klass G_GNUC_UNUSED){} -static void osinfo_dummy_init (OsinfoDummy *self G_GNUC_UNUSED) {} +static void osinfo_dummy_init(OsinfoDummy *self G_GNUC_UNUSED) {} static OsinfoProduct *osinfo_dummy_new(const gchar *id) { return g_object_new(osinfo_dummy_get_type(), "id", id, NULL); @@ -202,8 +202,8 @@ product_suite(void) int main(void) { int number_failed; - Suite *s = product_suite (); - SRunner *sr = srunner_create (s); + Suite *s = product_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -217,9 +217,9 @@ int main(void) osinfo_devicelist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-productfilter.c b/test/test-productfilter.c index f05ce67..57d6fc4 100644 --- a/test/test-productfilter.c +++ b/test/test-productfilter.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,10 +41,10 @@ struct _OsinfoDummyClass GType osinfo_dummy_get_type(void); -G_DEFINE_TYPE (OsinfoDummy, osinfo_dummy, OSINFO_TYPE_PRODUCT); +G_DEFINE_TYPE(OsinfoDummy, osinfo_dummy, OSINFO_TYPE_PRODUCT); static void osinfo_dummy_class_init(OsinfoDummyClass *klass G_GNUC_UNUSED){} -static void osinfo_dummy_init (OsinfoDummy *self G_GNUC_UNUSED) {} +static void osinfo_dummy_init(OsinfoDummy *self G_GNUC_UNUSED) {} static OsinfoProduct *osinfo_dummy_new(const gchar *id) { return g_object_new(osinfo_dummy_get_type(), "id", id, NULL); @@ -240,8 +240,8 @@ productfilter_suite(void) int main(void) { int number_failed; - Suite *s = productfilter_suite (); - SRunner *sr = srunner_create (s); + Suite *s = productfilter_suite(); + SRunner *sr = srunner_create(s); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -255,9 +255,9 @@ int main(void) osinfo_productfilter_get_type(); osinfo_product_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/test/test-treeuris.c b/test/test-treeuris.c index ff0de9e..da0dee4 100644 --- a/test/test-treeuris.c +++ b/test/test-treeuris.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,9 +77,9 @@ START_TEST(test_uris) SoupLogger *logger; int debug_level = atoi(debugstr); - logger = soup_logger_new (debug_level, -1); - soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger)); - g_object_unref (logger); + logger = soup_logger_new(debug_level, -1); + soup_session_add_feature(session, SOUP_SESSION_FEATURE(logger)); + g_object_unref(logger); } fail_unless(OSINFO_IS_LOADER(loader), "Loader is not a LOADER"); @@ -127,8 +127,8 @@ list_suite(void) int main(void) { int number_failed; - Suite *s = list_suite (); - SRunner *sr = srunner_create (s); + Suite *s = list_suite(); + SRunner *sr = srunner_create(s); if (!g_getenv("LIBOSINFO_NETWORK_TESTS")) return 77; /* Skip */ @@ -149,9 +149,9 @@ int main(void) osinfo_oslist_get_type(); osinfo_filter_get_type(); - srunner_run_all (sr, CK_ENV); - number_failed = srunner_ntests_failed (sr); - srunner_free (sr); + srunner_run_all(sr, CK_ENV); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.9.3 From gscrivan at redhat.com Wed Jun 4 09:50:55 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 4 Jun 2014 11:50:55 +0200 Subject: [Libosinfo] [PATCH 3/5] tools: fix spacing to satisfy sc_bracket_spacing_check In-Reply-To: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401875457-21439-4-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- tools/osinfo-db-validate.c | 8 ++++---- tools/osinfo-detect.c | 14 +++++++------- tools/osinfo-install-script.c | 8 ++++---- tools/osinfo-query.c | 24 ++++++++++++------------ 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tools/osinfo-db-validate.c b/tools/osinfo-db-validate.c index 20a77c2..f53aebe 100644 --- a/tools/osinfo-db-validate.c +++ b/tools/osinfo-db-validate.c @@ -227,7 +227,7 @@ static gboolean validate_files(gint argc, gchar **argv, GError **error) goto cleanup; } - for (i = 0 ; i < argc ; i++) { + for (i = 0; i < argc; i++) { GFile *file = g_file_new_for_commandline_arg(argv[i]); if (!validate_file(rngValid, file, NULL, error)) { g_object_unref(file); @@ -252,9 +252,9 @@ gint main(gint argc, gchar **argv) gint ret = EXIT_FAILURE; setlocale(LC_ALL, ""); - textdomain (GETTEXT_PACKAGE); + textdomain(GETTEXT_PACKAGE); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -333,7 +333,7 @@ Daniel P. Berrange =head1 COPYRIGHT -Copyright (C) 2012 Red Hat, Inc. +Copyright (C) 2012, 2014 Red Hat, Inc. =head1 LICENSE diff --git a/tools/osinfo-detect.c b/tools/osinfo-detect.c index cf737f2..fae7b21 100644 --- a/tools/osinfo-detect.c +++ b/tools/osinfo-detect.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011, 2014 Red Hat, Inc. * * osinfo-detect: Given a path to a ISO9660 image/device, detects if media is * bootable and the relevant OS if media is an installer for it. @@ -129,9 +129,9 @@ static void print_media(OsinfoMedia *media) if (format == OUTPUT_FORMAT_ENV) { const gchar *id = osinfo_entity_get_id(OSINFO_ENTITY(os)); - if (osinfo_media_get_installer (media)) + if (osinfo_media_get_installer(media)) g_print("OSINFO_INSTALLER=%s\n", id); - if (osinfo_media_get_live (media)) + if (osinfo_media_get_live(media)) g_print("OSINFO_LIVE=%s\n", id); g_print("OSINFO_MEDIA=%s\n", osinfo_entity_get_id(OSINFO_ENTITY(media))); @@ -151,9 +151,9 @@ static void print_media(OsinfoMedia *media) name = osinfo_product_get_name(OSINFO_PRODUCT(os)); } - if (osinfo_media_get_installer (media)) + if (osinfo_media_get_installer(media)) g_print(_("Media is an installer for OS '%s'\n"), name); - if (osinfo_media_get_live (media)) + if (osinfo_media_get_live(media)) g_print(_("Media is live media for OS '%s'\n"), name); if (num_variants > 1) { @@ -217,9 +217,9 @@ gint main(gint argc, gchar **argv) gint ret = 0; setlocale(LC_ALL, ""); - textdomain (GETTEXT_PACKAGE); + textdomain(GETTEXT_PACKAGE); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); context = g_option_context_new(_("- Detect if media is bootable " \ "and the relevant OS and distribution.")); diff --git a/tools/osinfo-install-script.c b/tools/osinfo-install-script.c index 4191629..9f9894a 100644 --- a/tools/osinfo-install-script.c +++ b/tools/osinfo-install-script.c @@ -148,7 +148,7 @@ static gboolean list_script_config(OsinfoOs *os) GList *params = osinfo_install_script_get_config_param_list(script); GList *tmp2; - for (tmp2 = params ; tmp2 != NULL ; tmp2 = tmp2->next) { + for (tmp2 = params; tmp2 != NULL; tmp2 = tmp2->next) { OsinfoInstallConfigParam *param = OSINFO_INSTALL_CONFIG_PARAM(tmp2->data); g_print("%s: %s\n", @@ -265,7 +265,7 @@ static gboolean generate_script(OsinfoOs *os) goto cleanup; } if (!quiet) - g_print ("%s\n", osinfo_install_script_get_output_filename(script)); + g_print("%s\n", osinfo_install_script_get_output_filename(script)); } ret = TRUE; @@ -290,9 +290,9 @@ gint main(gint argc, gchar **argv) gint ret = 0; setlocale(LC_ALL, ""); - textdomain (GETTEXT_PACKAGE); + textdomain(GETTEXT_PACKAGE); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); diff --git a/tools/osinfo-query.c b/tools/osinfo-query.c index 8ceba3f..43ded4f 100644 --- a/tools/osinfo-query.c +++ b/tools/osinfo-query.c @@ -136,13 +136,13 @@ static gboolean toggle_fields(struct OsinfoLabel *labels, fields = g_strsplit(fieldStr, ",", 0); - for (j = 0 ; labels[j].prop ; j++) { + for (j = 0; labels[j].prop; j++) { labels[j].enabled = FALSE; } - for (i = 0 ; fields[i] != NULL ; i++) { + for (i = 0; fields[i] != NULL; i++) { gboolean found = FALSE; - for (j = 0 ; labels[j].prop ; j++) { + for (j = 0; labels[j].prop; j++) { if (g_str_equal(fields[i], labels[j].prop)) { labels[j].enabled = TRUE; found = TRUE; @@ -171,7 +171,7 @@ static gboolean build_filter(struct OsinfoLabel *labels, gboolean ret = FALSE; gsize i, j; - for (i = 0 ; i < argc ; i++) { + for (i = 0; i < argc; i++) { const gchar *tmp = strchr(argv[i], '='); if (!tmp) { g_set_error(error, 0, 0, "%s", _("Syntax error in condition, expecting KEY=VALUE")); @@ -181,7 +181,7 @@ static gboolean build_filter(struct OsinfoLabel *labels, gchar *val = g_strdup(tmp+1); gboolean found = FALSE; - for (j = 0 ; labels[j].prop != NULL ; j++) { + for (j = 0; labels[j].prop != NULL; j++) { if (g_str_equal(key, labels[j].prop)) found = TRUE; } @@ -234,7 +234,7 @@ static gboolean print_entity_text(OsinfoEntity *entity, { gsize i; gboolean first = TRUE; - for (i = 0 ; labels[i].prop != NULL ; i++) { + for (i = 0; labels[i].prop != NULL; i++) { gsize pad; gchar *padstr; const gchar *val = osinfo_entity_get_param_value(entity, labels[i].prop); @@ -281,7 +281,7 @@ static gboolean print_results_text(OsinfoList *list, (gchar*)(sortKey ? sortKey : labels[0].prop)); - for (i = 0 ; labels[i].prop != NULL ; i++) { + for (i = 0; labels[i].prop != NULL; i++) { gsize pad; gchar *padstr; if (!labels[i].enabled) @@ -311,7 +311,7 @@ static gboolean print_results_text(OsinfoList *list, g_print("\n"); first = TRUE; - for (i = 0 ; labels[i].prop != NULL ; i++) { + for (i = 0; labels[i].prop != NULL; i++) { gchar *padstr; if (!labels[i].enabled) continue; @@ -362,9 +362,9 @@ gint main(gint argc, gchar **argv) const gchar *fields = NULL; setlocale(LC_ALL, ""); - textdomain (GETTEXT_PACKAGE); + textdomain(GETTEXT_PACKAGE); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); #if !GLIB_CHECK_VERSION(2,35,1) g_type_init(); @@ -434,7 +434,7 @@ gint main(gint argc, gchar **argv) db = osinfo_loader_get_db(loader); - for (i = 0 ; i < (sizeof(types)/sizeof(types[0])) ; i++) { + for (i = 0; i < (sizeof(types)/sizeof(types[0])); i++) { if (g_str_equal(types[i].name, type)) { entities = types[i].listFunc(db); filter = g_object_new(types[i].filterType, NULL); @@ -702,7 +702,7 @@ Daniel P. Berrange =head1 COPYRIGHT -Copyright (C) 2012 Red Hat, Inc. +Copyright (C) 2012, 2014 Red Hat, Inc. =head1 LICENSE -- 1.9.3 From gscrivan at redhat.com Wed Jun 4 09:50:56 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 4 Jun 2014 11:50:56 +0200 Subject: [Libosinfo] [PATCH 4/5] osinfo: fix spacing to satisfy sc_bracket_spacing_check In-Reply-To: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401875457-21439-5-git-send-email-gscrivan@redhat.com> Signed-off-by: Giuseppe Scrivano --- osinfo/osinfo_avatar_format.c | 16 +- osinfo/osinfo_datamap.c | 18 +- osinfo/osinfo_datamaplist.c | 18 +- osinfo/osinfo_db.c | 48 ++-- osinfo/osinfo_deployment.c | 28 +-- osinfo/osinfo_deploymentlist.c | 18 +- osinfo/osinfo_device.c | 20 +- osinfo/osinfo_device_driver.c | 28 +-- osinfo/osinfo_device_driverlist.c | 18 +- osinfo/osinfo_devicelink.c | 24 +- osinfo/osinfo_devicelinkfilter.c | 26 +-- osinfo/osinfo_devicelinklist.c | 20 +- osinfo/osinfo_devicelist.c | 18 +- osinfo/osinfo_entity.c | 44 ++-- osinfo/osinfo_filter.c | 22 +- osinfo/osinfo_install_config.c | 14 +- osinfo/osinfo_install_config_param.c | 24 +- osinfo/osinfo_install_config_paramlist.c | 18 +- osinfo/osinfo_install_script.c | 28 +-- osinfo/osinfo_install_scriptlist.c | 18 +- osinfo/osinfo_list.c | 24 +- osinfo/osinfo_loader.c | 108 ++++----- osinfo/osinfo_media.c | 382 +++++++++++++++---------------- osinfo/osinfo_medialist.c | 18 +- osinfo/osinfo_os.c | 84 +++---- osinfo/osinfo_os_variant.c | 48 ++-- osinfo/osinfo_os_variantlist.c | 12 +- osinfo/osinfo_oslist.c | 18 +- osinfo/osinfo_platform.c | 20 +- osinfo/osinfo_platformlist.c | 18 +- osinfo/osinfo_product.c | 138 +++++------ osinfo/osinfo_productfilter.c | 24 +- osinfo/osinfo_productlist.c | 18 +- osinfo/osinfo_resources.c | 178 +++++++------- osinfo/osinfo_resourceslist.c | 18 +- osinfo/osinfo_tree.c | 12 +- osinfo/osinfo_treelist.c | 22 +- 37 files changed, 805 insertions(+), 805 deletions(-) diff --git a/osinfo/osinfo_avatar_format.c b/osinfo/osinfo_avatar_format.c index 7928c41..4e0b9d9 100644 --- a/osinfo/osinfo_avatar_format.c +++ b/osinfo/osinfo_avatar_format.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * Copyright (C) 2012 Fabiano Fid?ncio * * This library is free software; you can redistribute it and/or @@ -28,10 +28,10 @@ #include #include -G_DEFINE_TYPE (OsinfoAvatarFormat, osinfo_avatar_format, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoAvatarFormat, osinfo_avatar_format, OSINFO_TYPE_ENTITY); #define OSINFO_AVATAR_FORMAT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ OSINFO_TYPE_AVATAR_FORMAT, \ OsinfoAvatarFormatPrivate)) @@ -56,7 +56,7 @@ osinfo_avatar_format_get_property(GObject *object, GValue *value, GParamSpec *pspec) { - OsinfoAvatarFormat *avatar = OSINFO_AVATAR_FORMAT (object); + OsinfoAvatarFormat *avatar = OSINFO_AVATAR_FORMAT(object); switch (property_id) { @@ -82,16 +82,16 @@ osinfo_avatar_format_get_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } /* Init functions */ static void -osinfo_avatar_format_class_init (OsinfoAvatarFormatClass *klass) +osinfo_avatar_format_class_init(OsinfoAvatarFormatClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->get_property = osinfo_avatar_format_get_property; @@ -164,7 +164,7 @@ osinfo_avatar_format_class_init (OsinfoAvatarFormatClass *klass) } static void -osinfo_avatar_format_init (OsinfoAvatarFormat *avatar) +osinfo_avatar_format_init(OsinfoAvatarFormat *avatar) { } diff --git a/osinfo/osinfo_datamap.c b/osinfo/osinfo_datamap.c index efd5d1d..beea6e8 100644 --- a/osinfo/osinfo_datamap.c +++ b/osinfo/osinfo_datamap.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,9 +30,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDatamap, osinfo_datamap, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoDatamap, osinfo_datamap, OSINFO_TYPE_ENTITY); -#define OSINFO_DATAMAP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DATAMAP, OsinfoDatamapPrivate)) +#define OSINFO_DATAMAP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DATAMAP, OsinfoDatamapPrivate)) /** * SECTION:osinfo_datamap @@ -51,7 +51,7 @@ struct _OsinfoDatamapPrivate }; static void -osinfo_datamap_finalize (GObject *object) +osinfo_datamap_finalize(GObject *object) { OsinfoDatamap *map = OSINFO_DATAMAP(object); @@ -59,22 +59,22 @@ osinfo_datamap_finalize (GObject *object) g_hash_table_unref(map->priv->reverse_map); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_datamap_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_datamap_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_datamap_class_init (OsinfoDatamapClass *klass) +osinfo_datamap_class_init(OsinfoDatamapClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_datamap_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDatamapPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDatamapPrivate)); } static void -osinfo_datamap_init (OsinfoDatamap *list) +osinfo_datamap_init(OsinfoDatamap *list) { list->priv = OSINFO_DATAMAP_GET_PRIVATE(list); list->priv->map = g_hash_table_new_full(g_str_hash, diff --git a/osinfo/osinfo_datamaplist.c b/osinfo/osinfo_datamaplist.c index 01b58f1..6d56d9c 100644 --- a/osinfo/osinfo_datamaplist.c +++ b/osinfo/osinfo_datamaplist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,9 +26,9 @@ #include -G_DEFINE_TYPE (OsinfoDatamapList, osinfo_datamaplist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoDatamapList, osinfo_datamaplist, OSINFO_TYPE_LIST); -#define OSINFO_DATAMAPLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DATAMAPLIST, OsinfoDatamapListPrivate)) +#define OSINFO_DATAMAPLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DATAMAPLIST, OsinfoDatamapListPrivate)) /** * SECTION:osinfo_datamaplist @@ -45,24 +45,24 @@ struct _OsinfoDatamapListPrivate }; static void -osinfo_datamaplist_finalize (GObject *object) +osinfo_datamaplist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_datamaplist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_datamaplist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_datamaplist_class_init (OsinfoDatamapListClass *klass) +osinfo_datamaplist_class_init(OsinfoDatamapListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_datamaplist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDatamapListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDatamapListPrivate)); } static void -osinfo_datamaplist_init (OsinfoDatamapList *list) +osinfo_datamaplist_init(OsinfoDatamapList *list) { list->priv = OSINFO_DATAMAPLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c index db04033..241ee47 100644 --- a/osinfo/osinfo_db.c +++ b/osinfo/osinfo_db.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,9 +30,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDb, osinfo_db, G_TYPE_OBJECT); +G_DEFINE_TYPE(OsinfoDb, osinfo_db, G_TYPE_OBJECT); -#define OSINFO_DB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DB, OsinfoDbPrivate)) +#define OSINFO_DB_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DB, OsinfoDbPrivate)) #define match_regex(pattern, str) \ (((pattern) == NULL) || \ @@ -138,12 +138,12 @@ struct _OsinfoDbPrivate OsinfoInstallScriptList *scripts; }; -static void osinfo_db_finalize (GObject *object); +static void osinfo_db_finalize(GObject *object); static void -osinfo_db_finalize (GObject *object) +osinfo_db_finalize(GObject *object) { - OsinfoDb *db = OSINFO_DB (object); + OsinfoDb *db = OSINFO_DB(object); g_object_unref(db->priv->devices); g_object_unref(db->priv->platforms); @@ -153,24 +153,24 @@ osinfo_db_finalize (GObject *object) g_object_unref(db->priv->scripts); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_db_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_db_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_db_class_init (OsinfoDbClass *klass) +osinfo_db_class_init(OsinfoDbClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_db_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDbPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDbPrivate)); } static void -osinfo_db_init (OsinfoDb *db) +osinfo_db_init(OsinfoDb *db) { db->priv = OSINFO_DB_GET_PRIVATE(db); db->priv->devices = osinfo_devicelist_new(); @@ -518,7 +518,7 @@ void osinfo_db_add_install_script(OsinfoDb *db, OsinfoInstallScript *script) } -static gint media_volume_compare (gconstpointer a, gconstpointer b) +static gint media_volume_compare(gconstpointer a, gconstpointer b) { OsinfoMedia *media_a = OSINFO_MEDIA(a); OsinfoMedia *media_b = OSINFO_MEDIA(b); @@ -573,10 +573,10 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db, const gchar *os_publisher = osinfo_media_get_publisher_id(os_media); const gchar *os_application = osinfo_media_get_application_id(os_media); - if (match_regex (os_volume, media_volume) && - match_regex (os_application, media_application) && - match_regex (os_system, media_system) && - match_regex (os_publisher, media_publisher)) { + if (match_regex(os_volume, media_volume) && + match_regex(os_application, media_application) && + match_regex(os_system, media_system) && + match_regex(os_publisher, media_publisher)) { ret = os; if (matched_media != NULL) *matched_media = os_media; @@ -614,7 +614,7 @@ OsinfoOs *osinfo_db_guess_os_from_media(OsinfoDb *db, return osinfo_db_guess_os_from_media_internal(db, media, matched_media); } -static void fill_media (OsinfoDb *db, OsinfoMedia *media, +static void fill_media(OsinfoDb *db, OsinfoMedia *media, OsinfoMedia *matched_media, OsinfoOs *os) { @@ -751,10 +751,10 @@ OsinfoOs *osinfo_db_guess_os_from_tree(OsinfoDb *db, const gchar *os_version = osinfo_tree_get_treeinfo_version(os_tree); const gchar *os_arch = osinfo_tree_get_treeinfo_arch(os_tree); - if (match_regex (os_family, tree_family) && - match_regex (os_variant, tree_variant) && - match_regex (os_version, tree_version) && - match_regex (os_arch, tree_arch)) { + if (match_regex(os_family, tree_family) && + match_regex(os_variant, tree_variant) && + match_regex(os_version, tree_version) && + match_regex(os_arch, tree_arch)) { ret = os; if (matched_tree != NULL) *matched_tree = os_tree; @@ -908,7 +908,7 @@ static void __osinfoAddProductIfRelationship(gpointer data, gpointer opaque) OsinfoProductList *thisList = osinfo_product_get_related(product, args->relshp); int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(thisList)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(thisList)); i++) { OsinfoEntity *entity = osinfo_list_get_nth(OSINFO_LIST(thisList), i); osinfo_list_add(newList, entity); } @@ -931,7 +931,7 @@ OsinfoOsList *osinfo_db_unique_values_for_os_relationship(OsinfoDb *db, OsinfoPr g_return_val_if_fail(OSINFO_IS_DB(db), NULL); OsinfoOsList *newList = osinfo_oslist_new(); - struct __osinfoProductCheckRelationshipArgs args = {OSINFO_LIST (newList), relshp}; + struct __osinfoProductCheckRelationshipArgs args = {OSINFO_LIST(newList), relshp}; GList *entities = osinfo_list_get_elements(OSINFO_LIST(db->priv->oses)); g_list_foreach(entities, __osinfoAddProductIfRelationship, &args); @@ -956,7 +956,7 @@ OsinfoPlatformList *osinfo_db_unique_values_for_platform_relationship(OsinfoDb * g_return_val_if_fail(OSINFO_IS_DB(db), NULL); OsinfoPlatformList *newList = osinfo_platformlist_new(); - struct __osinfoProductCheckRelationshipArgs args = {OSINFO_LIST (newList), relshp}; + struct __osinfoProductCheckRelationshipArgs args = {OSINFO_LIST(newList), relshp}; GList *entities = osinfo_list_get_elements(OSINFO_LIST(db->priv->platforms)); g_list_foreach(entities, __osinfoAddProductIfRelationship, &args); diff --git a/osinfo/osinfo_deployment.c b/osinfo/osinfo_deployment.c index a00497d..7191ac3 100644 --- a/osinfo/osinfo_deployment.c +++ b/osinfo/osinfo_deployment.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDeployment, osinfo_deployment, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoDeployment, osinfo_deployment, OSINFO_TYPE_ENTITY); -#define OSINFO_DEPLOYMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEPLOYMENT, OsinfoDeploymentPrivate)) +#define OSINFO_DEPLOYMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEPLOYMENT, OsinfoDeploymentPrivate)) /** * SECTION:osinfo_deployment @@ -64,7 +64,7 @@ osinfo_deployment_set_property(GObject *object, const GValue *value, GParamSpec *pspec) { - OsinfoDeployment *deployment = OSINFO_DEPLOYMENT (object); + OsinfoDeployment *deployment = OSINFO_DEPLOYMENT(object); switch (property_id) { @@ -84,7 +84,7 @@ osinfo_deployment_set_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -95,7 +95,7 @@ osinfo_deployment_get_property(GObject *object, GValue *value, GParamSpec *pspec) { - OsinfoDeployment *deployment = OSINFO_DEPLOYMENT (object); + OsinfoDeployment *deployment = OSINFO_DEPLOYMENT(object); switch (property_id) { @@ -107,7 +107,7 @@ osinfo_deployment_get_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -120,9 +120,9 @@ static void osinfo_device_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED } static void -osinfo_deployment_finalize (GObject *object) +osinfo_deployment_finalize(GObject *object) { - OsinfoDeployment *deployment = OSINFO_DEPLOYMENT (object); + OsinfoDeployment *deployment = OSINFO_DEPLOYMENT(object); g_list_foreach(deployment->priv->deviceLinks, osinfo_device_link_free, NULL); g_list_free(deployment->priv->deviceLinks); @@ -131,14 +131,14 @@ osinfo_deployment_finalize (GObject *object) g_object_unref(deployment->priv->platform); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_deployment_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_deployment_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_deployment_class_init (OsinfoDeploymentClass *klass) +osinfo_deployment_class_init(OsinfoDeploymentClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->set_property = osinfo_deployment_set_property; @@ -176,11 +176,11 @@ osinfo_deployment_class_init (OsinfoDeploymentClass *klass) pspec); g_klass->finalize = osinfo_deployment_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDeploymentPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeploymentPrivate)); } static void -osinfo_deployment_init (OsinfoDeployment *deployment) +osinfo_deployment_init(OsinfoDeployment *deployment) { deployment->priv = OSINFO_DEPLOYMENT_GET_PRIVATE(deployment); deployment->priv->deviceLinks = NULL; diff --git a/osinfo/osinfo_deploymentlist.c b/osinfo/osinfo_deploymentlist.c index acf5e6e..b50febd 100644 --- a/osinfo/osinfo_deploymentlist.c +++ b/osinfo/osinfo_deploymentlist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDeploymentList, osinfo_deploymentlist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoDeploymentList, osinfo_deploymentlist, OSINFO_TYPE_LIST); -#define OSINFO_DEPLOYMENTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEPLOYMENTLIST, OsinfoDeploymentListPrivate)) +#define OSINFO_DEPLOYMENTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEPLOYMENTLIST, OsinfoDeploymentListPrivate)) /** * SECTION:osinfo_deploymentlist @@ -46,24 +46,24 @@ struct _OsinfoDeploymentListPrivate }; static void -osinfo_deploymentlist_finalize (GObject *object) +osinfo_deploymentlist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_deploymentlist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_deploymentlist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_deploymentlist_class_init (OsinfoDeploymentListClass *klass) +osinfo_deploymentlist_class_init(OsinfoDeploymentListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_deploymentlist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDeploymentListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeploymentListPrivate)); } static void -osinfo_deploymentlist_init (OsinfoDeploymentList *list) +osinfo_deploymentlist_init(OsinfoDeploymentList *list) { list->priv = OSINFO_DEPLOYMENTLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_device.c b/osinfo/osinfo_device.c index 8308817..6389878 100644 --- a/osinfo/osinfo_device.c +++ b/osinfo/osinfo_device.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,9 +28,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDevice, osinfo_device, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoDevice, osinfo_device, OSINFO_TYPE_ENTITY); -#define OSINFO_DEVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEVICE, OsinfoDevicePrivate)) +#define OSINFO_DEVICE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEVICE, OsinfoDevicePrivate)) /** * SECTION:osinfo_device @@ -48,27 +48,27 @@ struct _OsinfoDevicePrivate }; -static void osinfo_device_finalize (GObject *object); +static void osinfo_device_finalize(GObject *object); static void -osinfo_device_finalize (GObject *object) +osinfo_device_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_device_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_device_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_device_class_init (OsinfoDeviceClass *klass) +osinfo_device_class_init(OsinfoDeviceClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_device_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDevicePrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDevicePrivate)); } static void -osinfo_device_init (OsinfoDevice *device) +osinfo_device_init(OsinfoDevice *device) { device->priv = OSINFO_DEVICE_GET_PRIVATE(device); } diff --git a/osinfo/osinfo_device_driver.c b/osinfo/osinfo_device_driver.c index 6aa8de3..e9c81ab 100644 --- a/osinfo/osinfo_device_driver.c +++ b/osinfo/osinfo_device_driver.c @@ -1,7 +1,7 @@ /* * libosinfo: Device driver * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,12 +31,12 @@ #include "osinfo_device_driver_private.h" -G_DEFINE_TYPE (OsinfoDeviceDriver, osinfo_device_driver, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoDeviceDriver, osinfo_device_driver, OSINFO_TYPE_ENTITY); #define OSINFO_DEVICE_DRIVER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ - OSINFO_TYPE_DEVICE_DRIVER, \ - OsinfoDeviceDriverPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + OSINFO_TYPE_DEVICE_DRIVER, \ + OsinfoDeviceDriverPrivate)) /** * SECTION:osinfo_device_driver @@ -53,38 +53,38 @@ struct _OsinfoDeviceDriverPrivate }; static void -osinfo_device_driver_finalize (GObject *object) +osinfo_device_driver_finalize(GObject *object) { - OsinfoDeviceDriver *driver = OSINFO_DEVICE_DRIVER (object); + OsinfoDeviceDriver *driver = OSINFO_DEVICE_DRIVER(object); g_object_unref(driver->priv->devices); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_device_driver_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_device_driver_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_device_driver_class_init (OsinfoDeviceDriverClass *klass) +osinfo_device_driver_class_init(OsinfoDeviceDriverClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_device_driver_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDeviceDriverPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeviceDriverPrivate)); } static void -osinfo_device_driver_init (OsinfoDeviceDriver *driver) +osinfo_device_driver_init(OsinfoDeviceDriver *driver) { driver->priv = OSINFO_DEVICE_DRIVER_GET_PRIVATE(driver); - driver->priv->devices = osinfo_devicelist_new (); + driver->priv->devices = osinfo_devicelist_new(); } OsinfoDeviceDriver *osinfo_device_driver_new(const gchar *id) { OsinfoDeviceDriver *driver; - driver = g_object_new (OSINFO_TYPE_DEVICE_DRIVER, + driver = g_object_new(OSINFO_TYPE_DEVICE_DRIVER, "id", id, NULL); diff --git a/osinfo/osinfo_device_driverlist.c b/osinfo/osinfo_device_driverlist.c index f802e38..73c0021 100644 --- a/osinfo/osinfo_device_driverlist.c +++ b/osinfo/osinfo_device_driverlist.c @@ -1,7 +1,7 @@ /* * libosinfo: Device driver list * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,9 +28,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDeviceDriverList, osinfo_device_driverlist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoDeviceDriverList, osinfo_device_driverlist, OSINFO_TYPE_LIST); -#define OSINFO_DEVICE_DRIVERLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEVICE_DRIVERLIST, OsinfoDeviceDriverListPrivate)) +#define OSINFO_DEVICE_DRIVERLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEVICE_DRIVERLIST, OsinfoDeviceDriverListPrivate)) /** * SECTION:osinfo_device_driverlist @@ -47,24 +47,24 @@ struct _OsinfoDeviceDriverListPrivate }; static void -osinfo_device_driverlist_finalize (GObject *object) +osinfo_device_driverlist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_device_driverlist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_device_driverlist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_device_driverlist_class_init (OsinfoDeviceDriverListClass *klass) +osinfo_device_driverlist_class_init(OsinfoDeviceDriverListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_device_driverlist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDeviceDriverListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeviceDriverListPrivate)); } static void -osinfo_device_driverlist_init (OsinfoDeviceDriverList *list) +osinfo_device_driverlist_init(OsinfoDeviceDriverList *list) { list->priv = OSINFO_DEVICE_DRIVERLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_devicelink.c b/osinfo/osinfo_devicelink.c index fd72a1b..41ebd56 100644 --- a/osinfo/osinfo_devicelink.c +++ b/osinfo/osinfo_devicelink.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDeviceLink, osinfo_devicelink, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoDeviceLink, osinfo_devicelink, OSINFO_TYPE_ENTITY); -#define OSINFO_DEVICELINK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEVICELINK, OsinfoDeviceLinkPrivate)) +#define OSINFO_DEVICELINK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEVICELINK, OsinfoDeviceLinkPrivate)) /** * SECTION:osinfo_devicelink @@ -58,7 +58,7 @@ osinfo_devicelink_set_property(GObject *object, const GValue *value, GParamSpec *pspec) { - OsinfoDeviceLink *devlink = OSINFO_DEVICELINK (object); + OsinfoDeviceLink *devlink = OSINFO_DEVICELINK(object); switch (property_id) { @@ -71,7 +71,7 @@ osinfo_devicelink_set_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -82,7 +82,7 @@ osinfo_devicelink_get_property(GObject *object, GValue *value, GParamSpec *pspec) { - OsinfoDeviceLink *devlink = OSINFO_DEVICELINK (object); + OsinfoDeviceLink *devlink = OSINFO_DEVICELINK(object); switch (property_id) { @@ -91,7 +91,7 @@ osinfo_devicelink_get_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -106,14 +106,14 @@ osinfo_devicelink_finalize(GObject *object) g_object_unref(devlink->priv->target); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_devicelink_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_devicelink_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_devicelink_class_init (OsinfoDeviceLinkClass *klass) +osinfo_devicelink_class_init(OsinfoDeviceLinkClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->set_property = osinfo_devicelink_set_property; @@ -137,11 +137,11 @@ osinfo_devicelink_class_init (OsinfoDeviceLinkClass *klass) g_klass->finalize = osinfo_devicelink_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDeviceLinkPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeviceLinkPrivate)); } static void -osinfo_devicelink_init (OsinfoDeviceLink *devlink) +osinfo_devicelink_init(OsinfoDeviceLink *devlink) { devlink->priv = OSINFO_DEVICELINK_GET_PRIVATE(devlink); } diff --git a/osinfo/osinfo_devicelinkfilter.c b/osinfo/osinfo_devicelinkfilter.c index 2c84009..5ecb09b 100644 --- a/osinfo/osinfo_devicelinkfilter.c +++ b/osinfo/osinfo_devicelinkfilter.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDeviceLinkFilter, osinfo_devicelinkfilter, OSINFO_TYPE_FILTER); +G_DEFINE_TYPE(OsinfoDeviceLinkFilter, osinfo_devicelinkfilter, OSINFO_TYPE_FILTER); -#define OSINFO_DEVICELINKFILTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEVICELINKFILTER, OsinfoDeviceLinkFilterPrivate)) +#define OSINFO_DEVICELINKFILTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEVICELINKFILTER, OsinfoDeviceLinkFilterPrivate)) /** * SECTION:osinfo_devicelinkfilter @@ -62,7 +62,7 @@ osinfo_devicelinkfilter_set_property(GObject *object, const GValue *value, GParamSpec *pspec) { - OsinfoDeviceLinkFilter *filter = OSINFO_DEVICELINKFILTER (object); + OsinfoDeviceLinkFilter *filter = OSINFO_DEVICELINKFILTER(object); switch (property_id) { @@ -75,7 +75,7 @@ osinfo_devicelinkfilter_set_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -95,26 +95,26 @@ osinfo_devicelinkfilter_get_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } static void -osinfo_devicelinkfilter_finalize (GObject *object) +osinfo_devicelinkfilter_finalize(GObject *object) { - OsinfoDeviceLinkFilter *filter = OSINFO_DEVICELINKFILTER (object); + OsinfoDeviceLinkFilter *filter = OSINFO_DEVICELINKFILTER(object); g_object_unref(filter->priv->targetFilter); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_devicelinkfilter_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_devicelinkfilter_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_devicelinkfilter_class_init (OsinfoDeviceLinkFilterClass *klass) +osinfo_devicelinkfilter_class_init(OsinfoDeviceLinkFilterClass *klass) { GObjectClass *g_klass = G_OBJECT_CLASS(klass); OsinfoFilterClass *filter_klass = OSINFO_FILTER_CLASS(klass); @@ -140,7 +140,7 @@ osinfo_devicelinkfilter_class_init (OsinfoDeviceLinkFilterClass *klass) PROP_TARGET_FILTER, pspec); - g_type_class_add_private (klass, sizeof (OsinfoDeviceLinkFilterPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeviceLinkFilterPrivate)); filter_klass->matches = osinfo_devicelinkfilter_matches_default; } @@ -164,7 +164,7 @@ OsinfoDeviceLinkFilter *osinfo_devicelinkfilter_new(OsinfoFilter *filter) static void -osinfo_devicelinkfilter_init (OsinfoDeviceLinkFilter *devicelinkfilter) +osinfo_devicelinkfilter_init(OsinfoDeviceLinkFilter *devicelinkfilter) { devicelinkfilter->priv = OSINFO_DEVICELINKFILTER_GET_PRIVATE(devicelinkfilter); } @@ -191,7 +191,7 @@ static gboolean osinfo_devicelinkfilter_matches_default(OsinfoFilter *filter, Os g_return_val_if_fail(OSINFO_IS_DEVICELINK(entity), FALSE); OsinfoDeviceLinkFilter *linkfilter = OSINFO_DEVICELINKFILTER(filter); - if (!OSINFO_FILTER_CLASS (osinfo_devicelinkfilter_parent_class)->matches(filter, entity)) + if (!OSINFO_FILTER_CLASS(osinfo_devicelinkfilter_parent_class)->matches(filter, entity)) return FALSE; if (!osinfo_filter_matches(linkfilter->priv->targetFilter, diff --git a/osinfo/osinfo_devicelinklist.c b/osinfo/osinfo_devicelinklist.c index 14f1a7f..8e72119 100644 --- a/osinfo/osinfo_devicelinklist.c +++ b/osinfo/osinfo_devicelinklist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDeviceLinkList, osinfo_devicelinklist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoDeviceLinkList, osinfo_devicelinklist, OSINFO_TYPE_LIST); -#define OSINFO_DEVICELINKLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEVICELINKLIST, OsinfoDeviceLinkListPrivate)) +#define OSINFO_DEVICELINKLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEVICELINKLIST, OsinfoDeviceLinkListPrivate)) /** * SECTION:osinfo_devicelinklist @@ -46,24 +46,24 @@ struct _OsinfoDeviceLinkListPrivate }; static void -osinfo_devicelinklist_finalize (GObject *object) +osinfo_devicelinklist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_devicelinklist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_devicelinklist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_devicelinklist_class_init (OsinfoDeviceLinkListClass *klass) +osinfo_devicelinklist_class_init(OsinfoDeviceLinkListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_devicelinklist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDeviceLinkListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeviceLinkListPrivate)); } static void -osinfo_devicelinklist_init (OsinfoDeviceLinkList *list) +osinfo_devicelinklist_init(OsinfoDeviceLinkList *list) { list->priv = OSINFO_DEVICELINKLIST_GET_PRIVATE(list); } @@ -178,7 +178,7 @@ OsinfoDeviceList *osinfo_devicelinklist_get_devices(OsinfoDeviceLinkList *list, { OsinfoDeviceList *newList = osinfo_devicelist_new(); int i; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(list)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list)); i++) { OsinfoEntity *ent = osinfo_list_get_nth(OSINFO_LIST(list), i); if (!filter || osinfo_filter_matches(filter, ent)) osinfo_list_add(OSINFO_LIST(newList), ent); diff --git a/osinfo/osinfo_devicelist.c b/osinfo/osinfo_devicelist.c index f390ba5..fd293b5 100644 --- a/osinfo/osinfo_devicelist.c +++ b/osinfo/osinfo_devicelist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoDeviceList, osinfo_devicelist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoDeviceList, osinfo_devicelist, OSINFO_TYPE_LIST); -#define OSINFO_DEVICELIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_DEVICELIST, OsinfoDeviceListPrivate)) +#define OSINFO_DEVICELIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEVICELIST, OsinfoDeviceListPrivate)) /** * SECTION:osinfo_devicelist @@ -46,24 +46,24 @@ struct _OsinfoDeviceListPrivate }; static void -osinfo_devicelist_finalize (GObject *object) +osinfo_devicelist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_devicelist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_devicelist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_devicelist_class_init (OsinfoDeviceListClass *klass) +osinfo_devicelist_class_init(OsinfoDeviceListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_devicelist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoDeviceListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoDeviceListPrivate)); } static void -osinfo_devicelist_init (OsinfoDeviceList *list) +osinfo_devicelist_init(OsinfoDeviceList *list) { list->priv = OSINFO_DEVICELIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c index 5c062bc..871c307 100644 --- a/osinfo/osinfo_entity.c +++ b/osinfo/osinfo_entity.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_ABSTRACT_TYPE (OsinfoEntity, osinfo_entity, G_TYPE_OBJECT); +G_DEFINE_ABSTRACT_TYPE(OsinfoEntity, osinfo_entity, G_TYPE_OBJECT); -#define OSINFO_ENTITY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_ENTITY, OsinfoEntityPrivate)) +#define OSINFO_ENTITY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_ENTITY, OsinfoEntityPrivate)) /** * SECTION:osinfo_entity @@ -52,7 +52,7 @@ struct _OsinfoEntityPrivate GHashTable *params; }; -static void osinfo_entity_finalize (GObject *object); +static void osinfo_entity_finalize(GObject *object); enum { PROP_0, @@ -61,63 +61,63 @@ enum { }; static void -osinfo_entity_set_property (GObject *object, +osinfo_entity_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - OsinfoEntity *entity = OSINFO_ENTITY (object); + OsinfoEntity *entity = OSINFO_ENTITY(object); switch (property_id) { case PROP_ID: g_free(entity->priv->id); - entity->priv->id = g_value_dup_string (value); + entity->priv->id = g_value_dup_string(value); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } static void -osinfo_entity_get_property (GObject *object, +osinfo_entity_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - OsinfoEntity *entity = OSINFO_ENTITY (object); + OsinfoEntity *entity = OSINFO_ENTITY(object); switch (property_id) { case PROP_ID: - g_value_set_string (value, entity->priv->id); + g_value_set_string(value, entity->priv->id); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } static void -osinfo_entity_finalize (GObject *object) +osinfo_entity_finalize(GObject *object) { - OsinfoEntity *entity = OSINFO_ENTITY (object); + OsinfoEntity *entity = OSINFO_ENTITY(object); g_free(entity->priv->id); g_hash_table_destroy(entity->priv->params); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_entity_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_entity_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_entity_class_init (OsinfoEntityClass *klass) +osinfo_entity_class_init(OsinfoEntityClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->set_property = osinfo_entity_set_property; @@ -131,19 +131,19 @@ osinfo_entity_class_init (OsinfoEntityClass *klass) * This parameter must be set at time of construction as no * default value is provided. */ - pspec = g_param_spec_string ("id", + pspec = g_param_spec_string("id", "ID", _("Unique identifier"), NULL /* default value */, G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, + g_object_class_install_property(g_klass, PROP_ID, pspec); g_klass->finalize = osinfo_entity_finalize; - g_type_class_add_private (klass, sizeof (OsinfoEntityPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoEntityPrivate)); } static void osinfo_entity_param_value_free(gpointer value, gpointer opaque G_GNUC_UNUSED) @@ -159,7 +159,7 @@ static void osinfo_entity_param_values_free(gpointer values) static void -osinfo_entity_init (OsinfoEntity *entity) +osinfo_entity_init(OsinfoEntity *entity) { entity->priv = OSINFO_ENTITY_GET_PRIVATE(entity); entity->priv->params = g_hash_table_new_full(g_str_hash, @@ -212,7 +212,7 @@ void osinfo_entity_set_param_enum(OsinfoEntity *entity, const gchar *key, gint v GEnumClass *enum_class; GEnumValue *enum_value; - g_return_if_fail(G_TYPE_IS_ENUM (enum_type)); + g_return_if_fail(G_TYPE_IS_ENUM(enum_type)); enum_class = g_type_class_ref(enum_type); enum_value = g_enum_get_value(enum_class, value); diff --git a/osinfo/osinfo_filter.c b/osinfo/osinfo_filter.c index a3d5840..7f06d43 100644 --- a/osinfo/osinfo_filter.c +++ b/osinfo/osinfo_filter.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoFilter, osinfo_filter, G_TYPE_OBJECT); +G_DEFINE_TYPE(OsinfoFilter, osinfo_filter, G_TYPE_OBJECT); -#define OSINFO_FILTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_FILTER, OsinfoFilterPrivate)) +#define OSINFO_FILTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_FILTER, OsinfoFilterPrivate)) /** * SECTION:osinfo_filter @@ -48,28 +48,28 @@ struct _OsinfoFilterPrivate }; -static void osinfo_filter_finalize (GObject *object); +static void osinfo_filter_finalize(GObject *object); static gboolean osinfo_filter_matches_default(OsinfoFilter *filter, OsinfoEntity *entity); static void -osinfo_filter_finalize (GObject *object) +osinfo_filter_finalize(GObject *object) { - OsinfoFilter *filter = OSINFO_FILTER (object); + OsinfoFilter *filter = OSINFO_FILTER(object); g_hash_table_unref(filter->priv->propertyConstraints); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_filter_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_filter_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_filter_class_init (OsinfoFilterClass *klass) +osinfo_filter_class_init(OsinfoFilterClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_filter_finalize; - g_type_class_add_private (klass, sizeof (OsinfoFilterPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoFilterPrivate)); klass->matches = osinfo_filter_matches_default; } @@ -103,7 +103,7 @@ osinfo_filter_prop_constraints_free(gpointer props) static void -osinfo_filter_init (OsinfoFilter *filter) +osinfo_filter_init(OsinfoFilter *filter) { filter->priv = OSINFO_FILTER_GET_PRIVATE(filter); diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c index 9cdceb0..abe37bd 100644 --- a/osinfo/osinfo_install_config.c +++ b/osinfo/osinfo_install_config.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,9 +26,9 @@ #include #include -G_DEFINE_TYPE (OsinfoInstallConfig, osinfo_install_config, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoInstallConfig, osinfo_install_config, OSINFO_TYPE_ENTITY); -#define OSINFO_INSTALL_CONFIG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_CONFIG, OsinfoInstallConfigPrivate)) +#define OSINFO_INSTALL_CONFIG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_INSTALL_CONFIG, OsinfoInstallConfigPrivate)) /** * SECTION:osinfo_install_config @@ -48,9 +48,9 @@ struct _OsinfoInstallConfigPrivate /* Init functions */ static void -osinfo_install_config_class_init (OsinfoInstallConfigClass *klass) +osinfo_install_config_class_init(OsinfoInstallConfigClass *klass) { - g_type_class_add_private (klass, sizeof (OsinfoInstallConfigPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoInstallConfigPrivate)); } static const gchar valid[] = { @@ -65,7 +65,7 @@ static const gchar valid[] = { static void -osinfo_install_config_init (OsinfoInstallConfig *config) +osinfo_install_config_init(OsinfoInstallConfig *config) { gchar pass[9]; gsize i; @@ -82,7 +82,7 @@ osinfo_install_config_init (OsinfoInstallConfig *config) OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE, "en_US"); - for (i = 0 ; i < sizeof(pass)-1 ; i++) { + for (i = 0; i < sizeof(pass)-1; i++) { gint val = g_random_int_range(0, sizeof(valid)); pass[i] = valid[val]; } diff --git a/osinfo/osinfo_install_config_param.c b/osinfo/osinfo_install_config_param.c index 401279f..f74a802 100644 --- a/osinfo/osinfo_install_config_param.c +++ b/osinfo/osinfo_install_config_param.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * Copyright (C) 2012 Fabiano Fid?ncio * * This library is free software; you can redistribute it and/or @@ -28,9 +28,9 @@ #include #include -G_DEFINE_TYPE (OsinfoInstallConfigParam, osinfo_install_config_param, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoInstallConfigParam, osinfo_install_config_param, OSINFO_TYPE_ENTITY); -#define OSINFO_INSTALL_CONFIG_PARAM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_CONFIG_PARAM, OsinfoInstallConfigParamPrivate)) +#define OSINFO_INSTALL_CONFIG_PARAM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_INSTALL_CONFIG_PARAM, OsinfoInstallConfigParamPrivate)) /** * SECTION:osinfo_install_config_param @@ -64,7 +64,7 @@ osinfo_install_config_param_set_property(GObject *object, GParamSpec *pspec) { OsinfoInstallConfigParam *config_param = - OSINFO_INSTALL_CONFIG_PARAM (object); + OSINFO_INSTALL_CONFIG_PARAM(object); switch (property_id) { case PROP_NAME: @@ -80,7 +80,7 @@ osinfo_install_config_param_set_property(GObject *object, default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -92,7 +92,7 @@ osinfo_install_config_param_get_property(GObject *object, GParamSpec *pspec) { OsinfoInstallConfigParam *config_param = - OSINFO_INSTALL_CONFIG_PARAM (object); + OSINFO_INSTALL_CONFIG_PARAM(object); switch (property_id) { case PROP_NAME: @@ -116,7 +116,7 @@ osinfo_install_config_param_get_property(GObject *object, break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -129,14 +129,14 @@ osinfo_install_config_param_finalize(GObject *object) g_clear_object(&config_param->priv->value_map); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_install_config_param_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_install_config_param_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_install_config_param_class_init (OsinfoInstallConfigParamClass *klass) +osinfo_install_config_param_class_init(OsinfoInstallConfigParamClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->set_property = osinfo_install_config_param_set_property; @@ -190,11 +190,11 @@ osinfo_install_config_param_class_init (OsinfoInstallConfigParamClass *klass) pspec); g_klass->finalize = osinfo_install_config_param_finalize; - g_type_class_add_private (klass, sizeof (OsinfoInstallConfigParamPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoInstallConfigParamPrivate)); } static void -osinfo_install_config_param_init (OsinfoInstallConfigParam *config_param) +osinfo_install_config_param_init(OsinfoInstallConfigParam *config_param) { config_param->priv = OSINFO_INSTALL_CONFIG_PARAM_GET_PRIVATE(config_param); } diff --git a/osinfo/osinfo_install_config_paramlist.c b/osinfo/osinfo_install_config_paramlist.c index df44b58..060cbdb 100644 --- a/osinfo/osinfo_install_config_paramlist.c +++ b/osinfo/osinfo_install_config_paramlist.c @@ -1,7 +1,7 @@ /* * libosinfo: a list of installation configuration parameters * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,9 +28,9 @@ #include #include -G_DEFINE_TYPE (OsinfoInstallConfigParamList, osinfo_install_config_paramlist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoInstallConfigParamList, osinfo_install_config_paramlist, OSINFO_TYPE_LIST); -#define OSINFO_INSTALL_CONFIG_PARAMLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_CONFIG_PARAMLIST, OsinfoInstallConfigParamListPrivate)) +#define OSINFO_INSTALL_CONFIG_PARAMLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_INSTALL_CONFIG_PARAMLIST, OsinfoInstallConfigParamListPrivate)) /** * SECTION:osinfo_install_config_paramlist @@ -47,24 +47,24 @@ struct _OsinfoInstallConfigParamListPrivate }; static void -osinfo_install_config_paramlist_finalize (GObject *object) +osinfo_install_config_paramlist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_install_config_paramlist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_install_config_paramlist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_install_config_paramlist_class_init (OsinfoInstallConfigParamListClass *klass) +osinfo_install_config_paramlist_class_init(OsinfoInstallConfigParamListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_install_config_paramlist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoInstallConfigParamListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoInstallConfigParamListPrivate)); } static void -osinfo_install_config_paramlist_init (OsinfoInstallConfigParamList *list) +osinfo_install_config_paramlist_init(OsinfoInstallConfigParamList *list) { list->priv = OSINFO_INSTALL_CONFIG_PARAMLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c index b6fe1ab..fca1267 100644 --- a/osinfo/osinfo_install_script.c +++ b/osinfo/osinfo_install_script.c @@ -32,9 +32,9 @@ #include #include "osinfo_install_script_private.h" -G_DEFINE_TYPE (OsinfoInstallScript, osinfo_install_script, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoInstallScript, osinfo_install_script, OSINFO_TYPE_ENTITY); -#define OSINFO_INSTALL_SCRIPT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_SCRIPT, OsinfoInstallScriptPrivate)) +#define OSINFO_INSTALL_SCRIPT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_INSTALL_SCRIPT, OsinfoInstallScriptPrivate)) /** * SECTION:osinfo_install_script @@ -107,7 +107,7 @@ osinfo_install_script_set_property(GObject *object, default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -153,16 +153,16 @@ osinfo_install_script_get_property(GObject *object, default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } static void -osinfo_install_script_finalize (GObject *object) +osinfo_install_script_finalize(GObject *object) { - OsinfoInstallScript *script = OSINFO_INSTALL_SCRIPT (object); + OsinfoInstallScript *script = OSINFO_INSTALL_SCRIPT(object); g_free(script->priv->output_prefix); g_free(script->priv->output_filename); @@ -173,14 +173,14 @@ osinfo_install_script_finalize (GObject *object) g_object_unref(script->priv->avatar); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_install_script_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_install_script_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_install_script_class_init (OsinfoInstallScriptClass *klass) +osinfo_install_script_class_init(OsinfoInstallScriptClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->get_property = osinfo_install_script_get_property; @@ -254,7 +254,7 @@ osinfo_install_script_class_init (OsinfoInstallScriptClass *klass) PROP_AVATAR_FORMAT, pspec); - g_type_class_add_private (klass, sizeof (OsinfoInstallScriptPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoInstallScriptPrivate)); } void osinfo_install_script_add_config_param(OsinfoInstallScript *script, OsinfoInstallConfigParam *param) @@ -335,7 +335,7 @@ osinfo_install_script_get_config_param(const OsinfoInstallScript *script, } static void -osinfo_install_script_init (OsinfoInstallScript *list) +osinfo_install_script_init(OsinfoInstallScript *list) { list->priv = OSINFO_INSTALL_SCRIPT_GET_PRIVATE(list); list->priv->config_params = osinfo_install_config_paramlist_new(); @@ -1077,14 +1077,14 @@ static void osinfo_install_script_generate_output_write_file(GObject *src, OsinfoInstallScriptGenerateOutputData *data = user_data; if (data->stream == NULL) - data->stream = g_file_replace_finish(G_FILE (src), res, &data->error); + data->stream = g_file_replace_finish(G_FILE(src), res, &data->error); else data->output_pos += g_output_stream_write_finish(G_OUTPUT_STREAM(data->stream), res, &data->error); if (data->output_pos < data->output_len) { - g_output_stream_write_async(G_OUTPUT_STREAM (data->stream), + g_output_stream_write_async(G_OUTPUT_STREAM(data->stream), data->output + data->output_pos, data->output_len - data->output_pos, G_PRIORITY_DEFAULT, @@ -1093,7 +1093,7 @@ static void osinfo_install_script_generate_output_write_file(GObject *src, data); } else { - g_output_stream_close_async(G_OUTPUT_STREAM (data->stream), + g_output_stream_close_async(G_OUTPUT_STREAM(data->stream), G_PRIORITY_DEFAULT, data->cancellable, osinfo_install_script_generate_output_close_file, diff --git a/osinfo/osinfo_install_scriptlist.c b/osinfo/osinfo_install_scriptlist.c index c870ddf..3146619 100644 --- a/osinfo/osinfo_install_scriptlist.c +++ b/osinfo/osinfo_install_scriptlist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoInstallScriptList, osinfo_install_scriptlist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoInstallScriptList, osinfo_install_scriptlist, OSINFO_TYPE_LIST); -#define OSINFO_INSTALL_SCRIPTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_INSTALL_SCRIPTLIST, OsinfoInstallScriptListPrivate)) +#define OSINFO_INSTALL_SCRIPTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_INSTALL_SCRIPTLIST, OsinfoInstallScriptListPrivate)) /** * SECTION:osinfo_install_scriptlist @@ -46,24 +46,24 @@ struct _OsinfoInstallScriptListPrivate }; static void -osinfo_install_scriptlist_finalize (GObject *object) +osinfo_install_scriptlist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_install_scriptlist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_install_scriptlist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_install_scriptlist_class_init (OsinfoInstallScriptListClass *klass) +osinfo_install_scriptlist_class_init(OsinfoInstallScriptListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_install_scriptlist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoInstallScriptListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoInstallScriptListPrivate)); } static void -osinfo_install_scriptlist_init (OsinfoInstallScriptList *list) +osinfo_install_scriptlist_init(OsinfoInstallScriptList *list) { list->priv = OSINFO_INSTALL_SCRIPTLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_list.c b/osinfo/osinfo_list.c index c3fe92f..6e32387 100644 --- a/osinfo/osinfo_list.c +++ b/osinfo/osinfo_list.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,9 +28,9 @@ #include #include -G_DEFINE_ABSTRACT_TYPE (OsinfoList, osinfo_list, G_TYPE_OBJECT); +G_DEFINE_ABSTRACT_TYPE(OsinfoList, osinfo_list, G_TYPE_OBJECT); -#define OSINFO_LIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_LIST, OsinfoListPrivate)) +#define OSINFO_LIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_LIST, OsinfoListPrivate)) /** * SECTION:osinfo_list @@ -71,7 +71,7 @@ osinfo_list_set_property(GObject *object, default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -91,29 +91,29 @@ osinfo_list_get_property(GObject *object, default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } static void -osinfo_list_finalize (GObject *object) +osinfo_list_finalize(GObject *object) { - OsinfoList *list = OSINFO_LIST (object); + OsinfoList *list = OSINFO_LIST(object); g_ptr_array_free(list->priv->array, TRUE); g_hash_table_unref(list->priv->entities); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_list_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_list_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_list_class_init (OsinfoListClass *klass) +osinfo_list_class_init(OsinfoListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->set_property = osinfo_list_set_property; @@ -139,11 +139,11 @@ osinfo_list_class_init (OsinfoListClass *klass) PROP_ELEMENT_TYPE, pspec); - g_type_class_add_private (klass, sizeof (OsinfoListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoListPrivate)); } static void -osinfo_list_init (OsinfoList *list) +osinfo_list_init(OsinfoList *list) { list->priv = OSINFO_LIST_GET_PRIVATE(list); list->priv->array = g_ptr_array_new_with_free_func(NULL); diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c index 685352b..3f0ca54 100644 --- a/osinfo/osinfo_loader.c +++ b/osinfo/osinfo_loader.c @@ -38,9 +38,9 @@ #include "osinfo_install_script_private.h" #include "osinfo_device_driver_private.h" -G_DEFINE_TYPE (OsinfoLoader, osinfo_loader, G_TYPE_OBJECT); +G_DEFINE_TYPE(OsinfoLoader, osinfo_loader, G_TYPE_OBJECT); -#define OSINFO_LOADER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_LOADER, OsinfoLoaderPrivate)) +#define OSINFO_LOADER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_LOADER, OsinfoLoaderPrivate)) /** * SECTION:osinfo_loader @@ -65,32 +65,32 @@ struct _OsinfoEntityKey typedef struct _OsinfoEntityKey OsinfoEntityKey; static void -osinfo_loader_finalize (GObject *object) +osinfo_loader_finalize(GObject *object) { - OsinfoLoader *loader = OSINFO_LOADER (object); + OsinfoLoader *loader = OSINFO_LOADER(object); g_object_unref(loader->priv->db); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_loader_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_loader_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_loader_class_init (OsinfoLoaderClass *klass) +osinfo_loader_class_init(OsinfoLoaderClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); g_klass->finalize = osinfo_loader_finalize; - g_type_class_add_private (klass, sizeof (OsinfoLoaderPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoLoaderPrivate)); } static void -osinfo_loader_init (OsinfoLoader *loader) +osinfo_loader_init(OsinfoLoader *loader) { loader->priv = OSINFO_LOADER_GET_PRIVATE(loader); loader->priv->db = osinfo_db_new(); @@ -205,7 +205,7 @@ osinfo_loader_boolean(const char *xpath, if (count < 0) { return FALSE; } - for (i = 0 ; i < count ; i++) { + for (i = 0; i < count; i++) { xmlNodePtr node = nodes[i]; if (!node->children) { @@ -275,10 +275,10 @@ static void osinfo_loader_entity(OsinfoLoader *loader, GError **err) { int i = 0; - const gchar * const *langs = g_get_language_names (); + const gchar * const *langs = g_get_language_names(); /* Standard well-known keys first, allow single value only */ - for (i = 0 ; keys != NULL && keys[i].name != NULL; i++) { + for (i = 0; keys != NULL && keys[i].name != NULL; i++) { gchar *value_str = NULL; gboolean value_bool = FALSE; gchar *xpath = NULL; @@ -343,7 +343,7 @@ static void osinfo_loader_entity(OsinfoLoader *loader, if (error_is_set(err)) return; - for (i = 0 ; i < ncustom ; i++) { + for (i = 0; i < ncustom; i++) { xmlNodePtr param = custom[i]; if (!param->children || @@ -462,7 +462,7 @@ static void osinfo_loader_device_link(OsinfoLoader *loader, if (error_is_set(err)) return; - for (i = 0 ; i < nrelated ; i++) { + for (i = 0; i < nrelated; i++) { const OsinfoEntityKey keys[] = { { OSINFO_DEVICELINK_PROP_DRIVER, G_TYPE_STRING }, { NULL, G_TYPE_INVALID } @@ -510,7 +510,7 @@ static void osinfo_loader_product_relshp(OsinfoLoader *loader, if (error_is_set(err)) return; - for (i = 0 ; i < nrelated ; i++) { + for (i = 0; i < nrelated; i++) { gchar *id = (gchar *)xmlGetProp(related[i], BAD_CAST "id"); if (!id) { OSINFO_ERROR(err, _("Missing product upgrades id property")); @@ -676,7 +676,7 @@ static void osinfo_loader_datamap(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { gchar *inval = (gchar *)xmlGetProp(nodes[i], BAD_CAST "inval"); gchar *outval; @@ -707,7 +707,7 @@ static void osinfo_loader_install_config_params(OsinfoLoader *loader, if (error_is_set(err)) return; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { gchar *name = (gchar *)xmlGetProp(nodes[i], BAD_CAST OSINFO_INSTALL_CONFIG_PARAM_PROP_NAME); gchar *policy = (gchar *)xmlGetProp(nodes[i], BAD_CAST OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY); gchar *mapid = (gchar *)xmlGetProp(nodes[i], BAD_CAST OSINFO_INSTALL_CONFIG_PARAM_PROP_DATAMAP); @@ -750,7 +750,7 @@ static OsinfoAvatarFormat *osinfo_loader_avatar_format(OsinfoLoader *loader, osinfo_loader_entity(loader, OSINFO_ENTITY(avatar_format), keys, ctxt, root, err); if (error_is_set(err)) { - g_object_unref (avatar_format); + g_object_unref(avatar_format); return NULL; } @@ -842,7 +842,7 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, goto error; flags_class = g_type_class_ref(OSINFO_TYPE_INSTALL_SCRIPT_INJECTION_METHOD); - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { const gchar *nick = (const gchar *) nodes[i]->children->content; injection_methods |= g_flags_get_value_by_nick(flags_class, nick)->value; } @@ -864,7 +864,7 @@ static void osinfo_loader_install_script(OsinfoLoader *loader, g_object_unref(installScript); } -static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, +static OsinfoMedia *osinfo_loader_media(OsinfoLoader *loader, xmlXPathContextPtr ctxt, xmlNodePtr root, const gchar *id, @@ -916,7 +916,7 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, return NULL; } - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { gchar *variant_id = (gchar *)xmlGetProp(nodes[i], BAD_CAST "id"); osinfo_entity_add_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_VARIANT, @@ -931,7 +931,7 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, return NULL; } - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { if (!nodes[i]->children || nodes[i]->children->type != XML_TEXT_NODE || (strcmp((const gchar *)nodes[i]->name, @@ -978,7 +978,7 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader, return media; } -static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader, +static OsinfoTree *osinfo_loader_tree(OsinfoLoader *loader, xmlXPathContextPtr ctxt, xmlNodePtr root, const gchar *id, @@ -1007,7 +1007,7 @@ static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader, return NULL; } - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { if (!nodes[i]->children || nodes[i]->children->type != XML_TEXT_NODE) continue; @@ -1039,10 +1039,10 @@ static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader, return tree; } -static OsinfoOsVariant *osinfo_loader_os_variant (OsinfoLoader *loader, - xmlXPathContextPtr ctxt, - xmlNodePtr root, - GError **err) +static OsinfoOsVariant *osinfo_loader_os_variant(OsinfoLoader *loader, + xmlXPathContextPtr ctxt, + xmlNodePtr root, + GError **err) { const OsinfoEntityKey keys[] = { { OSINFO_OS_VARIANT_PROP_NAME, G_TYPE_STRING }, @@ -1078,7 +1078,7 @@ static OsinfoResources *osinfo_loader_resources(OsinfoLoader *loader, resources = osinfo_resources_new(id, arch); - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { if (!nodes[i]->children || nodes[i]->children->type != XML_TEXT_NODE || (strcmp((const gchar *)nodes[i]->name, @@ -1181,7 +1181,7 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader, return NULL; } - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { if (nodes[i]->children && nodes[i]->children->type == XML_TEXT_NODE && (strcmp((const gchar *)nodes[i]->name, @@ -1247,18 +1247,18 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = nodes[i]; - gchar *media_id = g_strdup_printf ("%s:%u", id, i); + gchar *media_id = g_strdup_printf("%s:%u", id, i); OsinfoMedia *media = osinfo_loader_media(loader, ctxt, nodes[i], media_id, err); - g_free (media_id); + g_free(media_id); ctxt->node = saved; if (error_is_set(err)) goto cleanup; - osinfo_os_add_media (os, media); - g_object_unref (media); + osinfo_os_add_media(os, media); + g_object_unref(media); } g_free(nodes); @@ -1267,17 +1267,17 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = nodes[i]; - gchar *tree_id = g_strdup_printf ("%s:%u", id, i); + gchar *tree_id = g_strdup_printf("%s:%u", id, i); OsinfoTree *tree = osinfo_loader_tree(loader, ctxt, nodes[i], tree_id, err); - g_free (tree_id); + g_free(tree_id); ctxt->node = saved; if (error_is_set(err)) goto cleanup; - osinfo_os_add_tree (os, tree); + osinfo_os_add_tree(os, tree); g_object_unref(G_OBJECT(tree)); } @@ -1287,7 +1287,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = nodes[i]; OsinfoOsVariant *variant = osinfo_loader_os_variant(loader, @@ -1298,7 +1298,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - osinfo_os_add_variant (os, variant); + osinfo_os_add_variant(os, variant); g_object_unref(G_OBJECT(variant)); } @@ -1308,10 +1308,10 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = nodes[i]; - gchar *resources_id = g_strdup_printf ("%s:%u", id, i); + gchar *resources_id = g_strdup_printf("%s:%u", id, i); osinfo_loader_resources_list(loader, ctxt, @@ -1319,7 +1319,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, resources_id, os, err); - g_free (resources_id); + g_free(resources_id); ctxt->node = saved; } @@ -1330,7 +1330,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { gchar *scriptid = (gchar *)xmlGetProp(nodes[i], BAD_CAST "id"); if (!scriptid) { OSINFO_ERROR(err, _("Missing OS install script property")); @@ -1349,7 +1349,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nnodes ; i++) { + for (i = 0; i < nnodes; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = nodes[i]; gchar *driver_id = g_strdup_printf("%s:%u", id, i); @@ -1358,7 +1358,7 @@ static void osinfo_loader_os(OsinfoLoader *loader, nodes[i], driver_id, err); - g_free (driver_id); + g_free(driver_id); ctxt->node = saved; if (error_is_set(err)) break; @@ -1416,7 +1416,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < ndevice ; i++) { + for (i = 0; i < ndevice; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = devices[i]; osinfo_loader_device(loader, ctxt, devices[i], err); @@ -1429,7 +1429,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nplatform ; i++) { + for (i = 0; i < nplatform; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = platforms[i]; osinfo_loader_platform(loader, ctxt, platforms[i], err); @@ -1442,7 +1442,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < nos ; i++) { + for (i = 0; i < nos; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = oss[i]; osinfo_loader_os(loader, ctxt, oss[i], err); @@ -1455,7 +1455,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < ndeployment ; i++) { + for (i = 0; i < ndeployment; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = deployments[i]; osinfo_loader_deployment(loader, ctxt, deployments[i], err); @@ -1468,7 +1468,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < ninstallScript ; i++) { + for (i = 0; i < ninstallScript; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = installScripts[i]; osinfo_loader_install_script(loader, ctxt, installScripts[i], err); @@ -1481,7 +1481,7 @@ static void osinfo_loader_root(OsinfoLoader *loader, if (error_is_set(err)) goto cleanup; - for (i = 0 ; i < ndataMaps ; i++) { + for (i = 0; i < ndataMaps; i++) { xmlNodePtr saved = ctxt->node; ctxt->node = dataMaps[i]; osinfo_loader_datamap(loader, ctxt, dataMaps[i], err); diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c index 09555ea..96f9603 100644 --- a/osinfo/osinfo_media.c +++ b/osinfo/osinfo_media.c @@ -1,7 +1,7 @@ /* * libosinfo: An installation media for a (guest) OS * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -109,22 +109,22 @@ static void create_from_location_data_free(CreateFromLocationData *data) } GQuark -osinfo_media_error_quark (void) +osinfo_media_error_quark(void) { static GQuark quark = 0; if (!quark) - quark = g_quark_from_static_string ("osinfo-media-error"); + quark = g_quark_from_static_string("osinfo-media-error"); return quark; } -G_DEFINE_TYPE (OsinfoMedia, osinfo_media, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoMedia, osinfo_media, OSINFO_TYPE_ENTITY); #define OSINFO_MEDIA_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ - OSINFO_TYPE_MEDIA, \ - OsinfoMediaPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + OSINFO_TYPE_MEDIA, \ + OsinfoMediaPrivate)) /** * SECTION:osinfo_media @@ -159,80 +159,80 @@ enum { }; static void -osinfo_media_get_property (GObject *object, +osinfo_media_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - OsinfoMedia *media = OSINFO_MEDIA (object); + OsinfoMedia *media = OSINFO_MEDIA(object); switch (property_id) { case PROP_ARCHITECTURE: - g_value_set_string (value, - osinfo_media_get_architecture (media)); + g_value_set_string(value, + osinfo_media_get_architecture(media)); break; case PROP_URL: - g_value_set_string (value, - osinfo_media_get_url (media)); + g_value_set_string(value, + osinfo_media_get_url(media)); break; case PROP_VOLUME_ID: - g_value_set_string (value, - osinfo_media_get_volume_id (media)); + g_value_set_string(value, + osinfo_media_get_volume_id(media)); break; case PROP_PUBLISHER_ID: - g_value_set_string (value, - osinfo_media_get_publisher_id (media)); + g_value_set_string(value, + osinfo_media_get_publisher_id(media)); break; case PROP_APPLICATION_ID: - g_value_set_string (value, - osinfo_media_get_application_id (media)); + g_value_set_string(value, + osinfo_media_get_application_id(media)); break; case PROP_SYSTEM_ID: - g_value_set_string (value, - osinfo_media_get_system_id (media)); + g_value_set_string(value, + osinfo_media_get_system_id(media)); break; case PROP_KERNEL_PATH: - g_value_set_string (value, - osinfo_media_get_kernel_path (media)); + g_value_set_string(value, + osinfo_media_get_kernel_path(media)); break; case PROP_INITRD_PATH: - g_value_set_string (value, - osinfo_media_get_initrd_path (media)); + g_value_set_string(value, + osinfo_media_get_initrd_path(media)); break; case PROP_INSTALLER: - g_value_set_boolean (value, - osinfo_media_get_installer (media)); + g_value_set_boolean(value, + osinfo_media_get_installer(media)); break; case PROP_LIVE: - g_value_set_boolean (value, - osinfo_media_get_live (media)); + g_value_set_boolean(value, + osinfo_media_get_live(media)); break; case PROP_INSTALLER_REBOOTS: - g_value_set_int (value, - osinfo_media_get_installer_reboots (media)); + g_value_set_int(value, + osinfo_media_get_installer_reboots(media)); break; case PROP_OS: - g_value_take_object (value, osinfo_media_get_os (media)); + g_value_take_object(value, osinfo_media_get_os(media)); break; case PROP_LANGUAGES: - g_value_set_pointer (value, osinfo_media_get_languages (media)); + g_value_set_pointer(value, osinfo_media_get_languages(media)); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -243,73 +243,73 @@ osinfo_media_set_property(GObject *object, const GValue *value, GParamSpec *pspec) { - OsinfoMedia *media = OSINFO_MEDIA (object); + OsinfoMedia *media = OSINFO_MEDIA(object); switch (property_id) { case PROP_ARCHITECTURE: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_ARCHITECTURE, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_ARCHITECTURE, + g_value_get_string(value)); break; case PROP_URL: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_URL, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_URL, + g_value_get_string(value)); break; case PROP_VOLUME_ID: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_VOLUME_ID, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_VOLUME_ID, + g_value_get_string(value)); break; case PROP_PUBLISHER_ID: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_PUBLISHER_ID, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_PUBLISHER_ID, + g_value_get_string(value)); break; case PROP_APPLICATION_ID: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_APPLICATION_ID, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_APPLICATION_ID, + g_value_get_string(value)); break; case PROP_SYSTEM_ID: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_SYSTEM_ID, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_SYSTEM_ID, + g_value_get_string(value)); break; case PROP_KERNEL_PATH: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_KERNEL, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_KERNEL, + g_value_get_string(value)); break; case PROP_INITRD_PATH: - osinfo_entity_set_param (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_INITRD, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_INITRD, + g_value_get_string(value)); break; case PROP_LIVE: - osinfo_entity_set_param_boolean (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_LIVE, - g_value_get_boolean (value)); + osinfo_entity_set_param_boolean(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_LIVE, + g_value_get_boolean(value)); break; case PROP_INSTALLER: - osinfo_entity_set_param_boolean (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_INSTALLER, - g_value_get_boolean (value)); + osinfo_entity_set_param_boolean(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_INSTALLER, + g_value_get_boolean(value)); break; case PROP_INSTALLER_REBOOTS: - osinfo_entity_set_param_int64 (OSINFO_ENTITY(media), - OSINFO_MEDIA_PROP_INSTALLER_REBOOTS, - g_value_get_int (value)); + osinfo_entity_set_param_int64(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_INSTALLER_REBOOTS, + g_value_get_int(value)); break; case PROP_OS: @@ -322,16 +322,16 @@ osinfo_media_set_property(GObject *object, default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } static void -osinfo_media_finalize (GObject *object) +osinfo_media_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_media_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_media_parent_class)->finalize(object); } static void osinfo_media_dispose(GObject *obj) @@ -346,146 +346,146 @@ static void osinfo_media_dispose(GObject *obj) /* Init functions */ static void -osinfo_media_class_init (OsinfoMediaClass *klass) +osinfo_media_class_init(OsinfoMediaClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->dispose = osinfo_media_dispose; g_klass->finalize = osinfo_media_finalize; g_klass->get_property = osinfo_media_get_property; g_klass->set_property = osinfo_media_set_property; - g_type_class_add_private (klass, sizeof (OsinfoMediaPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoMediaPrivate)); /** * OsinfoMedia:architecture: * * The target hardware architecture of this media. */ - pspec = g_param_spec_string ("architecture", - "ARCHITECTURE", - _("CPU Architecture"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_ARCHITECTURE, pspec); + pspec = g_param_spec_string("architecture", + "ARCHITECTURE", + _("CPU Architecture"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_ARCHITECTURE, pspec); /** * OsinfoMedia:url: * * The URL to this media. */ - pspec = g_param_spec_string ("url", - "URL", - _("The URL to this media"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_URL, pspec); + pspec = g_param_spec_string("url", + "URL", + _("The URL to this media"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_URL, pspec); /** * OsinfoMedia:volume-id: * * Expected volume ID (regular expression) for ISO9660 image/device. */ - pspec = g_param_spec_string ("volume-id", - "VolumeID", - _("The expected ISO9660 volume ID"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_VOLUME_ID, pspec); + pspec = g_param_spec_string("volume-id", + "VolumeID", + _("The expected ISO9660 volume ID"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_VOLUME_ID, pspec); /** * OsinfoMedia:publisher-id: * * Expected publisher ID (regular expression) for ISO9660 image/device. */ - pspec = g_param_spec_string ("publisher-id", - "PublisherID", - _("The expected ISO9660 publisher ID"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_PUBLISHER_ID, pspec); + pspec = g_param_spec_string("publisher-id", + "PublisherID", + _("The expected ISO9660 publisher ID"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_PUBLISHER_ID, pspec); /** * OsinfoMedia:application-id: * * Expected application ID (regular expression) for ISO9660 image/device. */ - pspec = g_param_spec_string ("application-id", - "ApplicationID", - _("The expected ISO9660 application ID"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_APPLICATION_ID, pspec); + pspec = g_param_spec_string("application-id", + "ApplicationID", + _("The expected ISO9660 application ID"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_APPLICATION_ID, pspec); /** * OsinfoMedia:system-id: * * Expected system ID (regular expression) for ISO9660 image/device. */ - pspec = g_param_spec_string ("system-id", - "SystemID", - _("The expected ISO9660 system ID"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_SYSTEM_ID, pspec); + pspec = g_param_spec_string("system-id", + "SystemID", + _("The expected ISO9660 system ID"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_SYSTEM_ID, pspec); /** * OsinfoMedia:kernel-path: * * The path to the kernel image in the install tree. */ - pspec = g_param_spec_string ("kernel-path", - "KernelPath", - _("The path to the kernel image"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_KERNEL_PATH, pspec); + pspec = g_param_spec_string("kernel-path", + "KernelPath", + _("The path to the kernel image"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_KERNEL_PATH, pspec); /** * OsinfoMedia:initrd-path: * * The path to the initrd image in the install tree. */ - pspec = g_param_spec_string ("initrd-path", - "InitrdPath", - _("The path to the initrd image"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_INITRD_PATH, pspec); + pspec = g_param_spec_string("initrd-path", + "InitrdPath", + _("The path to the initrd image"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_INITRD_PATH, pspec); /** * OsinfoMedia:installer: * * Whether media provides an installer for an OS. */ - pspec = g_param_spec_boolean ("installer", - "Installer", - _("Media provides an installer"), - TRUE /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_INSTALLER, pspec); + pspec = g_param_spec_boolean("installer", + "Installer", + _("Media provides an installer"), + TRUE /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_INSTALLER, pspec); /** * OsinfoMedia:live: * * Whether media can boot directly an OS without any installations. */ - pspec = g_param_spec_boolean ("live", - "Live", - _("Media can boot directly w/o installation"), - FALSE /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_LIVE, pspec); + pspec = g_param_spec_boolean("live", + "Live", + _("Media can boot directly w/o installation"), + FALSE /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_LIVE, pspec); /** * OsinfoMedia:installer-reboots: @@ -494,22 +494,22 @@ osinfo_media_class_init (OsinfoMediaClass *klass) * the installer takes before installation is complete. * * This property is not applicable to media that has no installer. You can - * use #osinfo_media_get_installer (or OsinfoMedia::installer) to check + * use #osinfo_media_get_installer(or OsinfoMedia::installer) to check * that. * * Warning: Some media allow you to install from live sessions, in which * case number of reboots *alone* is not a reliable method for tracking * installation. */ - pspec = g_param_spec_int ("installer-reboots", - "InstallerReboots", - _("Number of installer reboots"), - G_MININT, - G_MAXINT, - 1 /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_INSTALLER_REBOOTS, pspec); + pspec = g_param_spec_int("installer-reboots", + "InstallerReboots", + _("Number of installer reboots"), + G_MININT, + G_MAXINT, + 1 /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_INSTALLER_REBOOTS, pspec); /** * OsinfoMedia:os: @@ -519,13 +519,13 @@ osinfo_media_class_init (OsinfoMediaClass *klass) * the property will be filled after a successful call to * osinfo_db_identify_media(). */ - pspec = g_param_spec_object ("os", - "Os", - _("Information about the operating system on this media"), - OSINFO_TYPE_OS, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_OS, pspec); + pspec = g_param_spec_object("os", + "Os", + _("Information about the operating system on this media"), + OSINFO_TYPE_OS, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_OS, pspec); /** * OsinfoMedia:languages: @@ -535,22 +535,22 @@ osinfo_media_class_init (OsinfoMediaClass *klass) * * On media that are not installers, this property will indicate the * languages that the user interface can be displayed in. - * Use #osinfo_media_get_installer (or OsinfoMedia::installer) to know + * Use #osinfo_media_get_installer(or OsinfoMedia::installer) to know * if the media is an installer or not. * * Type: GLib.List(utf8) * Transfer: container */ - pspec = g_param_spec_pointer ("languages", - "Languages", - _("Supported languages"), - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_LANGUAGES, pspec); + pspec = g_param_spec_pointer("languages", + "Languages", + _("Supported languages"), + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_LANGUAGES, pspec); } static void -osinfo_media_init (OsinfoMedia *media) +osinfo_media_init(OsinfoMedia *media) { media->priv = OSINFO_MEDIA_GET_PRIVATE(media); g_weak_ref_init(&media->priv->os, NULL); @@ -572,7 +572,7 @@ OsinfoMedia *osinfo_media_new(const gchar *id, return media; } -static void on_media_create_from_location_ready (GObject *source_object, +static void on_media_create_from_location_ready(GObject *source_object, GAsyncResult *res, gpointer user_data) { @@ -604,7 +604,7 @@ OsinfoMedia *osinfo_media_create_from_location(const gchar *location, OsinfoMedia *ret; data = g_slice_new0(CreateFromLocationData); - data->main_loop = g_main_loop_new (g_main_context_get_thread_default (), + data->main_loop = g_main_loop_new(g_main_context_get_thread_default(), TRUE); osinfo_media_create_from_location_async(location, @@ -614,8 +614,8 @@ OsinfoMedia *osinfo_media_create_from_location(const gchar *location, data); /* Loop till we get a reply (or time out) */ - if (g_main_loop_is_running (data->main_loop)) - g_main_loop_run (data->main_loop); + if (g_main_loop_is_running(data->main_loop)) + g_main_loop_run(data->main_loop); ret = osinfo_media_create_from_location_finish(data->res, error); create_from_location_data_free(data); @@ -630,8 +630,8 @@ static gboolean is_str_empty(const gchar *str) { if ((str == NULL) || (*str == 0)) return TRUE; - for (i = 0; i < strlen (str); i++) - if (!g_ascii_isspace (str[i])) { + for (i = 0; i < strlen(str); i++) + if (!g_ascii_isspace(str[i])) { ret = FALSE; break; @@ -640,7 +640,7 @@ static gboolean is_str_empty(const gchar *str) { return ret; } -static void on_svd_read (GObject *source, +static void on_svd_read(GObject *source, GAsyncResult *res, gpointer user_data) { @@ -701,19 +701,19 @@ static void on_svd_read (GObject *source, OSINFO_MEDIA_PROP_URL, uri); g_free(uri); - if (!is_str_empty (data->pvd.volume)) + if (!is_str_empty(data->pvd.volume)) osinfo_entity_set_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_VOLUME_ID, data->pvd.volume); - if (!is_str_empty (data->pvd.system)) + if (!is_str_empty(data->pvd.system)) osinfo_entity_set_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_SYSTEM_ID, data->pvd.system); - if (!is_str_empty (data->pvd.publisher)) + if (!is_str_empty(data->pvd.publisher)) osinfo_entity_set_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_PUBLISHER_ID, data->pvd.publisher); - if (!is_str_empty (data->pvd.application)) + if (!is_str_empty(data->pvd.application)) osinfo_entity_set_param(OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_APPLICATION_ID, data->pvd.application); @@ -723,13 +723,13 @@ EXIT: g_simple_async_result_take_error(data->res, error); else g_simple_async_result_set_op_res_gpointer(data->res, media, NULL); - g_simple_async_result_complete (data->res); + g_simple_async_result_complete(data->res); g_object_unref(stream); create_from_location_async_data_free(data); } -static void on_pvd_read (GObject *source, +static void on_pvd_read(GObject *source, GAsyncResult *res, gpointer user_data) { @@ -795,7 +795,7 @@ static void on_pvd_read (GObject *source, ON_ERROR: g_simple_async_result_take_error(data->res, error); - g_simple_async_result_complete (data->res); + g_simple_async_result_complete(data->res); create_from_location_async_data_free(data); } @@ -814,11 +814,11 @@ static void on_location_skipped(GObject *source, g_prefix_error(&error, _("Failed to skip %d bytes"), PVD_OFFSET); else g_set_error(&error, - OSINFO_MEDIA_ERROR, - OSINFO_MEDIA_ERROR_NO_DESCRIPTORS, - _("No volume descriptors")); + OSINFO_MEDIA_ERROR, + OSINFO_MEDIA_ERROR_NO_DESCRIPTORS, + _("No volume descriptors")); g_simple_async_result_take_error(data->res, error); - g_simple_async_result_complete (data->res); + g_simple_async_result_complete(data->res); create_from_location_async_data_free(data); return; @@ -850,7 +850,7 @@ static void on_location_read(GObject *source, if (error != NULL) { g_prefix_error(&error, _("Failed to open file")); g_simple_async_result_take_error(data->res, error); - g_simple_async_result_complete (data->res); + g_simple_async_result_complete(data->res); create_from_location_async_data_free(data); return; @@ -1095,7 +1095,7 @@ gboolean osinfo_media_get_live(OsinfoMedia *media) * installer takes before installation is complete. * * This function is not supposed to be called on media that has no installer. - * You can use #osinfo_media_get_installer (or OsinfoMedia::installer) to check + * You can use #osinfo_media_get_installer(or OsinfoMedia::installer) to check * that. * * Warning: Some media allow you to install from live sessions, in which case @@ -1107,7 +1107,7 @@ gboolean osinfo_media_get_live(OsinfoMedia *media) gint osinfo_media_get_installer_reboots(OsinfoMedia *media) { g_return_val_if_fail(OSINFO_IS_MEDIA(media), -1); - g_return_val_if_fail(osinfo_media_get_installer (media), -1); + g_return_val_if_fail(osinfo_media_get_installer(media), -1); return (gint) osinfo_entity_get_param_value_int64_with_default (OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_INSTALLER_REBOOTS, 1); @@ -1183,7 +1183,7 @@ OsinfoOsVariantList *osinfo_media_get_os_variants(OsinfoMedia *media) * * On media that are not installers, this property will indicate the * languages that the user interface can be displayed in. - * Use #osinfo_media_get_installer (or OsinfoMedia::installer) to know + * Use #osinfo_media_get_installer(or OsinfoMedia::installer) to know * if the media is an installer or not. * * Returns: (transfer container) (element-type utf8): a #GList diff --git a/osinfo/osinfo_medialist.c b/osinfo/osinfo_medialist.c index da018a6..d32ad27 100644 --- a/osinfo/osinfo_medialist.c +++ b/osinfo/osinfo_medialist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoMediaList, osinfo_medialist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoMediaList, osinfo_medialist, OSINFO_TYPE_LIST); -#define OSINFO_MEDIALIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_MEDIALIST, OsinfoMediaListPrivate)) +#define OSINFO_MEDIALIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_MEDIALIST, OsinfoMediaListPrivate)) /** * SECTION:osinfo_medialist @@ -46,24 +46,24 @@ struct _OsinfoMediaListPrivate }; static void -osinfo_medialist_finalize (GObject *object) +osinfo_medialist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_medialist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_medialist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_medialist_class_init (OsinfoMediaListClass *klass) +osinfo_medialist_class_init(OsinfoMediaListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_medialist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoMediaListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoMediaListPrivate)); } static void -osinfo_medialist_init (OsinfoMediaList *list) +osinfo_medialist_init(OsinfoMediaList *list) { list->priv = OSINFO_MEDIALIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c index c8b6ad5..ab97c67 100644 --- a/osinfo/osinfo_os.c +++ b/osinfo/osinfo_os.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,9 +29,9 @@ #include "osinfo/osinfo_product_private.h" #include -G_DEFINE_TYPE (OsinfoOs, osinfo_os, OSINFO_TYPE_PRODUCT); +G_DEFINE_TYPE(OsinfoOs, osinfo_os, OSINFO_TYPE_PRODUCT); -#define OSINFO_OS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_OS, OsinfoOsPrivate)) +#define OSINFO_OS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_OS, OsinfoOsPrivate)) /** * SECTION:osinfo_os @@ -73,7 +73,7 @@ enum { PROP_DISTRO, }; -static void osinfo_os_finalize (GObject *object); +static void osinfo_os_finalize(GObject *object); static void osinfo_device_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED) { @@ -81,36 +81,36 @@ static void osinfo_device_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED } static void -osinfo_os_get_property (GObject *object, +osinfo_os_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - OsinfoEntity *entity = OSINFO_ENTITY (object); + OsinfoEntity *entity = OSINFO_ENTITY(object); switch (property_id) { case PROP_FAMILY: - g_value_set_string (value, - osinfo_entity_get_param_value (entity, + g_value_set_string(value, + osinfo_entity_get_param_value(entity, "family")); break; case PROP_DISTRO: - g_value_set_string (value, - osinfo_entity_get_param_value (entity, + g_value_set_string(value, + osinfo_entity_get_param_value(entity, "distro")); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } static void -osinfo_os_finalize (GObject *object) +osinfo_os_finalize(GObject *object) { - OsinfoOs *os = OSINFO_OS (object); + OsinfoOs *os = OSINFO_OS(object); g_list_foreach(os->priv->deviceLinks, osinfo_device_link_free, NULL); g_list_free(os->priv->deviceLinks); @@ -123,20 +123,20 @@ osinfo_os_finalize (GObject *object) g_object_unref(os->priv->device_drivers); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_os_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_os_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_os_class_init (OsinfoOsClass *klass) +osinfo_os_class_init(OsinfoOsClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->get_property = osinfo_os_get_property; g_klass->finalize = osinfo_os_finalize; - g_type_class_add_private (klass, sizeof (OsinfoOsPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoOsPrivate)); /** * OsinfoOs:family: @@ -144,13 +144,13 @@ osinfo_os_class_init (OsinfoOsClass *klass) * The generic family this OS belongs to, based upon its kernel, * for example linux, winnt, solaris, freebsd etc. */ - pspec = g_param_spec_string ("family", - "Family", - _("Generic Family"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, + pspec = g_param_spec_string("family", + "Family", + _("Generic Family"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_FAMILY, pspec); @@ -160,30 +160,30 @@ osinfo_os_class_init (OsinfoOsClass *klass) * The generic distro this OS belongs to, for example fedora, windows, * solaris, freebsd etc. */ - pspec = g_param_spec_string ("distro", - "Distro", - _("Generic Distro"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, - PROP_DISTRO, - pspec); + pspec = g_param_spec_string("distro", + "Distro", + _("Generic Distro"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, + PROP_DISTRO, + pspec); } static void -osinfo_os_init (OsinfoOs *os) +osinfo_os_init(OsinfoOs *os) { os->priv = OSINFO_OS_GET_PRIVATE(os); os->priv->deviceLinks = NULL; - os->priv->medias = osinfo_medialist_new (); - os->priv->trees = osinfo_treelist_new (); - os->priv->variants = osinfo_os_variantlist_new (); - os->priv->minimum = osinfo_resourceslist_new (); - os->priv->recommended = osinfo_resourceslist_new (); - os->priv->scripts = osinfo_install_scriptlist_new (); - os->priv->device_drivers = osinfo_device_driverlist_new (); + os->priv->medias = osinfo_medialist_new(); + os->priv->trees = osinfo_treelist_new(); + os->priv->variants = osinfo_os_variantlist_new(); + os->priv->minimum = osinfo_resourceslist_new(); + os->priv->recommended = osinfo_resourceslist_new(); + os->priv->scripts = osinfo_install_scriptlist_new(); + os->priv->device_drivers = osinfo_device_driverlist_new(); } /** @@ -311,7 +311,7 @@ OsinfoDeviceList *osinfo_os_get_devices_by_property(OsinfoOs *os, devices = osinfo_os_get_all_devices(os, filter); else devices = osinfo_os_get_devices(os, filter); - g_object_unref (filter); + g_object_unref(filter); return devices; } diff --git a/osinfo/osinfo_os_variant.c b/osinfo/osinfo_os_variant.c index f859235..914353f 100644 --- a/osinfo/osinfo_os_variant.c +++ b/osinfo/osinfo_os_variant.c @@ -1,7 +1,7 @@ /* * libosinfo: The variant of an OS * - * Copyright (C) 2013 Red Hat, Inc. + * Copyright (C) 2013-2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,10 +26,10 @@ #include #include -G_DEFINE_TYPE (OsinfoOsVariant, osinfo_os_variant, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoOsVariant, osinfo_os_variant, OSINFO_TYPE_ENTITY); #define OSINFO_OS_VARIANT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ OSINFO_TYPE_OS_VARIANT, \ OsinfoOsVariantPrivate)) @@ -52,22 +52,22 @@ enum { }; static void -osinfo_os_variant_get_property (GObject *object, +osinfo_os_variant_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - OsinfoOsVariant *variant = OSINFO_OS_VARIANT (object); + OsinfoOsVariant *variant = OSINFO_OS_VARIANT(object); switch (property_id) { case PROP_NAME: - g_value_set_string (value, - osinfo_os_variant_get_name (variant)); + g_value_set_string(value, + osinfo_os_variant_get_name(variant)); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -78,49 +78,49 @@ osinfo_os_variant_set_property(GObject *object, const GValue *value, GParamSpec *pspec) { - OsinfoOsVariant *variant = OSINFO_OS_VARIANT (object); + OsinfoOsVariant *variant = OSINFO_OS_VARIANT(object); switch (property_id) { case PROP_NAME: - osinfo_entity_set_param (OSINFO_ENTITY(variant), - OSINFO_OS_VARIANT_PROP_NAME, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(variant), + OSINFO_OS_VARIANT_PROP_NAME, + g_value_get_string(value)); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } /* Init functions */ static void -osinfo_os_variant_class_init (OsinfoOsVariantClass *klass) +osinfo_os_variant_class_init(OsinfoOsVariantClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->get_property = osinfo_os_variant_get_property; g_klass->set_property = osinfo_os_variant_set_property; - g_type_class_add_private (klass, sizeof (OsinfoOsVariantPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoOsVariantPrivate)); /** * OsinfoOsVariant:name: * * The name to this variant. */ - pspec = g_param_spec_string ("name", - "Name", - _("The name to this variant"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_NAME, pspec); + pspec = g_param_spec_string("name", + "Name", + _("The name to this variant"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_NAME, pspec); } static void -osinfo_os_variant_init (OsinfoOsVariant *variant) +osinfo_os_variant_init(OsinfoOsVariant *variant) { variant->priv = OSINFO_OS_VARIANT_GET_PRIVATE(variant); } diff --git a/osinfo/osinfo_os_variantlist.c b/osinfo/osinfo_os_variantlist.c index b6bbced..469c62a 100644 --- a/osinfo/osinfo_os_variantlist.c +++ b/osinfo/osinfo_os_variantlist.c @@ -1,7 +1,7 @@ /* * libosinfo: a list of OS variants * - * Copyright (C) 2013 Red Hat, Inc. + * Copyright (C) 2013-2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,9 +25,9 @@ #include -G_DEFINE_TYPE (OsinfoOsVariantList, osinfo_os_variantlist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoOsVariantList, osinfo_os_variantlist, OSINFO_TYPE_LIST); -#define OSINFO_OS_VARIANTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_OS_VARIANTLIST, OsinfoOsVariantListPrivate)) +#define OSINFO_OS_VARIANTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_OS_VARIANTLIST, OsinfoOsVariantListPrivate)) /** * SECTION:osinfo_os_variantlist @@ -45,13 +45,13 @@ struct _OsinfoOsVariantListPrivate /* Init functions */ static void -osinfo_os_variantlist_class_init (OsinfoOsVariantListClass *klass) +osinfo_os_variantlist_class_init(OsinfoOsVariantListClass *klass) { - g_type_class_add_private (klass, sizeof (OsinfoOsVariantListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoOsVariantListPrivate)); } static void -osinfo_os_variantlist_init (OsinfoOsVariantList *list) +osinfo_os_variantlist_init(OsinfoOsVariantList *list) { list->priv = OSINFO_OS_VARIANTLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_oslist.c b/osinfo/osinfo_oslist.c index 59e8750..2c9b593 100644 --- a/osinfo/osinfo_oslist.c +++ b/osinfo/osinfo_oslist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoOsList, osinfo_oslist, OSINFO_TYPE_PRODUCTLIST); +G_DEFINE_TYPE(OsinfoOsList, osinfo_oslist, OSINFO_TYPE_PRODUCTLIST); -#define OSINFO_OSLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_OSLIST, OsinfoOsListPrivate)) +#define OSINFO_OSLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_OSLIST, OsinfoOsListPrivate)) /** * SECTION:osinfo_oslist @@ -46,24 +46,24 @@ struct _OsinfoOsListPrivate }; static void -osinfo_oslist_finalize (GObject *object) +osinfo_oslist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_oslist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_oslist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_oslist_class_init (OsinfoOsListClass *klass) +osinfo_oslist_class_init(OsinfoOsListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_oslist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoOsListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoOsListPrivate)); } static void -osinfo_oslist_init (OsinfoOsList *list) +osinfo_oslist_init(OsinfoOsList *list) { list->priv = OSINFO_OSLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_platform.c b/osinfo/osinfo_platform.c index c447448..b17eef6 100644 --- a/osinfo/osinfo_platform.c +++ b/osinfo/osinfo_platform.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,9 +28,9 @@ #include "osinfo/osinfo_product_private.h" #include -G_DEFINE_TYPE (OsinfoPlatform, osinfo_platform, OSINFO_TYPE_PRODUCT); +G_DEFINE_TYPE(OsinfoPlatform, osinfo_platform, OSINFO_TYPE_PRODUCT); -#define OSINFO_PLATFORM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_PLATFORM, OsinfoPlatformPrivate)) +#define OSINFO_PLATFORM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_PLATFORM, OsinfoPlatformPrivate)) /** * SECTION:osinfo_platform @@ -58,29 +58,29 @@ static void osinfo_device_link_free(gpointer data, gpointer opaque G_GNUC_UNUSED } static void -osinfo_platform_finalize (GObject *object) +osinfo_platform_finalize(GObject *object) { - OsinfoPlatform *platform = OSINFO_PLATFORM (object); + OsinfoPlatform *platform = OSINFO_PLATFORM(object); g_list_foreach(platform->priv->deviceLinks, osinfo_device_link_free, NULL); g_list_free(platform->priv->deviceLinks); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_platform_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_platform_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_platform_class_init (OsinfoPlatformClass *klass) +osinfo_platform_class_init(OsinfoPlatformClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_platform_finalize; - g_type_class_add_private (klass, sizeof (OsinfoPlatformPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoPlatformPrivate)); } static void -osinfo_platform_init (OsinfoPlatform *platform) +osinfo_platform_init(OsinfoPlatform *platform) { platform->priv = OSINFO_PLATFORM_GET_PRIVATE(platform); platform->priv->deviceLinks = NULL; diff --git a/osinfo/osinfo_platformlist.c b/osinfo/osinfo_platformlist.c index 8322fc2..00990f4 100644 --- a/osinfo/osinfo_platformlist.c +++ b/osinfo/osinfo_platformlist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoPlatformList, osinfo_platformlist, OSINFO_TYPE_PRODUCTLIST); +G_DEFINE_TYPE(OsinfoPlatformList, osinfo_platformlist, OSINFO_TYPE_PRODUCTLIST); -#define OSINFO_PLATFORMLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_PLATFORMLIST, OsinfoPlatformListPrivate)) +#define OSINFO_PLATFORMLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_PLATFORMLIST, OsinfoPlatformListPrivate)) /** * SECTION:osinfo_platformlist @@ -46,24 +46,24 @@ struct _OsinfoPlatformListPrivate }; static void -osinfo_platformlist_finalize (GObject *object) +osinfo_platformlist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_platformlist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_platformlist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_platformlist_class_init (OsinfoPlatformListClass *klass) +osinfo_platformlist_class_init(OsinfoPlatformListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_platformlist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoPlatformListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoPlatformListPrivate)); } static void -osinfo_platformlist_init (OsinfoPlatformList *list) +osinfo_platformlist_init(OsinfoPlatformList *list) { list->priv = OSINFO_PLATFORMLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_product.c b/osinfo/osinfo_product.c index 35a4071..1bd7017 100644 --- a/osinfo/osinfo_product.c +++ b/osinfo/osinfo_product.c @@ -1,7 +1,7 @@ /* * osinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,9 +32,9 @@ #include "osinfo/osinfo_product_private.h" -G_DEFINE_ABSTRACT_TYPE (OsinfoProduct, osinfo_product, OSINFO_TYPE_ENTITY); +G_DEFINE_ABSTRACT_TYPE(OsinfoProduct, osinfo_product, OSINFO_TYPE_ENTITY); -#define OSINFO_PRODUCT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_PRODUCT, OsinfoProductPrivate)) +#define OSINFO_PRODUCT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_PRODUCT, OsinfoProductPrivate)) /** * SECTION:osinfo_product @@ -91,155 +91,155 @@ static void osinfo_product_link_free(gpointer data, gpointer opaque G_GNUC_UNUSE static void -osinfo_product_finalize (GObject *object) +osinfo_product_finalize(GObject *object) { - OsinfoProduct *product = OSINFO_PRODUCT (object); + OsinfoProduct *product = OSINFO_PRODUCT(object); g_list_foreach(product->priv->productLinks, osinfo_product_link_free, NULL); g_list_free(product->priv->productLinks); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_product_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_product_parent_class)->finalize(object); } static void -osinfo_product_get_property (GObject *object, +osinfo_product_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - OsinfoProduct *product = OSINFO_PRODUCT (object); + OsinfoProduct *product = OSINFO_PRODUCT(object); switch (property_id) { case PROP_NAME: - g_value_set_string (value, - osinfo_product_get_name (product)); + g_value_set_string(value, + osinfo_product_get_name(product)); break; case PROP_SHORT_ID: - g_value_set_string (value, - osinfo_product_get_short_id (product)); + g_value_set_string(value, + osinfo_product_get_short_id(product)); break; case PROP_VENDOR: - g_value_set_string (value, - osinfo_product_get_vendor (product)); + g_value_set_string(value, + osinfo_product_get_vendor(product)); break; case PROP_VERSION: - g_value_set_string (value, - osinfo_product_get_version (product)); + g_value_set_string(value, + osinfo_product_get_version(product)); break; case PROP_CODENAME: - g_value_set_string (value, - osinfo_product_get_codename (product)); + g_value_set_string(value, + osinfo_product_get_codename(product)); break; case PROP_LOGO: - g_value_set_string (value, - osinfo_product_get_logo (product)); + g_value_set_string(value, + osinfo_product_get_logo(product)); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } /* Init functions */ static void -osinfo_product_class_init (OsinfoProductClass *klass) +osinfo_product_class_init(OsinfoProductClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->get_property = osinfo_product_get_property; g_klass->finalize = osinfo_product_finalize; - g_type_class_add_private (klass, sizeof (OsinfoProductPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoProductPrivate)); /** * OsinfoProduct:name: * * The name of this product. */ - pspec = g_param_spec_string ("name", - "Name", - _("Name"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_NAME, pspec); + pspec = g_param_spec_string("name", + "Name", + _("Name"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_NAME, pspec); /** * OsinfoProduct:short-id: * * The short ID of this product. */ - pspec = g_param_spec_string ("short-id", - "ShortID", - _("Short ID"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_SHORT_ID, pspec); + pspec = g_param_spec_string("short-id", + "ShortID", + _("Short ID"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_SHORT_ID, pspec); /** * OsinfoProduct:vendor: * * The Vendor of this product. */ - pspec = g_param_spec_string ("vendor", - "Vendor", - _("Vendor"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_VENDOR, pspec); + pspec = g_param_spec_string("vendor", + "Vendor", + _("Vendor"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_VENDOR, pspec); /** * OsinfoProduct:version: * * The version of the product. */ - pspec = g_param_spec_string ("version", - "Version", - _("Version"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_VERSION, pspec); + pspec = g_param_spec_string("version", + "Version", + _("Version"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_VERSION, pspec); /** * OsinfoProduct:codename: * * The codename of this product. */ - pspec = g_param_spec_string ("codename", - "Codename", - _("Codename"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_NAME, pspec); + pspec = g_param_spec_string("codename", + "Codename", + _("Codename"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_NAME, pspec); /** * OsinfoProduct:logo: * * The URI of the logo of the product. */ - pspec = g_param_spec_string ("logo", - "Logo", - _("URI of the logo"), - NULL /* default value */, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, PROP_LOGO, pspec); + pspec = g_param_spec_string("logo", + "Logo", + _("URI of the logo"), + NULL /* default value */, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_LOGO, pspec); } static void -osinfo_product_init (OsinfoProduct *product) +osinfo_product_init(OsinfoProduct *product) { product->priv = OSINFO_PRODUCT_GET_PRIVATE(product); product->priv->productLinks = NULL; @@ -342,7 +342,7 @@ static GDate *date_from_string(const gchar *str) m = strtoll(tmp+1, NULL, 10); tmp = strchr(tmp+1, '-'); d = strtoll(tmp+1, NULL, 10); - return g_date_new_dmy(d,m,y); + return g_date_new_dmy(d, m, y); } GDate *osinfo_product_get_release_date(OsinfoProduct *prod) @@ -436,7 +436,7 @@ void osinfo_product_foreach_related(OsinfoProduct *product, foreach_func, user_data); } - g_object_unref (related_list); + g_object_unref(related_list); } /* diff --git a/osinfo/osinfo_productfilter.c b/osinfo/osinfo_productfilter.c index 435a202..9dbffa2 100644 --- a/osinfo/osinfo_productfilter.c +++ b/osinfo/osinfo_productfilter.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoProductFilter, osinfo_productfilter, OSINFO_TYPE_FILTER); +G_DEFINE_TYPE(OsinfoProductFilter, osinfo_productfilter, OSINFO_TYPE_FILTER); -#define OSINFO_PRODUCTFILTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_PRODUCTFILTER, OsinfoProductFilterPrivate)) +#define OSINFO_PRODUCTFILTER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_PRODUCTFILTER, OsinfoProductFilterPrivate)) /** * SECTION:osinfo_productfilter @@ -52,29 +52,29 @@ struct _OsinfoProductFilterPrivate GDate *supportDate; }; -static void osinfo_productfilter_finalize (GObject *object); +static void osinfo_productfilter_finalize(GObject *object); static gboolean osinfo_productfilter_matches_default(OsinfoFilter *productfilter, OsinfoEntity *entity); static void -osinfo_productfilter_finalize (GObject *object) +osinfo_productfilter_finalize(GObject *object) { - OsinfoProductFilter *productfilter = OSINFO_PRODUCTFILTER (object); + OsinfoProductFilter *productfilter = OSINFO_PRODUCTFILTER(object); g_hash_table_unref(productfilter->priv->productConstraints); /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_productfilter_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_productfilter_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_productfilter_class_init (OsinfoProductFilterClass *klass) +osinfo_productfilter_class_init(OsinfoProductFilterClass *klass) { GObjectClass *g_klass = G_OBJECT_CLASS(klass); OsinfoFilterClass *filter_klass = OSINFO_FILTER_CLASS(klass); g_klass->finalize = osinfo_productfilter_finalize; - g_type_class_add_private (klass, sizeof (OsinfoProductFilterPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoProductFilterPrivate)); filter_klass->matches = osinfo_productfilter_matches_default; } @@ -108,7 +108,7 @@ osinfo_productfilter_product_constraints_free(gpointer relshps) } static void -osinfo_productfilter_init (OsinfoProductFilter *productfilter) +osinfo_productfilter_init(OsinfoProductFilter *productfilter) { productfilter->priv = OSINFO_PRODUCTFILTER_GET_PRIVATE(productfilter); productfilter->priv->productConstraints = @@ -240,7 +240,7 @@ static void osinfo_productfilter_match_product_iterator(gpointer key, gpointer v OsinfoProduct *currProduct = relProducts->data; int i; gboolean found = FALSE; - for (i = 0 ; i < osinfo_list_get_length(OSINFO_LIST(productlist)) ; i++) { + for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(productlist)); i++) { OsinfoProduct *testProduct = OSINFO_PRODUCT(osinfo_list_get_nth(OSINFO_LIST(productlist), i)); if (testProduct == currProduct) { found = TRUE; @@ -267,7 +267,7 @@ static gboolean osinfo_productfilter_matches_default(OsinfoFilter *filter, Osinf OsinfoProductFilter *productfilter = OSINFO_PRODUCTFILTER(filter); struct osinfo_productfilter_match_args args = { productfilter, entity, TRUE }; - if (!OSINFO_FILTER_CLASS (osinfo_productfilter_parent_class)->matches(filter, entity)) + if (!OSINFO_FILTER_CLASS(osinfo_productfilter_parent_class)->matches(filter, entity)) return FALSE; g_hash_table_foreach(productfilter->priv->productConstraints, diff --git a/osinfo/osinfo_productlist.c b/osinfo/osinfo_productlist.c index b166403..6e29357 100644 --- a/osinfo/osinfo_productlist.c +++ b/osinfo/osinfo_productlist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoProductList, osinfo_productlist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoProductList, osinfo_productlist, OSINFO_TYPE_LIST); -#define OSINFO_PRODUCTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_PRODUCTLIST, OsinfoProductListPrivate)) +#define OSINFO_PRODUCTLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_PRODUCTLIST, OsinfoProductListPrivate)) /** * SECTION:osinfo_productlist @@ -46,24 +46,24 @@ struct _OsinfoProductListPrivate }; static void -osinfo_productlist_finalize (GObject *object) +osinfo_productlist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_productlist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_productlist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_productlist_class_init (OsinfoProductListClass *klass) +osinfo_productlist_class_init(OsinfoProductListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_productlist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoProductListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoProductListPrivate)); } static void -osinfo_productlist_init (OsinfoProductList *list) +osinfo_productlist_init(OsinfoProductList *list) { list->priv = OSINFO_PRODUCTLIST_GET_PRIVATE(list); } diff --git a/osinfo/osinfo_resources.c b/osinfo/osinfo_resources.c index 9f12055..8c116fa 100644 --- a/osinfo/osinfo_resources.c +++ b/osinfo/osinfo_resources.c @@ -1,7 +1,7 @@ /* * libosinfo: Required or recommended resources for an (guest) OS * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,7 +31,7 @@ #include #include -G_DEFINE_TYPE (OsinfoResources, osinfo_resources, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoResources, osinfo_resources, OSINFO_TYPE_ENTITY); enum { PROP_0, @@ -44,9 +44,9 @@ enum { }; #define OSINFO_RESOURCES_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ - OSINFO_TYPE_RESOURCES, \ - OsinfoResourcesPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + OSINFO_TYPE_RESOURCES, \ + OsinfoResourcesPrivate)) /** * SECTION:osinfo_resources @@ -63,49 +63,49 @@ struct _OsinfoResourcesPrivate }; static void -osinfo_resources_finalize (GObject *object) +osinfo_resources_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_resources_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_resources_parent_class)->finalize(object); } static void -osinfo_resources_get_property (GObject *object, +osinfo_resources_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - OsinfoResources *resources = OSINFO_RESOURCES (object); + OsinfoResources *resources = OSINFO_RESOURCES(object); switch (property_id) { case PROP_ARCHITECTURE: - g_value_set_string (value, - osinfo_resources_get_architecture (resources)); + g_value_set_string(value, + osinfo_resources_get_architecture(resources)); break; case PROP_N_CPUS: - g_value_set_int (value, - osinfo_resources_get_n_cpus (resources)); + g_value_set_int(value, + osinfo_resources_get_n_cpus(resources)); break; case PROP_CPU: - g_value_set_int64 (value, - osinfo_resources_get_cpu (resources)); + g_value_set_int64(value, + osinfo_resources_get_cpu(resources)); break; case PROP_RAM: - g_value_set_int64 (value, - osinfo_resources_get_ram (resources)); + g_value_set_int64(value, + osinfo_resources_get_ram(resources)); break; case PROP_STORAGE: - g_value_set_int64 (value, - osinfo_resources_get_storage (resources)); + g_value_set_int64(value, + osinfo_resources_get_storage(resources)); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } @@ -116,137 +116,137 @@ osinfo_resources_set_property(GObject *object, const GValue *value, GParamSpec *pspec) { - OsinfoResources *resources = OSINFO_RESOURCES (object); + OsinfoResources *resources = OSINFO_RESOURCES(object); switch (property_id) { case PROP_ARCHITECTURE: - osinfo_entity_set_param (OSINFO_ENTITY(resources), - OSINFO_RESOURCES_PROP_ARCHITECTURE, - g_value_get_string (value)); + osinfo_entity_set_param(OSINFO_ENTITY(resources), + OSINFO_RESOURCES_PROP_ARCHITECTURE, + g_value_get_string(value)); break; case PROP_N_CPUS: - osinfo_resources_set_n_cpus (resources, g_value_get_int (value)); + osinfo_resources_set_n_cpus(resources, g_value_get_int(value)); break; case PROP_CPU: - osinfo_resources_set_cpu (resources, g_value_get_int64 (value)); + osinfo_resources_set_cpu(resources, g_value_get_int64(value)); break; case PROP_RAM: - osinfo_resources_set_ram (resources, g_value_get_int64 (value)); + osinfo_resources_set_ram(resources, g_value_get_int64(value)); break; case PROP_STORAGE: - osinfo_resources_set_storage (resources, g_value_get_int64 (value)); + osinfo_resources_set_storage(resources, g_value_get_int64(value)); break; default: /* We don't have any other property... */ - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; } } /* Init functions */ static void -osinfo_resources_class_init (OsinfoResourcesClass *klass) +osinfo_resources_class_init(OsinfoResourcesClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); GParamSpec *pspec; g_klass->get_property = osinfo_resources_get_property; g_klass->set_property = osinfo_resources_set_property; g_klass->finalize = osinfo_resources_finalize; - g_type_class_add_private (klass, sizeof (OsinfoResourcesPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoResourcesPrivate)); /** * OsinfoResources:architecture: * * The target hardware architecture to which these resources applies. */ - pspec = g_param_spec_string ("architecture", - "ARCHITECTURE", - _("CPU Architecture"), - NULL /* default value */, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, - PROP_ARCHITECTURE, - pspec); + pspec = g_param_spec_string("architecture", + "ARCHITECTURE", + _("CPU Architecture"), + NULL /* default value */, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, + PROP_ARCHITECTURE, + pspec); /** * OsinfoResources:cpu: * * The CPU frequency in hertz (Hz). */ - pspec = g_param_spec_int64 ("cpu", - "CPU", - _("CPU frequency in hertz (Hz)"), - -1, - G_MAXINT, - -1, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, - PROP_CPU, - pspec); + pspec = g_param_spec_int64("cpu", + "CPU", + _("CPU frequency in hertz (Hz)"), + -1, + G_MAXINT, + -1, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, + PROP_CPU, + pspec); /** * OsinfoResources:n-cpus: * * The number of CPUs. */ - pspec = g_param_spec_int ("n-cpus", - "N-CPUs", - _("Number of CPUs"), - -1, - G_MAXINT, - -1, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, - PROP_N_CPUS, - pspec); + pspec = g_param_spec_int("n-cpus", + "N-CPUs", + _("Number of CPUs"), + -1, + G_MAXINT, + -1, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, + PROP_N_CPUS, + pspec); /** * OsinfoResources:ram: * * The amount of Random Access Memory (RAM) in bytes. */ - pspec = g_param_spec_int64 ("ram", - "RAM", - _("Amount of Random Access Memory (RAM) in bytes"), - -1, - G_MAXINT64, - -1, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, - PROP_RAM, - pspec); + pspec = g_param_spec_int64("ram", + "RAM", + _("Amount of Random Access Memory (RAM) in bytes"), + -1, + G_MAXINT64, + -1, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, + PROP_RAM, + pspec); /** * OsinfoResources:storage: * * The amount of storage space in bytes. */ - pspec = g_param_spec_int64 ("storage", - "Storage", - _("Amount of storage space in bytes"), - -1, - G_MAXINT64, - -1, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (g_klass, + pspec = g_param_spec_int64("storage", + "Storage", + _("Amount of storage space in bytes"), + -1, + G_MAXINT64, + -1, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(g_klass, PROP_STORAGE, pspec); } static void -osinfo_resources_init (OsinfoResources *resources) +osinfo_resources_init(OsinfoResources *resources) { resources->priv = OSINFO_RESOURCES_GET_PRIVATE(resources); } @@ -256,10 +256,10 @@ OsinfoResources *osinfo_resources_new(const gchar *id, { OsinfoResources *resources; - resources = g_object_new (OSINFO_TYPE_RESOURCES, - "id", id, - "architecture", architecture, - NULL); + resources = g_object_new(OSINFO_TYPE_RESOURCES, + "id", id, + "architecture", architecture, + NULL); return resources; } diff --git a/osinfo/osinfo_resourceslist.c b/osinfo/osinfo_resourceslist.c index 057d4a4..a9d3737 100644 --- a/osinfo/osinfo_resourceslist.c +++ b/osinfo/osinfo_resourceslist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoResourcesList, osinfo_resourceslist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoResourcesList, osinfo_resourceslist, OSINFO_TYPE_LIST); -#define OSINFO_RESOURCESLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ +#define OSINFO_RESOURCESLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ OSINFO_TYPE_RESOURCESLIST, \ OsinfoResourcesListPrivate)) @@ -48,24 +48,24 @@ struct _OsinfoResourcesListPrivate }; static void -osinfo_resourceslist_finalize (GObject *object) +osinfo_resourceslist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_resourceslist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_resourceslist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_resourceslist_class_init (OsinfoResourcesListClass *klass) +osinfo_resourceslist_class_init(OsinfoResourcesListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_resourceslist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoResourcesListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoResourcesListPrivate)); } static void -osinfo_resourceslist_init (OsinfoResourcesList *list) +osinfo_resourceslist_init(OsinfoResourcesList *list) { list->priv = OSINFO_RESOURCESLIST_GET_PRIVATE(list); diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c index b4dad63..55c572e 100644 --- a/osinfo/osinfo_tree.c +++ b/osinfo/osinfo_tree.c @@ -1,7 +1,7 @@ /* * libosinfo: An installation tree for a (guest) OS * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -71,20 +71,20 @@ static void create_from_location_data_free(CreateFromLocationData *data) } GQuark -osinfo_tree_error_quark (void) +osinfo_tree_error_quark(void) { static GQuark quark = 0; if (!quark) - quark = g_quark_from_static_string ("osinfo-tree-error"); + quark = g_quark_from_static_string("osinfo-tree-error"); return quark; } -G_DEFINE_TYPE (OsinfoTree, osinfo_tree, OSINFO_TYPE_ENTITY); +G_DEFINE_TYPE(OsinfoTree, osinfo_tree, OSINFO_TYPE_ENTITY); #define OSINFO_TREE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ OSINFO_TYPE_TREE, \ OsinfoTreePrivate)) @@ -622,7 +622,7 @@ static void on_location_read(GObject *source, g_simple_async_result_set_op_res_gpointer(data->res, ret, NULL); cleanup: - g_simple_async_result_complete (data->res); + g_simple_async_result_complete(data->res); create_from_location_async_data_free(data); g_free(content); } diff --git a/osinfo/osinfo_treelist.c b/osinfo/osinfo_treelist.c index 45410df..01952f7 100644 --- a/osinfo/osinfo_treelist.c +++ b/osinfo/osinfo_treelist.c @@ -1,7 +1,7 @@ /* * libosinfo: * - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2012, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ #include #include -G_DEFINE_TYPE (OsinfoTreeList, osinfo_treelist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoTreeList, osinfo_treelist, OSINFO_TYPE_LIST); -#define OSINFO_TREELIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_TREELIST, OsinfoTreeListPrivate)) +#define OSINFO_TREELIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_TREELIST, OsinfoTreeListPrivate)) /** * SECTION:osinfo_treelist @@ -46,24 +46,24 @@ struct _OsinfoTreeListPrivate }; static void -osinfo_treelist_finalize (GObject *object) +osinfo_treelist_finalize(GObject *object) { /* Chain up to the parent class */ - G_OBJECT_CLASS (osinfo_treelist_parent_class)->finalize (object); + G_OBJECT_CLASS(osinfo_treelist_parent_class)->finalize(object); } /* Init functions */ static void -osinfo_treelist_class_init (OsinfoTreeListClass *klass) +osinfo_treelist_class_init(OsinfoTreeListClass *klass) { - GObjectClass *g_klass = G_OBJECT_CLASS (klass); + GObjectClass *g_klass = G_OBJECT_CLASS(klass); g_klass->finalize = osinfo_treelist_finalize; - g_type_class_add_private (klass, sizeof (OsinfoTreeListPrivate)); + g_type_class_add_private(klass, sizeof(OsinfoTreeListPrivate)); } static void -osinfo_treelist_init (OsinfoTreeList *list) +osinfo_treelist_init(OsinfoTreeList *list) { list->priv = OSINFO_TREELIST_GET_PRIVATE(list); } @@ -112,7 +112,7 @@ OsinfoTreeList *osinfo_treelist_new_copy(OsinfoTreeList *source) * Deprecated: 0.2.2: Use osinfo_list_new_filtered() instead. */ OsinfoTreeList *osinfo_treelist_new_filtered(OsinfoTreeList *source, - OsinfoFilter *filter) + OsinfoFilter *filter) { OsinfoTreeList *newList = osinfo_treelist_new(); osinfo_list_add_filtered(OSINFO_LIST(newList), @@ -133,7 +133,7 @@ OsinfoTreeList *osinfo_treelist_new_filtered(OsinfoTreeList *source, * Deprecated: 0.2.2: Use osinfo_list_new_intersection() instead. */ OsinfoTreeList *osinfo_treelist_new_intersection(OsinfoTreeList *sourceOne, - OsinfoTreeList *sourceTwo) + OsinfoTreeList *sourceTwo) { OsinfoTreeList *newList = osinfo_treelist_new(); osinfo_list_add_intersection(OSINFO_LIST(newList), -- 1.9.3 From gscrivan at redhat.com Wed Jun 4 09:50:57 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 4 Jun 2014 11:50:57 +0200 Subject: [Libosinfo] [PATCH 5/5] enforce bracket spacing with a syntax rule In-Reply-To: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Message-ID: <1401875457-21439-6-git-send-email-gscrivan@redhat.com> The build-aux/bracket-spacing.pl script was copied from libvirt. Signed-off-by: Giuseppe Scrivano --- build-aux/bracket-spacing.pl | 162 +++++++++++++++++++++++++++++++++++++++++++ cfg.mk | 6 ++ 2 files changed, 168 insertions(+) create mode 100755 build-aux/bracket-spacing.pl diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl new file mode 100755 index 0000000..e4ae8f0 --- /dev/null +++ b/build-aux/bracket-spacing.pl @@ -0,0 +1,162 @@ +#!/usr/bin/perl +# +# bracket-spacing.pl: Report any usage of 'function (..args..)' +# Also check for other syntax issues, such as correct use of ';' +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see +# . +# +# Authors: +# Daniel P. Berrange + +use strict; +use warnings; + +my $ret = 0; +my $incomment = 0; + +foreach my $file (@ARGV) { + open FILE, $file; + + while (defined (my $line = )) { + my $data = $line; + + # Kill any quoted , ; or " + $data =~ s/'[";,]'/'X'/g; + + # Kill any quoted strings + $data =~ s,"([^\\\"]|\\.)*","XXX",g; + + # Kill any C++ style comments + $data =~ s,//.*$,//,; + + next if $data =~ /^#/; + + # Kill contents of multi-line comments + # and detect end of multi-line comments + if ($incomment) { + if ($data =~ m,\*/,) { + $incomment = 0; + $data =~ s,^.*\*/,*/,; + } else { + $data = ""; + } + } + + # Kill single line comments, and detect + # start of multi-line comments + if ($data =~ m,/\*.*\*/,) { + $data =~ s,/\*.*\*/,/* */,; + } elsif ($data =~ m,/\*,) { + $incomment = 1; + $data =~ s,/\*.*,/*,; + } + + # We need to match things like + # + # int foo (int bar, bool wizz); + # foo (bar, wizz); + # + # but not match things like: + # + # typedef int (*foo)(bar wizz) + # + # we can't do this (efficiently) without + # missing things like + # + # foo (*bar, wizz); + # + while ($data =~ /(\w+)\s\((?!\*)/) { + my $kw = $1; + + # Allow space after keywords only + if ($kw =~ /^(if|for|while|switch|return)$/) { + $data =~ s/($kw\s\()/XXX(/; + } else { + print "$file:$.: $line"; + $ret = 1; + last; + } + } + + # Require whitespace immediately after keywords, + # but none after the opening bracket + while ($data =~ /\b(if|for|while|switch|return)\(/ || + $data =~ /\b(if|for|while|switch|return)\s+\(\s/) { + print "$file:$.: $line"; + $ret = 1; + last; + } + + # Forbid whitespace between )( of a function typedef + while ($data =~ /\(\*\w+\)\s+\(/) { + print "$file:$.: $line"; + $ret = 1; + last; + } + + # Forbid whitespace following ( or prior to ) + while ($data =~ /\S\s+\)/ || + $data =~ /\(\s+\S/) { + print "$file:$.: $line"; + $ret = 1; + last; + } + + # Forbid whitespace before ";" or ",". Things like below are allowed: + # + # 1) The expression is empty for "for" loop. E.g. + # for (i = 0; ; i++) + # + # 2) An empty statement. E.g. + # while (write(statuswrite, &status, 1) == -1 && + # errno == EINTR) + # ; + # + while ($data =~ /[^;\s]\s+[;,]/) { + print "$file:$.: $line"; + $ret = 1; + last; + } + + # Require EOL, macro line continuation, or whitespace after ";". + # Allow "for (;;)" as an exception. + while ($data =~ /;[^ \\\n;)]/) { + print "$file:$.: $line"; + $ret = 1; + last; + } + + # Require EOL, space, or enum/struct end after comma. + while ($data =~ /,[^ \\\n)}]/) { + print "$file:$.: $line"; + $ret = 1; + last; + } + + # Require spaces around assignment '=', compounds and '==' + # with the exception of virAssertCmpInt() + while ($data =~ /[^!<>&|\-+*\/%\^'= ]=\+[^=]/ || + $data =~ /[^!<>&|\-+*\/%\^'=]=[^= \\\n]/ || + $data =~ /[\S]==/ || + ($data =~ /==[^\s,]/ && $data !~ /[\s]virAssertCmpInt\(/)) { + print "$file:$.: $line"; + $ret = 1; + last; + } + } + close FILE; +} + +exit $ret; diff --git a/cfg.mk b/cfg.mk index 36b000f..c2f07e0 100644 --- a/cfg.mk +++ b/cfg.mk @@ -110,6 +110,12 @@ sc_copyright_format: halt='spell Red Hat as two words' \ $(_sc_search_regexp) +sc_bracket_spacing_check: + $(AM_V_GEN)files=`$(VC_LIST) | grep '\.c$$'`; \ + $(PERL) $(top_srcdir)/build-aux/bracket-spacing.pl $$files || \ + { echo '$(ME): incorrect whitespace' 1>&2; \ + exit 1; } + # We don't use this feature of maint.mk. prev_version_file = /dev/null -- 1.9.3 From gscrivan at redhat.com Wed Jun 4 09:53:34 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 04 Jun 2014 11:53:34 +0200 Subject: [Libosinfo] [PATCH v2 3/4] osinfo_loader: replace some xpath queries with direct data access In-Reply-To: <538E161B.4070505@redhat.com> (Eric Blake's message of "Tue, 03 Jun 2014 12:38:19 -0600") References: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> <1401819544-24381-4-git-send-email-gscrivan@redhat.com> <538E161B.4070505@redhat.com> Message-ID: <877g4x3srl.fsf@redhat.com> Eric Blake writes: > On 06/03/2014 12:19 PM, Giuseppe Scrivano wrote: >> Signed-off-by: Giuseppe Scrivano >> --- > >> - for (i = 0 ; i < nrelated ; i++) { >> - gchar *id = (gchar *)xmlGetProp(related[i], BAD_CAST "id"); >> + for(it = root->children; it; it = it->next) { > > Style nit - isn't there supposed to be a space after 'for' ? thanks to have catched it. Fixed in my local version. I was hoping for "make syntax-check" to catch this kind of errors, but the rule wasn't there. This should help in future: https://www.redhat.com/archives/libosinfo/2014-June/msg00025.html Regards, Giuseppe From cfergeau at redhat.com Wed Jun 4 10:04:15 2014 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 4 Jun 2014 12:04:15 +0200 Subject: [Libosinfo] [PATCH 1/5] osinfo_loader: don't wrap return value with parentheses In-Reply-To: <1401875457-21439-2-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> <1401875457-21439-2-git-send-email-gscrivan@redhat.com> Message-ID: <20140604100415.GU27464@edamame.cdg.redhat.com> ACK On Wed, Jun 04, 2014 at 11:50:53AM +0200, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > osinfo/osinfo_loader.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c > index aa5e48f..685352b 100644 > --- a/osinfo/osinfo_loader.c > +++ b/osinfo/osinfo_loader.c > @@ -138,16 +138,16 @@ osinfo_loader_nodeset(const char *xpath, > obj = xmlXPathEval(BAD_CAST xpath, ctxt); > ctxt->node = relnode; > if (obj == NULL) > - return(0); > + return 0; > if (obj->type != XPATH_NODESET) { > g_set_error(err, g_quark_from_static_string("libosinfo"), 0, > _("Expected a nodeset in XPath query %s"), xpath); > xmlXPathFreeObject(obj); > - return (-1); > + return -1; > } > if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr < 0)) { > xmlXPathFreeObject(obj); > - return (0); > + return 0; > } > > ret = obj->nodesetval->nodeNr; > @@ -157,7 +157,7 @@ osinfo_loader_nodeset(const char *xpath, > ret * sizeof(xmlNodePtr)); > } > xmlXPathFreeObject(obj); > - return (ret); > + return ret; > } > > static gchar * > -- > 1.9.3 > > _______________________________________________ > Libosinfo mailing list > Libosinfo at redhat.com > https://www.redhat.com/mailman/listinfo/libosinfo -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From cfergeau at redhat.com Wed Jun 4 10:07:03 2014 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 4 Jun 2014 12:07:03 +0200 Subject: [Libosinfo] [PATCH 0/5] fix bracket spacing In-Reply-To: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Message-ID: <20140604100703.GV27464@edamame.cdg.redhat.com> Hey, Thanks for doing that! Regarding space/no space before '(', libosinfo is indeed inconsistent. I was under the impression that we are meant to be using space before '(' (ie the opposite of what your patch does). As a matter of personal preference, I prefer no space, don't know what others think. Christophe On Wed, Jun 04, 2014 at 11:50:52AM +0200, Giuseppe Scrivano wrote: > Fix bracket spacing and enforce it with a new syntax rule (copied from > libvirt). > > Giuseppe Scrivano (5): > osinfo_loader: don't wrap return value with parentheses > test: fix spacing to satisfy sc_bracket_spacing_check > tools: fix spacing to satisfy sc_bracket_spacing_check > osinfo: fix spacing to satisfy sc_bracket_spacing_check > enforce bracket spacing with a syntax rule > > build-aux/bracket-spacing.pl | 162 +++++++++++++ > cfg.mk | 6 + > osinfo/osinfo_avatar_format.c | 16 +- > osinfo/osinfo_datamap.c | 18 +- > osinfo/osinfo_datamaplist.c | 18 +- > osinfo/osinfo_db.c | 48 ++-- > osinfo/osinfo_deployment.c | 28 +-- > osinfo/osinfo_deploymentlist.c | 18 +- > osinfo/osinfo_device.c | 20 +- > osinfo/osinfo_device_driver.c | 28 +-- > osinfo/osinfo_device_driverlist.c | 18 +- > osinfo/osinfo_devicelink.c | 24 +- > osinfo/osinfo_devicelinkfilter.c | 26 +-- > osinfo/osinfo_devicelinklist.c | 20 +- > osinfo/osinfo_devicelist.c | 18 +- > osinfo/osinfo_entity.c | 44 ++-- > osinfo/osinfo_filter.c | 22 +- > osinfo/osinfo_install_config.c | 14 +- > osinfo/osinfo_install_config_param.c | 24 +- > osinfo/osinfo_install_config_paramlist.c | 18 +- > osinfo/osinfo_install_script.c | 28 +-- > osinfo/osinfo_install_scriptlist.c | 18 +- > osinfo/osinfo_list.c | 24 +- > osinfo/osinfo_loader.c | 116 +++++----- > osinfo/osinfo_media.c | 382 +++++++++++++++---------------- > osinfo/osinfo_medialist.c | 18 +- > osinfo/osinfo_os.c | 84 +++---- > osinfo/osinfo_os_variant.c | 48 ++-- > osinfo/osinfo_os_variantlist.c | 12 +- > osinfo/osinfo_oslist.c | 18 +- > osinfo/osinfo_platform.c | 20 +- > osinfo/osinfo_platformlist.c | 18 +- > osinfo/osinfo_product.c | 138 +++++------ > osinfo/osinfo_productfilter.c | 24 +- > osinfo/osinfo_productlist.c | 18 +- > osinfo/osinfo_resources.c | 178 +++++++------- > osinfo/osinfo_resourceslist.c | 18 +- > osinfo/osinfo_tree.c | 12 +- > osinfo/osinfo_treelist.c | 22 +- > test/test-db.c | 18 +- > test/test-device.c | 12 +- > test/test-devicelist.c | 18 +- > test/test-entity.c | 16 +- > test/test-filter.c | 12 +- > test/test-install-script.c | 24 +- > test/test-isodetect.c | 12 +- > test/test-list.c | 26 +-- > test/test-loader.c | 12 +- > test/test-mediauris.c | 18 +- > test/test-os.c | 12 +- > test/test-oslist.c | 18 +- > test/test-platform.c | 14 +- > test/test-platformlist.c | 18 +- > test/test-product.c | 16 +- > test/test-productfilter.c | 16 +- > test/test-treeuris.c | 18 +- > tools/osinfo-db-validate.c | 8 +- > tools/osinfo-detect.c | 14 +- > tools/osinfo-install-script.c | 8 +- > tools/osinfo-query.c | 24 +- > 60 files changed, 1144 insertions(+), 976 deletions(-) > create mode 100755 build-aux/bracket-spacing.pl > > -- > 1.9.3 > > _______________________________________________ > Libosinfo mailing list > Libosinfo at redhat.com > https://www.redhat.com/mailman/listinfo/libosinfo -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From berrange at redhat.com Wed Jun 4 10:09:26 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Wed, 4 Jun 2014 11:09:26 +0100 Subject: [Libosinfo] [PATCH 0/5] fix bracket spacing In-Reply-To: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> Message-ID: <20140604100926.GC32284@redhat.com> On Wed, Jun 04, 2014 at 11:50:52AM +0200, Giuseppe Scrivano wrote: > Fix bracket spacing and enforce it with a new syntax rule (copied from > libvirt). > > Giuseppe Scrivano (5): > osinfo_loader: don't wrap return value with parentheses > test: fix spacing to satisfy sc_bracket_spacing_check > tools: fix spacing to satisfy sc_bracket_spacing_check > osinfo: fix spacing to satisfy sc_bracket_spacing_check > enforce bracket spacing with a syntax rule ACK to all patches since it matches libvirt rules which I obviously agree with :-) Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Wed Jun 4 10:10:50 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Wed, 4 Jun 2014 11:10:50 +0100 Subject: [Libosinfo] [PATCH 0/5] fix bracket spacing In-Reply-To: <20140604100703.GV27464@edamame.cdg.redhat.com> References: <1401875457-21439-1-git-send-email-gscrivan@redhat.com> <20140604100703.GV27464@edamame.cdg.redhat.com> Message-ID: <20140604101050.GD32284@redhat.com> On Wed, Jun 04, 2014 at 12:07:03PM +0200, Christophe Fergeau wrote: > Hey, > > Thanks for doing that! Regarding space/no space before '(', libosinfo is > indeed inconsistent. I was under the impression that we are meant to be > using space before '(' (ie the opposite of what your patch does). > As a matter of personal preference, I prefer no space, don't know what > others think. GNOME coding style is to have space before '(' Libvirt coding style is to have no space before '(' I prefer that we follow libvirt style, so no space :-) Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From gscrivan at redhat.com Wed Jun 4 10:18:02 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 04 Jun 2014 12:18:02 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140604083815.GQ27464@edamame.cdg.redhat.com> (Christophe Fergeau's message of "Wed, 4 Jun 2014 10:38:15 +0200") References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> Message-ID: <8738fl3rmt.fsf@redhat.com> Christophe Fergeau writes: > On Tue, Jun 03, 2014 at 06:52:47PM +0200, Giuseppe Scrivano wrote: >> Christophe Fergeau writes: >> > The call to osinfo_loader_get_device() can also hide a g_object_new(), >> > which can be heavy. >> >> indeed, g_object_new seems to be very slow. I will try to play with >> what Daniel suggested and see if it makes any difference. > > Some profiling should tell you if the expensive part is the object > creation or the hash table insertion, and how much slower one is > compared to the ohter. Did you get these numbers by any chance? for my tests I've used a simple C program statically linked to libosinfo (compiled with -O0): #include int main() { GError *error; OsinfoLoader *loader = osinfo_loader_new(); osinfo_loader_process_default_path(loader, &error); OsinfoDb *db = osinfo_loader_get_db(loader); osinfo_db_get_os_list(db); return 0; } This series was applied to the libosinfo source. function total time spent in the function osinfo_loader_get_device 32.83% osinfo_db_get_device 2.96% osinfo_db_add_device 4.50% osinfo_db_new 24.97% so creating a new GObject is very slow. I thought about creating just a model object and then clone it instead of going trough the gobject constructors for every instance. Does it sound like a good idea? (I am not still sure if g_type_create_instance will be enough to achieve this, haven't looked into details). Regards, Giuseppe From gscrivan at redhat.com Wed Jun 4 10:28:39 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 04 Jun 2014 12:28:39 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <8738fl3rmt.fsf@redhat.com> (Giuseppe Scrivano's message of "Wed, 04 Jun 2014 12:18:02 +0200") References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> Message-ID: <87wqcx2cko.fsf@redhat.com> Giuseppe Scrivano writes: > This series was applied to the libosinfo source. > > function total time spent in the function > > osinfo_loader_get_device 32.83% > osinfo_db_get_device 2.96% > osinfo_db_add_device 4.50% > osinfo_db_new 24.97% I forgot to say that I've used callgrind to get these numbers. Regards, Giuseppe From berrange at redhat.com Wed Jun 4 10:30:44 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Wed, 4 Jun 2014 11:30:44 +0100 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <8738fl3rmt.fsf@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> Message-ID: <20140604103044.GF32284@redhat.com> On Wed, Jun 04, 2014 at 12:18:02PM +0200, Giuseppe Scrivano wrote: > Christophe Fergeau writes: > > > On Tue, Jun 03, 2014 at 06:52:47PM +0200, Giuseppe Scrivano wrote: > >> Christophe Fergeau writes: > >> > The call to osinfo_loader_get_device() can also hide a g_object_new(), > >> > which can be heavy. > >> > >> indeed, g_object_new seems to be very slow. I will try to play with > >> what Daniel suggested and see if it makes any difference. > > > > Some profiling should tell you if the expensive part is the object > > creation or the hash table insertion, and how much slower one is > > compared to the ohter. Did you get these numbers by any chance? > > for my tests I've used a simple C program statically linked to > libosinfo (compiled with -O0): > > #include > > int main() > { > GError *error; > OsinfoLoader *loader = osinfo_loader_new(); > osinfo_loader_process_default_path(loader, &error); > > OsinfoDb *db = osinfo_loader_get_db(loader); > osinfo_db_get_os_list(db); > return 0; > } > > This series was applied to the libosinfo source. > > function total time spent in the function > > osinfo_loader_get_device 32.83% > osinfo_db_get_device 2.96% > osinfo_db_add_device 4.50% > osinfo_db_new 24.97% > > so creating a new GObject is very slow. I thought about creating just a > model object and then clone it instead of going trough the gobject > constructors for every instance. Does it sound like a good idea? (I am > not still sure if g_type_create_instance will be enough to achieve this, > haven't looked into details). What's the actual wallclock time this demo takes to run for you ? For me it is a fraction of a second, which seems pretty fast and shouldn't be noticable by the user. $ time ./demo real 0m0.238s user 0m0.218s sys 0m0.014s Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From gscrivan at redhat.com Wed Jun 4 10:44:07 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 04 Jun 2014 12:44:07 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140604103044.GF32284@redhat.com> (Daniel P. Berrange's message of "Wed, 4 Jun 2014 11:30:44 +0100") References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> <20140604103044.GF32284@redhat.com> Message-ID: <87sinl2buw.fsf@redhat.com> "Daniel P. Berrange" writes: >> This series was applied to the libosinfo source. >> >> function total time spent in the function >> >> osinfo_loader_get_device 32.83% >> osinfo_db_get_device 2.96% >> osinfo_db_add_device 4.50% >> osinfo_db_new 24.97% >> >> so creating a new GObject is very slow. I thought about creating just a >> model object and then clone it instead of going trough the gobject >> constructors for every instance. Does it sound like a good idea? (I am >> not still sure if g_type_create_instance will be enough to achieve this, >> haven't looked into details). > > What's the actual wallclock time this demo takes to run for you ? > > For me it is a fraction of a second, which seems pretty fast and shouldn't > be noticable by the user. > > $ time ./demo > > real 0m0.238s > user 0m0.218s > sys 0m0.014s It takes approximately the same time for me as well. Indeed, it is not much time but it seems noticeable in the upstream version of virt-manager, where the UI seems a bit slower compared to older versions without libosinfo when the data is accessed for the first time and I preferred to optimize this in libosinfo instead of a workaround in virt-manager. Anyway, this series cuts enough wallclock time that this effect is much less noticeable now that shouldn't be a problem for virt-manager users too. Regards, Giuseppe From berrange at redhat.com Wed Jun 4 11:18:47 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Wed, 4 Jun 2014 12:18:47 +0100 Subject: [Libosinfo] [PATCH v2 2/4] osinfo_loader: introduce a compiled xpaths cache In-Reply-To: <1401819544-24381-3-git-send-email-gscrivan@redhat.com> References: <1401819544-24381-1-git-send-email-gscrivan@redhat.com> <1401819544-24381-3-git-send-email-gscrivan@redhat.com> Message-ID: <20140604111847.GG32284@redhat.com> On Tue, Jun 03, 2014 at 08:19:02PM +0200, Giuseppe Scrivano wrote: > Signed-off-by: Giuseppe Scrivano > --- > osinfo/osinfo_loader.c | 124 ++++++++++++++++++++++++++++++++++--------------- > 1 file changed, 87 insertions(+), 37 deletions(-) > > static int > osinfo_loader_nodeset(const char *xpath, > + OsinfoLoader *loader, > xmlXPathContextPtr ctxt, > xmlNodePtr **list, > GError **err) > @@ -127,15 +152,19 @@ osinfo_loader_nodeset(const char *xpath, > xmlXPathObjectPtr obj; > xmlNodePtr relnode; > int ret; > + xmlXPathCompExprPtr comp; > > g_return_val_if_fail(ctxt != NULL, -1); > g_return_val_if_fail(xpath != NULL, -1); > + g_return_val_if_fail(loader != NULL, NULL); s/NULL/-1/ ACK with the fix Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Wed Jun 4 11:24:32 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Wed, 4 Jun 2014 12:24:32 +0100 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <87sinl2buw.fsf@redhat.com> References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> <20140604103044.GF32284@redhat.com> <87sinl2buw.fsf@redhat.com> Message-ID: <20140604112432.GH32284@redhat.com> On Wed, Jun 04, 2014 at 12:44:07PM +0200, Giuseppe Scrivano wrote: > "Daniel P. Berrange" writes: > > >> This series was applied to the libosinfo source. > >> > >> function total time spent in the function > >> > >> osinfo_loader_get_device 32.83% > >> osinfo_db_get_device 2.96% > >> osinfo_db_add_device 4.50% > >> osinfo_db_new 24.97% > >> > >> so creating a new GObject is very slow. I thought about creating just a > >> model object and then clone it instead of going trough the gobject > >> constructors for every instance. Does it sound like a good idea? (I am > >> not still sure if g_type_create_instance will be enough to achieve this, > >> haven't looked into details). > > > > What's the actual wallclock time this demo takes to run for you ? > > > > For me it is a fraction of a second, which seems pretty fast and shouldn't > > be noticable by the user. > > > > $ time ./demo > > > > real 0m0.238s > > user 0m0.218s > > sys 0m0.014s > > It takes approximately the same time for me as well. Indeed, it is not > much time but it seems noticeable in the upstream version of > virt-manager, where the UI seems a bit slower compared to older versions > without libosinfo when the data is accessed for the first time and I > preferred to optimize this in libosinfo instead of a workaround in > virt-manager. > Anyway, this series cuts enough wallclock time that this effect is much > less noticeable now that shouldn't be a problem for virt-manager users > too. FYI before applying this series, oprofile reports 489780 100.000 demo CPU_CLK_UNHALT...| samples| %| ------------------ 173292 35.3816 libc-2.18.so 94375 19.2689 libxml2.so.2.9.1 90366 18.4503 libglib-2.0.so.0.4000.0 50390 10.2883 libgobject-2.0.so.0.4000.0 29642 6.0521 libosinfo-1.0.so.0.2.10 24293 4.9600 no-vmlinux 16796 3.4293 libgio-2.0.so.0.4000.0 10554 2.1548 libpthread-2.18.so 37 0.0076 ld-2.18.so 35 0.0071 [vdso] (tgid:23223 range:0x7fff939fe000-0x7fff939fffff) After applying it we get 355391 100.000 demo CPU_CLK_UNHALT...| samples| %| ------------------ 106098 29.8539 libc-2.18.so 88024 24.7682 libglib-2.0.so.0.4000.0 51930 14.6121 libgobject-2.0.so.0.4000.0 29712 8.3604 libosinfo-1.0.so.0.2.10 26496 7.4555 libxml2.so.2.9.1 25416 7.1516 no-vmlinux 17085 4.8074 libgio-2.0.so.0.4000.0 10546 2.9674 libpthread-2.18.so 45 0.0127 [vdso] (tgid:31109 range:0x7ffffb3e9000-0x7ffffb3eafff) 37 0.0104 ld-2.18.so 1 2.8e-04 demo 1 2.8e-04 libpng16.so.16.6.0 So we've clearly improved the XML parsing by a large degree. Looking at the per-symbol breakdown now we see Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (No unit mask) count 90000 samples % image name symbol name 25416 7.2170 no-vmlinux /no-vmlinux 24880 7.0648 libc-2.18.so _int_malloc 24609 6.9878 libc-2.18.so malloc 16643 4.7258 libc-2.18.so _int_free 12653 3.5929 libglib-2.0.so.0.4000.0 g_mutex_get_impl 12036 3.4177 libosinfo-1.0.so.0.2.10 osinfo_entity_get_type 10886 3.0911 libglib-2.0.so.0.4000.0 g_private_get_impl 9844 2.7952 libc-2.18.so vfprintf 9441 2.6808 libgobject-2.0.so.0.4000.0 g_type_value_table_peek 6839 1.9420 libglib-2.0.so.0.4000.0 g_hash_table_lookup 6695 1.9011 libglib-2.0.so.0.4000.0 g_str_hash 6213 1.7642 libglib-2.0.so.0.4000.0 g_hash_table_insert_internal 6193 1.7585 libgobject-2.0.so.0.4000.0 g_type_check_instance_is_a 5657 1.6063 libglib-2.0.so.0.4000.0 g_slice_alloc 5229 1.4848 libglib-2.0.so.0.4000.0 g_pointer_bit_unlock 4754 1.3499 libgio-2.0.so.0.4000.0 scan_for_newline 4685 1.3303 libglib-2.0.so.0.4000.0 g_datalist_id_set_data_full 4502 1.2784 libgobject-2.0.so.0.4000.0 g_type_check_instance_cast 3922 1.1137 libglib-2.0.so.0.4000.0 slab_allocator_alloc_chunk 3848 1.0927 libgio-2.0.so.0.4000.0 g_input_stream_get_type 3831 1.0878 libpthread-2.18.so pthread_mutex_lock 3671 1.0424 libpthread-2.18.so pthread_mutex_unlock 3520 0.9995 libosinfo-1.0.so.0.2.10 osinfo_device_get_type 3016 0.8564 libc-2.18.so malloc_consolidate 2773 0.7874 libglib-2.0.so.0.4000.0 g_pointer_bit_lock 2763 0.7846 libpthread-2.18.so pthread_getspecific 2654 0.7536 libc-2.18.so calloc 2593 0.7363 libc-2.18.so _IO_default_xsputn 2459 0.6982 libxml2.so.2.9.1 xmlXPathCompOpEval.part.59 2422 0.6877 libgobject-2.0.so.0.4000.0 g_type_class_ref 2350 0.6673 libc-2.18.so strlen 2269 0.6443 libc-2.18.so __memcpy_sse2_unaligned 2257 0.6409 libglib-2.0.so.0.4000.0 g_hash_table_insert_node 2115 0.6006 libc-2.18.so __GI___strcmp_ssse3 2091 0.5937 libglib-2.0.so.0.4000.0 g_datalist_id_dup_data 2029 0.5761 libgobject-2.0.so.0.4000.0 g_type_class_peek_static 1995 0.5665 libosinfo-1.0.so.0.2.10 osinfo_list_get_type 1967 0.5585 libosinfo-1.0.so.0.2.10 osinfo_db_get_type I believe that much of the libc malloc overhead comes from XML parsing still, but the g_str_hash function appearence does suggest it might be worth optimizing our hash table usage to use g_intern_string or GQuark so we can do plain pointer comparisons instead of strcmp. I'm surprised that osinfo_entity_get_type is soo high up there too. Perhaps we do need to optimize that so we don't call it so frequently during parsing. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From cfergeau at redhat.com Wed Jun 4 11:45:40 2014 From: cfergeau at redhat.com (Christophe Fergeau) Date: Wed, 4 Jun 2014 13:45:40 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140604112432.GH32284@redhat.com> References: <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> <20140604103044.GF32284@redhat.com> <87sinl2buw.fsf@redhat.com> <20140604112432.GH32284@redhat.com> Message-ID: <20140604114540.GW27464@edamame.cdg.redhat.com> On Wed, Jun 04, 2014 at 12:24:32PM +0100, Daniel P. Berrange wrote: > I'm surprised that osinfo_entity_get_type is soo high up there too. There will be at least one osinfo_entity_get_type() call every time we call OSINFO_ENTITY, OSINFO_IS_ENTITY, ... so this could come from that. I think compiling with -DG_DISABLE_CAST_CHECKS would turn these calls into noop, this could give an indication of how much we can improve things by removing some of these get_type() calls. Christophe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From gscrivan at redhat.com Wed Jun 4 11:50:30 2014 From: gscrivan at redhat.com (Giuseppe Scrivano) Date: Wed, 04 Jun 2014 13:50:30 +0200 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140604112432.GH32284@redhat.com> (Daniel P. Berrange's message of "Wed, 4 Jun 2014 12:24:32 +0100") References: <1401804492-11338-1-git-send-email-gscrivan@redhat.com> <20140603142454.GV4207@redhat.com> <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> <20140604103044.GF32284@redhat.com> <87sinl2buw.fsf@redhat.com> <20140604112432.GH32284@redhat.com> Message-ID: <874n003ncp.fsf@redhat.com> "Daniel P. Berrange" writes: > I'm surprised that osinfo_entity_get_type is soo high up there too. > Perhaps we do need to optimize that so we don't call it so frequently > during parsing. have you used this version of the series or v2? In v2 I've dropped the "osinfo_loader: avoid multiple calls to OSINFO_ENTITY" patch as it has not clear benefits on the wallclock but it reduces the calls to osinfo_entity_get_type. Callgrind says 273.345 calls vs 377.077, and it makes sense as we save 4 calls and it is iterated 25933 times. Should I reintroduce it? Regards, Giuseppe From berrange at redhat.com Wed Jun 4 11:52:31 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Wed, 4 Jun 2014 12:52:31 +0100 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <874n003ncp.fsf@redhat.com> References: <87sinm3v31.fsf@redhat.com> <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> <20140604103044.GF32284@redhat.com> <87sinl2buw.fsf@redhat.com> <20140604112432.GH32284@redhat.com> <874n003ncp.fsf@redhat.com> Message-ID: <20140604115231.GJ32284@redhat.com> On Wed, Jun 04, 2014 at 01:50:30PM +0200, Giuseppe Scrivano wrote: > "Daniel P. Berrange" writes: > > > I'm surprised that osinfo_entity_get_type is soo high up there too. > > Perhaps we do need to optimize that so we don't call it so frequently > > during parsing. > > have you used this version of the series or v2? I used the v2 series. > In v2 I've dropped the "osinfo_loader: avoid multiple calls to > OSINFO_ENTITY" patch as it has not clear benefits on the wallclock but > it reduces the calls to osinfo_entity_get_type. > Callgrind says 273.345 calls vs 377.077, and it makes sense as we save 4 > calls and it is iterated 25933 times. Should I reintroduce it? Let me re-test with it and report back Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From berrange at redhat.com Wed Jun 4 11:57:20 2014 From: berrange at redhat.com (Daniel P. Berrange) Date: Wed, 4 Jun 2014 12:57:20 +0100 Subject: [Libosinfo] [RFC PATCH 0/5] various optimizations In-Reply-To: <20140604115231.GJ32284@redhat.com> References: <20140603145725.GY4207@redhat.com> <20140603150747.GJ27464@edamame.cdg.redhat.com> <87fvjm3pgg.fsf@redhat.com> <20140604083815.GQ27464@edamame.cdg.redhat.com> <8738fl3rmt.fsf@redhat.com> <20140604103044.GF32284@redhat.com> <87sinl2buw.fsf@redhat.com> <20140604112432.GH32284@redhat.com> <874n003ncp.fsf@redhat.com> <20140604115231.GJ32284@redhat.com> Message-ID: <20140604115720.GK32284@redhat.com> On Wed, Jun 04, 2014 at 12:52:31PM +0100, Daniel P. Berrange wrote: > On Wed, Jun 04, 2014 at 01:50:30PM +0200, Giuseppe Scrivano wrote: > > "Daniel P. Berrange" writes: > > > > > I'm surprised that osinfo_entity_get_type is soo high up there too. > > > Perhaps we do need to optimize that so we don't call it so frequently > > > during parsing. > > > > have you used this version of the series or v2? > > I used the v2 series. > > > In v2 I've dropped the "osinfo_loader: avoid multiple calls to > > OSINFO_ENTITY" patch as it has not clear benefits on the wallclock but > > it reduces the calls to osinfo_entity_get_type. > > Callgrind says 273.345 calls vs 377.077, and it makes sense as we save 4 > > calls and it is iterated 25933 times. Should I reintroduce it? > > Let me re-test with it and report back With that patch applied, we cut 1% off the count Without applied: samples % image name symbol name 12036 3.4177 libosinfo-1.0.so.0.2.10 osinfo_entity_get_type With it applied samples % image name symbol name 8757 2.6948 libosinfo-1.0.so.0.2.10 osinfo_entity_get_type So I guess that is probably worth it. NB, i modified your demo.c program so that it iterates over that code 50 times, so we get an acceptably long run time, otherwise the performance count sampling is too non-deterministic Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| From lasse.schuirmann at gmail.com Wed Jun 4 16:54:06 2014 From: lasse.schuirmann at gmail.com (Lasse Schuirmann) Date: Wed, 4 Jun 2014 18:54:06 +0200 Subject: [Libosinfo] (no subject) Message-ID: <1401900847-18153-1-git-send-email-lasse.schuirmann@gmail.com> Hello again, I updated the JEOS patch so that it works now too. The ejection is removed and the commandline parameters are minimized. The only thing left is the internet-connection-needed flag. I'll look into it in the next days. Greetings, Lasse From lasse.schuirmann at gmail.com Wed Jun 4 16:54:07 2014 From: lasse.schuirmann at gmail.com (Lasse Schuirmann) Date: Wed, 4 Jun 2014 18:54:07 +0200 Subject: [Libosinfo] [PATCH] debian: Add desktop installation script In-Reply-To: <1401900847-18153-1-git-send-email-lasse.schuirmann@gmail.com> References: <1401900847-18153-1-git-send-email-lasse.schuirmann@gmail.com> Message-ID: <1401900847-18153-2-git-send-email-lasse.schuirmann@gmail.com> This also fixes the JEOS script. --- data/install-scripts/debian.xml | 230 ++++++++++++++++++++++++++++++++++++++-- data/oses/debian.xml.in | 1 + 2 files changed, 220 insertions(+), 11 deletions(-) diff --git a/data/install-scripts/debian.xml b/data/install-scripts/debian.xml index c5c8592..e148352 100644 --- a/data/install-scripts/debian.xml +++ b/data/install-scripts/debian.xml @@ -1,4 +1,5 @@ + jeos preseed.cfg @@ -8,6 +9,7 @@ + initrd + + + + + + desktop + preseed.cfg + true + + + + + + + + + + + + + + + + + + + initrd +