[Libosinfo] [libosinfo PATCH 1/3] loader: properly load the treeinfo attributes

Fabiano Fidêncio fabiano at fidencio.org
Sun Dec 2 15:37:57 UTC 2018


treeinfo attributes haven't been loaded properly due to the change done
in ab2ab35f, changing the hardcoded 9 to sizeof("treeinfo-").

The problem here is that size("treeinfo-") is 10, causing that any
comparison to fail.

Let's change the sizeof("treeinfo-") to strlen("treeinfo-").

Signed-off-by: Fabiano Fidêncio <fabiano at fidencio.org>
---
 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 030062b..b6b6bd2 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -1222,22 +1222,22 @@ static OsinfoTree *osinfo_loader_tree(OsinfoLoader *loader,
             continue;
 
         if (g_str_equal((const gchar *)nodes[i]->name,
-                        OSINFO_TREE_PROP_TREEINFO_FAMILY + sizeof("treeinfo-")))
+                        OSINFO_TREE_PROP_TREEINFO_FAMILY + strlen("treeinfo-")))
             osinfo_entity_set_param(OSINFO_ENTITY(tree),
                                     OSINFO_TREE_PROP_TREEINFO_FAMILY,
                                     (const gchar *)nodes[i]->children->content);
         else if (g_str_equal((const gchar *)nodes[i]->name,
-                             OSINFO_TREE_PROP_TREEINFO_VARIANT + sizeof("treeinfo-")))
+                             OSINFO_TREE_PROP_TREEINFO_VARIANT + strlen("treeinfo-")))
             osinfo_entity_set_param(OSINFO_ENTITY(tree),
                                     OSINFO_TREE_PROP_TREEINFO_VARIANT,
                                     (const gchar *)nodes[i]->children->content);
         else if (g_str_equal((const gchar *)nodes[i]->name,
-                             OSINFO_TREE_PROP_TREEINFO_VERSION + sizeof("treeinfo-")))
+                             OSINFO_TREE_PROP_TREEINFO_VERSION + strlen("treeinfo-")))
             osinfo_entity_set_param(OSINFO_ENTITY(tree),
                                     OSINFO_TREE_PROP_TREEINFO_VERSION,
                                     (const gchar *)nodes[i]->children->content);
         else if (g_str_equal((const gchar *)nodes[i]->name,
-                             OSINFO_TREE_PROP_TREEINFO_ARCH + sizeof("treeinfo-")))
+                             OSINFO_TREE_PROP_TREEINFO_ARCH + strlen("treeinfo-")))
             osinfo_entity_set_param(OSINFO_ENTITY(tree),
                                     OSINFO_TREE_PROP_TREEINFO_ARCH,
                                     (const gchar *)nodes[i]->children->content);
-- 
1.8.3.1




More information about the Libosinfo mailing list