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

Christophe Fergeau cfergeau at redhat.com
Mon Dec 10 12:56:46 UTC 2018


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

(and since "treeinfo-" is a compile-time constant, gcc should be able to
replace this with 9 at compile-time).

On Sun, Dec 02, 2018 at 04:37:57PM +0100, Fabiano Fidêncio wrote:
> 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
> 
> _______________________________________________
> Libosinfo mailing list
> Libosinfo at redhat.com
> https://www.redhat.com/mailman/listinfo/libosinfo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libosinfo/attachments/20181210/db343bef/attachment.sig>


More information about the Libosinfo mailing list