[virt-tools-list] [PATCH virt-viewer 1/6] file: make constructor accept NULL location

Eduardo Lima (Etrunko) etrunko at redhat.com
Wed Jun 28 13:30:41 UTC 2017


On 23/06/17 12:30, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
> 
> We are going to make empty/fake VirtViewerFile.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> ---
>  src/virt-viewer-file.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
> index 9ff2a05..dfc6164 100644
> --- a/src/virt-viewer-file.c
> +++ b/src/virt-viewer-file.c
> @@ -141,11 +141,13 @@ enum  {
>  VirtViewerFile*
>  virt_viewer_file_new(const gchar* location, GError** error)
>  {
> -    GError* inner_error = NULL;
> +    VirtViewerFile* self = VIRT_VIEWER_FILE(g_object_new(VIRT_VIEWER_TYPE_FILE, NULL));
>  
> -    g_return_val_if_fail (location != NULL, NULL);
> +    if (!location) {
> +        return self;
> +    }
>  

I would move this test after the declaration of the variables.

> -    VirtViewerFile* self = VIRT_VIEWER_FILE(g_object_new(VIRT_VIEWER_TYPE_FILE, NULL));
> +    GError* inner_error = NULL;
>      GKeyFile* keyfile = self->priv->keyfile;
>  

+    if (!location) {
+        return self;
+    }

Here.

>      g_key_file_load_from_file(keyfile, location,
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko at redhat.com




More information about the virt-tools-list mailing list