[Libosinfo] [libosinfo] Fix warnings in OsinfoLoader boolean support

Fabiano Fidencio fidencio at redhat.com
Wed Nov 13 15:28:54 UTC 2013


On Wed, 2013-11-13 at 16:16 +0100, Christophe Fergeau wrote:
> I always build with -O0, which sometimes makes me some warnings. The newly
> introduced boolean support in OsinfoLoader triggers some warnings when building with the
> default flags:
> 
> osinfo_loader.c: In function 'osinfo_loader_boolean':
> osinfo_loader.c:200:255: error: return makes integer from pointer without a cast [-Werror]
>      g_return_val_if_fail(ctxt != NULL, NULL);
>                                                                                                                                                                                                                                                                ^
> osinfo_loader.c:201:257: error: return makes integer from pointer without a cast [-Werror]
>      g_return_val_if_fail(xpath != NULL, NULL);
>                                                                                                                                                                                                                                                                  ^
> osinfo_loader.c: In function 'osinfo_loader_entity.isra.8':
> osinfo_loader.c:331:48: error: 'value_bool' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>                  osinfo_entity_set_param_boolean(entity, keys[i].name, value_bool);
> ---
>  osinfo/osinfo_loader.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
> index 0be18b8..b6dffba 100644
> --- a/osinfo/osinfo_loader.c
> +++ b/osinfo/osinfo_loader.c
> @@ -197,8 +197,8 @@ osinfo_loader_boolean(const char *xpath,
>      int i;
>      gboolean ret = FALSE;
>  
> -    g_return_val_if_fail(ctxt != NULL, NULL);
> -    g_return_val_if_fail(xpath != NULL, NULL);
> +    g_return_val_if_fail(ctxt != NULL, FALSE);
> +    g_return_val_if_fail(xpath != NULL, FALSE);
>  
>      count = osinfo_loader_nodeset(xpath, ctxt, &nodes, err);
>  
> @@ -280,7 +280,7 @@ static void osinfo_loader_entity(OsinfoLoader *loader,
>      /* 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;
> +        gboolean value_bool = FALSE;
>          gchar *xpath = NULL;
>          int j;
>  

ACK!




More information about the Libosinfo mailing list