[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [libvirt-glib] Use gvir_error_set_literal in more places



This hunk was missing (forgot to save in my editor first :)

@@ -747,9 +747,9 @@ gboolean
gvir_connection_fetch_storage_pools(GVirConnection *conn,
 
     g_mutex_lock(priv->lock);
     if (!priv->conn) {
-        g_set_error(err, GVIR_CONNECTION_ERROR,
-                    0,
-                    "Connection is not open");
+        g_set_error_literal(err, GVIR_CONNECTION_ERROR,
+                            0,
+                            "Connection is not open");
         g_mutex_unlock(priv->lock);
         goto cleanup;
     }


On Mon, Dec 05, 2011 at 05:14:10PM +0100, Christophe Fergeau wrote:
> GVirConnection has some gvir_set_error uses that can be replaced
> by gvir_set_error_set_literal. When passing a single string, this is
> safer since we are guaranteed that unwanted printf-format sequences
> in the string won't cause issues.
> ---
>  libvirt-gobject/libvirt-gobject-connection.c |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
> index 50cd860..f478948 100644
> --- a/libvirt-gobject/libvirt-gobject-connection.c
> +++ b/libvirt-gobject/libvirt-gobject-connection.c
> @@ -421,9 +421,9 @@ gboolean gvir_connection_open(GVirConnection *conn,
>      if (!priv->uri) {
>          char *uri = virConnectGetURI(priv->conn);
>          if (!uri) {
> -            gvir_set_error(err, GVIR_CONNECTION_ERROR,
> +            gvir_set_error_literal(err, GVIR_CONNECTION_ERROR,
>                             0,
> -                           "%s", "Unable to get connection URI");
> +                           "Unable to get connection URI");
>              virConnectClose(priv->conn);
>              priv->conn = NULL;
>              g_mutex_unlock(priv->lock);
> @@ -618,9 +618,9 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn,
>  
>      g_mutex_lock(priv->lock);
>      if (!priv->conn) {
> -        g_set_error(err, GVIR_CONNECTION_ERROR,
> -                    0,
> -                    "Connection is not open");
> +        g_set_error_literal(err, GVIR_CONNECTION_ERROR,
> +                            0,
> +                            "Connection is not open");
>          g_mutex_unlock(priv->lock);
>          goto cleanup;
>      }
> @@ -633,9 +633,9 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn,
>          goto cleanup;
>  
>      if ((nactive = virConnectNumOfDomains(vconn)) < 0) {
> -        gvir_set_error(err, GVIR_CONNECTION_ERROR,
> -                       0,
> -                       "Unable to count domains");
> +        gvir_set_error_literal(err, GVIR_CONNECTION_ERROR,
> +                               0,
> +                               "Unable to count domains");
>          goto cleanup;
>      }
>      if (nactive) {
> @@ -644,9 +644,9 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn,
>  
>          active = g_new(gint, nactive);
>          if ((nactive = virConnectListDomains(vconn, active, nactive)) < 0) {
> -            gvir_set_error(err, GVIR_CONNECTION_ERROR,
> -                           0,
> -                           "Unable to list domains");
> +            gvir_set_error_literal(err, GVIR_CONNECTION_ERROR,
> +                                   0,
> +                                   "Unable to list domains");
>              goto cleanup;
>          }
>      }
> -- 
> 1.7.7.3
> 
> --
> libvir-list mailing list
> libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgpLIUAf2GSKs.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]