[libvirt] [sandbox PATCH 01/10] Add an utility function for guessing filetype from file extension

Daniel P. Berrange berrange at redhat.com
Fri Jun 26 14:32:12 UTC 2015


On Fri, Jun 26, 2015 at 03:27:36PM +0200, Eren Yagdiran wrote:
> Consider the file name extension as the image type, except for .img that are usually RAW images

NB, try to line wrap commit messages at less than 80 chracters

> diff --git a/libvirt-sandbox/libvirt-sandbox-util.c b/libvirt-sandbox/libvirt-sandbox-util.c
> new file mode 100644
> index 0000000..079ecd6
> --- /dev/null
> +++ b/libvirt-sandbox/libvirt-sandbox-util.c

> +gint gvir_sandbox_util_guess_image_format(const gchar *path,
> +                                          GError **error)
> +{
> +    gchar *tmp;
> +
> +    if ((tmp = strchr(path, '.')) == NULL) {
> +        return -1;

Missing a g_set_error() call here.

> +    }
> +    tmp = tmp + 1;
> +
> +    if (g_str_equal(tmp,"img")==TRUE){

Comparing == TRUE is not really needed, nor at the {} braces

> +       return GVIR_CONFIG_DOMAIN_DISK_FORMAT_RAW;
> +    }
> +
> +    return gvir_sandbox_util_disk_format_from_str(tmp, error);
> +}

ACK, I'll fix these mistakes myself before pushing

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list