Re: [spice-gtk v1 3/5] usb-device-manager: handling failure from GUdevClient

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

 



Shortlog: "Handle failures from g_udev_client_new()" or "Handle failed
creation of GUdevClient"

On Tue, Nov 15, 2016 at 12:26:53AM +0100, Victor Toso wrote:
> From: Victor Toso <me@xxxxxxxxxxxxxx>
> 
> g_udev_client_new() can fail in more then one situation in its
> initable_init() method.

"more *than* one situation"
However I'm not sure I understand why it's important that there are
multiple failures possible in initable_init()? Your point is that it can
fail, right? I got distracted by the "in more than one situation".
I would not go into details, the fact that we are using GInitable means
that we should handle initialization failures.

> 
> Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
> ---
>  src/usb-device-manager.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index 3d4bd98..ae73a02 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -321,6 +321,10 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
>      /* Start listening for usb devices plug / unplug */
>  #ifdef USE_GUDEV
>      priv->udev = g_udev_client_new(subsystems, err);
> +    if (priv->udev == NULL) {
> +        g_warning("Error initializing GUdevClient");
> +        return FALSE;
> +    }

Most of the time the error is ignored by the callers, so I would log
err->message in the g_warning() (being careful that *err can be NULL).

Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]