[libvirt] [libvirt-glib][PATCH 2/2] gobject: Introduce gvir_connection_get_version

Christophe Fergeau cfergeau at redhat.com
Wed Sep 12 13:09:27 UTC 2012


On Tue, Sep 11, 2012 at 07:42:42PM +0200, Michal Privoznik wrote:
> +gboolean
> +gvir_connection_get_version(GVirConnection *conn,
> +                            gulong *version,
> +                            GError **err)

gulong gvir_connection_get_version(GVirConnection *conn, GError **error)
would feel more natural here as errors can be reported through the GError.

> +{
> +    GVirConnectionPrivate *priv;
> +    virConnectPtr vconn = NULL;
> +    gboolean ret = FALSE;
> +
> +    g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE);

Same comment as in the previous patch, I'd add a
 g_return_val_if_fail(err == NULL || *err == NULL, 0);

> +
> +    priv = conn->priv;
> +    g_mutex_lock(priv->lock);
> +    if (!priv->conn) {
> +        g_set_error_literal(err, GVIR_CONNECTION_ERROR, 0,
> +                            "Connection is not open");
> +        g_mutex_unlock(priv->lock);
> +        goto cleanup;
> +    }
> +
> +    vconn = priv->conn;
> +    /* Stop another thread closing the connection just at the minute */
> +    virConnectRef(vconn);
> +    g_mutex_unlock(priv->lock);
> +
> +    if ( virConnectGetVersion(priv->conn, version) < 0) {

extra space before 'virConnectGetVersion'

Looks good otherwise.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120912/45636169/attachment-0001.sig>


More information about the libvir-list mailing list