[Spice-devel] [PATCH spice-gtk 4/7] usbredir: make channel lifetime equal to session lifetime

Hans de Goede hdegoede at redhat.com
Mon Feb 20 02:07:06 PST 2012


Hi,

On 02/19/2012 03:19 PM, Marc-André Lureau wrote:
> On Sun, Feb 19, 2012 at 12:50 AM, Hans de Goede<hdegoede at redhat.com>  wrote:
>> +    if (!priv->host)
>> +        g_error("Out of memory allocating usbredirhost");
>
> spice-gtk is a library, and should not abort a program using it.

Agreed.

> However, if it's for memory allocation reasons, then it does that
> already and it's the only reasonable thing to do.

Yes, the usbredirhost_open_full call can only fail if calloc returns
NULL.

> I would prefer if it didn't call g_error() here.

I understand but given that:
1) This only happens on memory allocation errors
2) glib already does a g_error on memory allocation errors
    in other places
3) Doing other error handling is way more complicated

I believe that this is the best solution here.

> Why is it not the policy of libusbredir to
> abort if allocation failed?

Because libusbredirparser and libusbredirhost are meant to be
generic libraries which can be used in various places, including some
which may have a different oom handling policy.

Regards,

Hans


More information about the Spice-devel mailing list