Re: [PATCH 3/3] Fix "NULL_RETURNS" caught by coverity

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

 




----- Original Message -----
> Hi Marc,
> 
> 
> On Mon, Jul 14, 2014 at 12:19 PM, Marc-André Lureau < mlureau@xxxxxxxxxx >
> wrote:
> 
> 
> Hi,
> 
> All of those changes are OOM conditions. How can we shut coverity on those?
> 
> Yes, there is a simple way and that's what we have in Evolution Data Server.
> Long story short, we can just add some comments in the code like: /*
> coverity[unchecked_value] */
> Please, take a look on:
> https://git.gnome.org/browse/evolution-data-server/commit/?id=a317be96dcffe6ce2c5900fe4e76d955e2294ce9

I don't see allocation failure workarounds here.

> Can I go for it?

For consistency, I would prefer to avoid checking for allocation failures.

Also using glib API for allocations for the same reason.

> 
> Why does it warn here and not for other allocations?
> 
> Hmmm. I don't know, maybe these are the cases where we are using the members
> of the structure right after the allocation fail, but it's just a guess.
> 

Could malloc & free do not have annotations like the glib ones.

What happens for example if you replace malloc() by g_malloc(), and free() by g_free() in the function below?

void send_data (uint32_t id, uint8_t* data, size_t data_size)
{
    size_t size = sizeof (ControllerData) + data_size;
    ControllerData* msg = (ControllerData*)malloc (size);

    msg->base.id = id;
    msg->base.size = (uint32_t)size;
    memcpy (msg->data, data, data_size);
    write_to_pipe (msg, size);
    free (msg);
}
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]